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

Method load

imperative/python/src/helper.h:336–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

334struct from_none_caster : public type_caster_base<T> {
335 using base = type_caster_base<T>;
336 bool load(handle src, bool convert) {
337 if (!convert || !src.is_none()) {
338 return base::load(src, convert);
339 }
340 // adapted from pybind11::implicitly_convertible
341 auto temp = reinterpret_steal<object>(
342 PyObject_Call((PyObject*)this->typeinfo->type, tuple().ptr(), nullptr));
343 if (!temp) {
344 PyErr_Clear();
345 return false;
346 }
347 // adapted from pybind11::detail::type_caster_generic
348 if (base::load(temp, false)) {
349 loader_life_support::add_patient(temp);
350 return true;
351 }
352 return false;
353 }
354};
355
356template <>

Callers 1

loadMethod · 0.45

Calls 2

loadFunction · 0.70
ptrMethod · 0.45

Tested by

no test coverage detected