mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Turn more functions and variables into static if they are not used outside the cpp files. Unused functions are removed. Pull Request resolved: https://github.com/pytorch/pytorch/pull/150930 Approved by: https://github.com/Skylion007 Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
38 lines
818 B
C++
38 lines
818 B
C++
#include <torch/csrc/dynamo/utils.h>
|
|
|
|
namespace torch::dynamo {
|
|
|
|
static std::array<PyMethodDef, 1> _methods = {{
|
|
{nullptr,
|
|
nullptr,
|
|
0,
|
|
nullptr} // Sentinel value indicating the end of the array
|
|
}};
|
|
|
|
static bool is_instancemethod(py::object obj) {
|
|
return PyInstanceMethod_Check(obj.ptr());
|
|
}
|
|
|
|
static struct PyModuleDef _module = {
|
|
PyModuleDef_HEAD_INIT,
|
|
"torch._C._dynamo.utils",
|
|
"Module containing C utils",
|
|
-1,
|
|
_methods.data()};
|
|
|
|
PyObject* torch_c_dynamo_utils_init() {
|
|
auto m = PyModule_Create(&_module);
|
|
if (m == nullptr)
|
|
return nullptr;
|
|
|
|
#ifdef Py_GIL_DISABLED
|
|
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
|
|
#endif
|
|
|
|
auto py_m = py::handle(m).cast<py::module>();
|
|
py_m.def("is_instancemethod", is_instancemethod);
|
|
return m;
|
|
}
|
|
|
|
} // namespace torch::dynamo
|