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

Method is_attached_to

imperative/python/src/grad.cpp:97–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97PyObject* GradKeyWrapper::is_attached_to(PyObject* const* args, size_t nargs) {
98 if (nargs != 1) {
99 PyErr_SetString(PyExc_TypeError, "expect 1 argument");
100 return nullptr;
101 }
102 auto* tw = TensorWrapper::try_cast(args[0]);
103 if (!tw) {
104 PyErr_SetString(PyExc_TypeError, "expect Tensor");
105 return nullptr;
106 }
107 if (imperative::apply(IsAttachedTo(m_key), tw->m_tensor->data())[0]
108 .cast<BoolValue>()) {
109 Py_RETURN_TRUE;
110 }
111 Py_RETURN_FALSE;
112}
113
114void GradKeyWrapper::enter() {
115 m_transformation = std::make_shared<GradTransformation>();

Callers 1

_is_attached_toMethod · 0.80

Calls 4

try_castFunction · 0.85
IsAttachedToClass · 0.85
applyFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected