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

Method __call__

imperative/python/megengine/module/module.py:135–151  ·  view source on GitHub ↗
(self, *inputs, **kwargs)

Source from the content-addressed store, hash-verified

133 return HookHandler(self._forward_hooks, hook)
134
135 def __call__(self, *inputs, **kwargs):
136 AutoNaming.push_scope(self.name if self.name is not None else self._short_name)
137 for hook in self._forward_pre_hooks.values():
138 modified_inputs = hook(self, inputs)
139 if modified_inputs is not None:
140 if not isinstance(modified_inputs, tuple):
141 modified_inputs = (modified_inputs,)
142 inputs = modified_inputs
143
144 outputs = self.forward(*inputs, **kwargs)
145
146 for hook in self._forward_hooks.values():
147 modified_outputs = hook(self, inputs, outputs)
148 if modified_outputs is not None:
149 outputs = modified_outputs
150 AutoNaming.pop_scope()
151 return outputs
152
153 def _flatten(
154 self,

Callers

nothing calls this directly

Calls 4

forwardMethod · 0.95
valuesMethod · 0.80
push_scopeMethod · 0.45
pop_scopeMethod · 0.45

Tested by

no test coverage detected