Support npu tensor for PyTorch installed by wheel(x86_64)
This commit is contained in:
@@ -73,18 +73,9 @@ PyObject * THPModule_npu_shutdown(PyObject * /* unused */)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
// Callback for python part. Used for additional initialization of python classes
|
||||
static PyObject * THPModule_initExtension(PyObject *_unused, PyObject *shm_manager_path) {
|
||||
HANDLE_TH_ERRORS
|
||||
torch_npu::utils::_initialize_python_bindings();
|
||||
Py_RETURN_NONE;
|
||||
END_HANDLE_TH_ERRORS
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
|
||||
static PyMethodDef TorchNpuMethods[] = {
|
||||
{"_npu_shutdown", (PyCFunction)THPModule_npu_shutdown, METH_NOARGS, nullptr},
|
||||
{"_initExtension", THPModule_initExtension, METH_NOARGS, nullptr},
|
||||
{nullptr, nullptr, 0, nullptr}
|
||||
};
|
||||
|
||||
@@ -111,6 +102,7 @@ PyObject* initModule(){
|
||||
AddPyMethodDefs(methods, torch_npu::profiler::profiler_functions());
|
||||
AddPyMethodDefs(methods, torch_npu::distributed::python_functions());
|
||||
AddPyMethodDefs(methods, torch_npu::utils::tensor_functions());
|
||||
AddPyMethodDefs(methods, torch_npu::utils::npu_extension_functions());
|
||||
static struct PyModuleDef torchnpu_module = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"torch_npu._C",
|
||||
|
||||
@@ -305,5 +305,23 @@ static void py_bind_tensor_types(const std::vector<PyTensorType>& tensor_types)
|
||||
}
|
||||
}
|
||||
|
||||
// Callback for python part. Used for additional initialization of python classes
|
||||
static PyObject * THPModule_initExtension(PyObject *_unused, PyObject *noargs) {
|
||||
HANDLE_TH_ERRORS
|
||||
_initialize_python_bindings();
|
||||
Py_RETURN_NONE;
|
||||
END_HANDLE_TH_ERRORS
|
||||
}
|
||||
|
||||
// autograd methods on torch._C
|
||||
static PyMethodDef TorchNpuExtensionMethods[] = {
|
||||
{"_initExtension", (PyCFunction)THPModule_initExtension, METH_NOARGS, nullptr},
|
||||
{nullptr, nullptr, 0, nullptr}
|
||||
};
|
||||
|
||||
PyMethodDef* npu_extension_functions() {
|
||||
return TorchNpuExtensionMethods;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,5 +28,7 @@ namespace utils {
|
||||
// torch.npu.DoubleTensor, etc. and binds them in their containing modules.
|
||||
void _initialize_python_bindings();
|
||||
|
||||
PyMethodDef* npu_extension_functions();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user