Skip to content

Commit 5e5de75

Browse files
ezyangfacebook-github-bot
authored andcommitted
Add getPyInterpreter() API (pytorch#62659)
Summary: Pull Request resolved: pytorch#62659 It turns out that it is occasionally useful to be able to access the PyInterpreter object from other Python bindings (see next diff in the stack). Make it publicly available. Signed-off-by: Edward Z. Yang <[email protected]> Test Plan: Imported from OSS Reviewed By: albanD Differential Revision: D30074926 Pulled By: ezyang fbshipit-source-id: 2f745ab7c7a672ed7215231fdf9eef6af9705511
1 parent 27135f8 commit 5e5de75

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

torch/csrc/autograd/python_variable.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ PyInterpreterHolder self_interpreter;
107107

108108
} // anonymous namespace
109109

110+
c10::impl::PyInterpreter* getPyInterpreter() {
111+
return self_interpreter.get();
112+
}
113+
110114
namespace py = pybind11;
111115

112116
PyObject *THPVariableClass = nullptr;

torch/csrc/autograd/python_variable.h

+2
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,5 @@ inline const at::Tensor& THPVariable_Unpack(THPVariable* var) {
5151
inline const at::Tensor& THPVariable_Unpack(PyObject* obj) {
5252
return THPVariable_Unpack(reinterpret_cast<THPVariable*>(obj));
5353
}
54+
55+
THP_API c10::impl::PyInterpreter* getPyInterpreter();

0 commit comments

Comments
 (0)