xref: /aosp_15_r20/external/pytorch/torch/csrc/utils/object_ptr.cpp (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #include <c10/macros/Macros.h>
2 #include <torch/csrc/utils/object_ptr.h>
3 
4 #include <torch/csrc/python_headers.h>
5 
6 template <>
free()7 void THPPointer<PyObject>::free() {
8   if (ptr && C10_LIKELY(Py_IsInitialized()))
9     Py_DECREF(ptr);
10 }
11 
12 template class THPPointer<PyObject>;
13 
14 template <>
free()15 void THPPointer<PyCodeObject>::free() {
16   if (ptr && C10_LIKELY(Py_IsInitialized()))
17     Py_DECREF(ptr);
18 }
19 
20 template class THPPointer<PyCodeObject>;
21 
22 template <>
free()23 void THPPointer<PyFrameObject>::free() {
24   if (ptr && C10_LIKELY(Py_IsInitialized()))
25     Py_DECREF(ptr);
26 }
27 
28 template class THPPointer<PyFrameObject>;
29