Caffe2 - C++ API
A deep learning, cross platform ML framework
tensor.h
1 #pragma once
2 
3 #include <torch/csrc/autograd/function.h>
4 #include <torch/csrc/autograd/variable.h>
5 
6 #include <ATen/TensorGeometry.h>
7 #include <ATen/Type.h>
8 #include <c10/util/Optional.h>
9 
10 #include <cstdint>
11 #include <memory>
12 
13 namespace torch { namespace autograd {
14 
15 struct CopyBackwards : public Function {
16  variable_list apply(variable_list&& grads) override;
17 
18  at::Type *src_type = nullptr; // initialized for safety.
19  at::Device src_device = at::kCPU;
20 };
21 
22 // Performs grad[idx] = fn(grad[idx]), but out-of-place. The slicing operation
23 // grad[idx] is defined by the relative sizes, strides, and offset of base and
24 // view.
25 // When an in-place operation is done on a differentiable view, the base's
26 // grad_fn is updated to become a `CopySlice` wrapping the backward of the
27 // in-place operation.
28 // See NOTE [ Autograd View Variables ].
29 struct CopySlices : public Function {
30  CopySlices(
31  const Variable& base_var,
32  at::TensorGeometry view_,
33  std::shared_ptr<Function> fn_);
34 
35  variable_list apply(variable_list&& inputs) override;
36  void release_variables() override;
37 
38  at::TensorGeometry base;
39  at::TensorGeometry view;
40  std::shared_ptr<Function> fn;
41 };
42 
43 }}
Represents a a compute device on which a tensor is located.
Definition: Device.h:30
Variable A Variable augments a Tensor with the ability to interact in our autograd machinery...
Definition: variable.h:85
Definition: jit_type.h:17