MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / __block_forward

Method __block_forward

python/oneflow/nn/graph/proxy.py:227–238  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

225 return type(self)
226
227 def __block_forward(self, *args, **kwargs):
228 self.to(GraphModule)._is_executing_forward = True
229 args, kwargs = self.__pre_forward_map(*args, **kwargs)
230 with self.to(GraphModule).scope_context():
231 # "Instance method __func__ is the function object", "when an instance method object is called,
232 # the underlying function __func__ is called, inserting the class instance __self__ in front of
233 # the argument list."
234 # Reference: https://docs.python.org/3/reference/datamodel.html
235 unbound_forward_of_module_instance = self.to(Module).forward.__func__
236 result = unbound_forward_of_module_instance(self, *args, **kwargs)
237 self.to(GraphModule)._is_executing_forward = False
238 return result
239
240 def __pre_forward_map(self, *args, **kwargs):
241 # Insert identity op when doing activation checkpointing or pipeline execution.

Callers 1

__call__Method · 0.95

Calls 3

__pre_forward_mapMethod · 0.95
scope_contextMethod · 0.80
toMethod · 0.45

Tested by

no test coverage detected