pytorch/torch/csrc/autograd/python_saved_variable_hooks.h
Peter Bell cd9da3267c Rationalize API exports in torch_python (#68095)
Summary:
This renames `WindowsTorchApiMacro.h` to `Export.h` to mirror the c10 header `c10/macros/Export.h` and also updates it to use `C10_EXPORT`/`C10_IMPORT`. This also removes the `THP_API` macro from `THP_export.h` which appears to serve the same purpose.

cc pietern mrshenli pritamdamania87 zhaojuanmao satgera rohan-varma gqchen aazzolini osalpekar jiayisuse SciPioneer H-Huang

Pull Request resolved: https://github.com/pytorch/pytorch/pull/68095

Reviewed By: jbschlosser

Differential Revision: D32810881

Pulled By: albanD

fbshipit-source-id: d6949ccd0d80d6c3e5ec1264207611fcfe2503e3
2021-12-07 15:24:37 -08:00

32 lines
879 B
C++

#pragma once
#include <pybind11/pybind11.h>
#include <torch/csrc/autograd/python_variable.h>
#include <torch/csrc/autograd/saved_variable_hooks.h>
#include <torch/csrc/python_headers.h>
#include <torch/csrc/Export.h>
#include <ATen/ATen.h>
namespace py = pybind11;
namespace torch { namespace autograd {
struct PySavedVariableHooks : public SavedVariableHooks {
PySavedVariableHooks(py::function &pack_hook, py::function &unpack_hook);
void call_pack_hook(const at::Tensor &tensor) override;
at::Tensor call_unpack_hook() override;
~PySavedVariableHooks() override;
private:
PyObject* pack_hook_;
PyObject* unpack_hook_;
PyObject* data_ = nullptr;
};
struct PyDefaultSavedVariableHooks {
static void set_hooks(py::function &pack_hook, py::function &unpack_hook);
static void reset_hooks();
static std::unique_ptr<SavedVariableHooks> get_hooks();
};
}}