MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / _is_external_value

Method _is_external_value

imperative/python/src/tensor.cpp:777–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

775}
776
777PyObject* TensorWrapper::_is_external_value() {
778 auto&& external_tsf =
779 TransformationManager::get_instance()
780 .segments[TransformationManager::Segment::ExternalConvert];
781 if (external_tsf.size() == 0 || external_tsf[0] == nullptr) {
782 Py_RETURN_FALSE;
783 }
784
785 auto* tsf = reinterpret_cast<ExternalConvertTransformation*>(external_tsf[0].get());
786 mgb_assert(tsf->enabled());
787 auto valueref = m_tensor->data();
788 if (valueref.is(tsf->value_type())) {
789 Py_RETURN_TRUE;
790 } else {
791 Py_RETURN_FALSE;
792 }
793}
794
795void dlpack_capsule_destructor(PyObject* data) {
796 if (!PyCapsule_IsValid(data, "dltensor")) {

Callers 7

__call__Method · 0.80
executeMethod · 0.80
wrapperFunction · 0.80
__call__Method · 0.80
test_external_tsf_setFunction · 0.80
workerFunction · 0.80

Calls 5

sizeMethod · 0.45
getMethod · 0.45
enabledMethod · 0.45
dataMethod · 0.45
isMethod · 0.45

Tested by 3

test_external_tsf_setFunction · 0.64
workerFunction · 0.64