diff --git a/src/python/torchdistx/_C/deferred_init.cc b/src/python/torchdistx/_C/deferred_init.cc index 3d3ce1e..7eb73b8 100644 --- a/src/python/torchdistx/_C/deferred_init.cc +++ b/src/python/torchdistx/_C/deferred_init.cc @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -40,7 +41,7 @@ py::object makeVariable(PyTypeObject* type, Tensor data) { constexpr auto s = PyInterpreterStatus::DEFINITELY_UNINITIALIZED; // Associate ATen and Python tensor instances. - data.unsafeGetTensorImpl()->init_pyobj(getPyInterpreter(), naked_obj, s); + data.unsafeGetTensorImpl()->pyobj_slot()->init_pyobj(getPyInterpreter(), naked_obj, s); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) auto* var = reinterpret_cast(naked_obj); @@ -83,7 +84,7 @@ py::object materializeVariable(const py::object& var) { // We might have already materialized `data`. Make sure that we preserve its // identity on the Python side and avoid creating a new Python tensor. c10::optional opt_materialized_var = - materialized_data.unsafeGetTensorImpl()->check_pyobj(getPyInterpreter()); + materialized_data.unsafeGetTensorImpl()->pyobj_slot()->check_pyobj(getPyInterpreter()); if (opt_materialized_var.has_value()) { return py::reinterpret_borrow(*opt_materialized_var); }