mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
* Change cpp_extensions.py to make it work on Windows * Fix linting * Show python paths * Debug * Debug 1 * set PYTHONPATH * Add ATen into library * expose essential libs and functions, and copy _C.lib * Specify dir in header * Update check_abi for MSVC * Activate cl environment to compile cpp extensions * change version string * Redirect stderr to stdout * Add monkey patch for windows * Remove unnecessary self * Fix various issues * Append necessary flags * add /MD flag to cuda * Install ninja * Use THP_API instead of THP_CLASS * Beautify the paths * Revert "Use THP_API instead of THP_CLASS" This reverts commit dd7e74c44db48e4c5f85bb8e3c698ff9de71ba2d. * Use THP_API instead of THP_CLASS(new)
39 lines
974 B
C
39 lines
974 B
C
#pragma once
|
|
|
|
#include <Python.h>
|
|
#include <memory>
|
|
#include <ATen/ATen.h>
|
|
|
|
#include "torch/csrc/autograd/variable.h"
|
|
#include "torch/csrc/THP_export.h"
|
|
|
|
// Python object that backs torch.autograd.Variable
|
|
struct THPVariable {
|
|
PyObject_HEAD
|
|
// Payload
|
|
torch::autograd::Variable cdata;
|
|
// Hooks to be run on backwards pass (corresponds to Python attr
|
|
// '_backwards_hooks', set by 'register_hook')
|
|
PyObject* backward_hooks;
|
|
};
|
|
|
|
THP_API PyObject *THPVariableClass;
|
|
|
|
bool THPVariable_initModule(PyObject *module);
|
|
THP_API PyObject * THPVariable_Wrap(torch::autograd::Variable var);
|
|
|
|
inline bool THPVariable_Check(PyObject *obj)
|
|
{
|
|
return THPVariableClass && PyObject_IsInstance(obj, THPVariableClass);
|
|
}
|
|
|
|
inline torch::autograd::Variable& THPVariable_Unpack(PyObject* obj) {
|
|
auto var = (THPVariable*)obj;
|
|
return var->cdata;
|
|
}
|
|
|
|
inline at::Tensor& THPVariable_UnpackData(PyObject* obj) {
|
|
auto var = (THPVariable*)obj;
|
|
return var->cdata.data();
|
|
}
|