/usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/autograd
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/autograd/python_variable.h (1645B)
#pragma once
#include
#include
#include
#include
#include
// Python object that backs torch.autograd.Variable
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
struct THPVariable {
PyObject_HEAD;
// Payload
c10::MaybeOwned cdata;
// Hooks to be run on backwards pass (corresponds to Python attr
// '_backwards_hooks', set by 'register_hook')
PyObject* backward_hooks = nullptr;
};
THP_API PyObject *THPVariableClass;
THP_API PyObject *ParameterClass;
bool THPVariable_initModule(PyObject *module);
THP_API PyObject * THPVariable_Wrap(at::TensorBase var);
static inline bool THPVariable_CheckTypeExact(PyTypeObject* tp) {
// Check that a python object is a `Tensor`, but not a `Tensor` subclass.
// (A subclass could have different semantics.) The one exception is
// Parameter, which is used for Python bookkeeping but is equivalent to
// Tensor as far as C++ is concerned.
return (
tp == (PyTypeObject*)THPVariableClass ||
tp == (PyTypeObject*)ParameterClass
);
}
static inline bool THPVariable_CheckExact(PyObject *obj) {
return THPVariable_CheckTypeExact(Py_TYPE(obj));
}
inline bool THPVariable_Check(PyObject *obj)
{
return THPVariableClass && PyObject_IsInstance(obj, THPVariableClass);
}
inline const at::Tensor& THPVariable_Unpack(THPVariable* var) {
return *var->cdata;
}
inline const at::Tensor& THPVariable_Unpack(PyObject* obj) {
return THPVariable_Unpack(reinterpret_cast(obj));
}
THP_API c10::impl::PyInterpreter* getPyInterpreter();