MCPcopy Create free account
hub / github.com/Tencent/TurboTransformers / DLPack_Capsule_Destructor

Function DLPack_Capsule_Destructor

turbo_transformers/python/pybind.cpp:41–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39namespace py = pybind11;
40
41static void DLPack_Capsule_Destructor(PyObject *data) {
42 auto *dlMTensor = (DLManagedTensor *)PyCapsule_GetPointer(data, "dltensor");
43 if (dlMTensor) {
44 // the dlMTensor has not been consumed, call deleter ourselves
45 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
46 dlMTensor->deleter(const_cast<DLManagedTensor *>(dlMTensor));
47 } else {
48 // the dlMTensor has been consumed
49 // PyCapsule_GetPointer has set an error indicator
50 PyErr_Clear();
51 }
52}
53
54static void BindConfig(py::module &m) {
55 py::enum_<core::BlasProvider>(m, "BlasProvider")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected