mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Fix C API to be compatible with latest 3.11 beta (#81242)
Based off https://github.com/pytorch/pytorch/pull/80511 with extra changes: - Update pybind to the latest release as it contains some needed fixes - Extend the compat header to do reduce changes in code Pull Request resolved: https://github.com/pytorch/pytorch/pull/81242 Approved by: https://github.com/malfet, https://github.com/mattip
This commit is contained in:
@ -576,6 +576,12 @@ static int THPVariable_clear(THPVariable* self) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int THPFunction_traverse(THPFunction* self, visitproc visit, void* arg) {
|
||||
TORCH_INTERNAL_ASSERT(
|
||||
false, "Tensor tp_traverse function was not overriden properly");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* THPVariable_pynew(
|
||||
PyTypeObject* type,
|
||||
PyObject* args,
|
||||
@ -1646,7 +1652,7 @@ PyTypeObject THPVariableType = {
|
||||
Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
||||
nullptr, /* tp_doc */
|
||||
// Also set by metaclass
|
||||
nullptr, /* tp_traverse */
|
||||
(traverseproc)THPFunction_traverse, /* tp_traverse */
|
||||
(inquiry)THPVariable_clear, /* tp_clear */
|
||||
nullptr, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
@ -1693,7 +1699,7 @@ static void clear_slots(PyTypeObject* type, PyObject* self) {
|
||||
PyMemberDef* mp;
|
||||
|
||||
n = Py_SIZE(type);
|
||||
mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject*)type);
|
||||
mp = type->tp_members;
|
||||
for (i = 0; i < n; i++, mp++) {
|
||||
if (mp->type == T_OBJECT_EX && !(mp->flags & READONLY)) {
|
||||
char* addr = (char*)self + mp->offset;
|
||||
@ -1905,7 +1911,7 @@ static int traverse_slots(
|
||||
PyMemberDef* mp;
|
||||
|
||||
n = Py_SIZE(type);
|
||||
mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject*)type);
|
||||
mp = type->tp_members;
|
||||
for (i = 0; i < n; i++, mp++) {
|
||||
if (mp->type == T_OBJECT_EX) {
|
||||
char* addr = (char*)self + mp->offset;
|
||||
|
Reference in New Issue
Block a user