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

Function _any

imperative/python/megengine/traced_module/traced_module.py:194–212  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

192def _wrap_method_to_tensor_node():
193 def _any_method(name, func):
194 def _any(*args, **kwargs):
195 if is_tracing_module() and _graph_surgery_mode():
196 args, kwargs = _node_to_tensor(*args, **kwargs)
197 attr = getattr(args[0], name)
198 outs = attr
199 if callable(attr):
200 outs = attr(*(args[1:]), **kwargs)
201 if name == "__setitem__":
202 _node_to_tensor(outs)
203 return None
204 outs = _tensor_to_node(outs)
205 return outs
206 else:
207 outs = func
208 if callable(func):
209 outs = func(*args, **kwargs)
210 if isinstance(func, property):
211 outs = func.__get__(*args, **kwargs)
212 return outs
213
214 return _any
215

Callers

nothing calls this directly

Calls 4

_graph_surgery_modeFunction · 0.85
_node_to_tensorFunction · 0.85
_tensor_to_nodeFunction · 0.85
funcFunction · 0.50

Tested by

no test coverage detected