3 #include <torch/csrc/python_headers.h> 5 #include <torch/csrc/Exceptions.h> 6 #include <torch/csrc/autograd/function.h> 7 #include <torch/csrc/autograd/variable.h> 8 #include <torch/csrc/autograd/saved_variable.h> 9 #include <torch/csrc/utils/object_ptr.h> 11 #include <c10/util/Optional.h> 12 #include <c10/core/DeviceGuard.h> 18 namespace torch {
namespace jit {
struct Graph; }}
19 namespace torch {
namespace autograd {
28 std::vector<int64_t> size;
37 variable_list apply(variable_list&& inputs)
override;
38 variable_list legacy_apply(
const variable_list& inputs);
40 void release_variables()
override;
41 std::string name()
const override;
42 std::shared_ptr<Function> get_shared_ptr()
override;
43 bool is_traceable()
override;
54 if (PyTuple_Check(obj.get()))
57 PyObject *tuple = PyTuple_New(1);
59 PyTuple_SET_ITEM(tuple, 0, obj.release());
69 PyObject *needs_input_grad;
78 PyObject *non_differentiable;
82 PyObject *dirty_tensors;
84 std::vector<torch::autograd::VariableInfo> output_info;
85 std::vector<torch::autograd::VariableInfo> input_info;
86 std::vector<torch::autograd::SavedVariable> saved_variables;
88 std::vector<bool> is_variable_input;
89 char has_freed_buffers;
96 bool THPFunction_initModule(PyObject *module);
97 extern PyTypeObject THPFunctionType;
98 extern PyObject *THPFunctionClass;
101 std::shared_ptr<torch::autograd::PyFunction> THPFunction_asFunction(
THPFunction*
self);
103 inline bool THPFunction_Check(PyObject* obj) {
104 return PyObject_IsInstance(obj, (PyObject*)&THPFunctionType);
Represents a a compute device on which a tensor is located.
A OptionalDeviceGuard is an RAII class that sets a device to some value on initialization, and resets the device to its original value on destruction.
Variable A Variable augments a Tensor with the ability to interact in our autograd machinery...
TensorOptions requires_grad(bool requires_grad=true)
Convenience function that returns a TensorOptions object with the requires_grad set to the given one...