MCPcopy Create free account
hub / github.com/pytorch/examples / call_module

Method call_module

fx/module_tracer.py:30–48  ·  view source on GitHub ↗

Override of Tracer.call_module (see https://pytorch.org/docs/stable/fx.html#torch.fx.Tracer.call_module). This override: 1) Stores away the qualified name of the caller for restoration later 2) Installs the qualified name of the caller in `current_module_qua

(self, m: torch.nn.Module, forward: Callable[..., Any],
                    args : Tuple[Any, ...], kwargs : Dict[str, Any])

Source from the content-addressed store, hash-verified

28 node_to_originating_module : Dict[torch.fx.Node, str] = {}
29
30 def call_module(self, m: torch.nn.Module, forward: Callable[..., Any],
31 args : Tuple[Any, ...], kwargs : Dict[str, Any]) -> Any:
32 """
33 Override of Tracer.call_module (see
34 https://pytorch.org/docs/stable/fx.html#torch.fx.Tracer.call_module).
35
36 This override:
37 1) Stores away the qualified name of the caller for restoration later
38 2) Installs the qualified name of the caller in `current_module_qualified_name`
39 for retrieval by `create_proxy`
40 3) Delegates into the normal Tracer.call_module method
41 4) Restores the caller's qualified name into current_module_qualified_name
42 """
43 old_qualname = self.current_module_qualified_name
44 try:
45 self.current_module_qualified_name = self.path_of_module(m)
46 return super().call_module(m, forward, args, kwargs)
47 finally:
48 self.current_module_qualified_name = old_qualname
49
50 def create_proxy(self, kind: str, target: torch.fx.node.Target, args: Tuple[Any, ...],
51 kwargs: Dict[str, Any], name: Optional[str] = None, type_expr: Optional[Any] = None):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected