(self, *args, **kwargs)
| 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. |
no test coverage detected