Insert a ``call_module`` ``Node`` into the ``Graph``. A ``call_module`` node represents a call to the forward() function of a ``Module`` in the ``Module`` hierarchy. Args: module_name (str): The qualified name of the ``Module`` in the ``Module``
(self,
module_name: str,
args: Optional[Tuple['Argument', ...]] = None,
kwargs: Optional[Dict[str, 'Argument']] = None,
type_expr: Optional[Any] = None)
| 1089 | |
| 1090 | @compatibility(is_backward_compatible=True) |
| 1091 | def call_module(self, |
| 1092 | module_name: str, |
| 1093 | args: Optional[Tuple['Argument', ...]] = None, |
| 1094 | kwargs: Optional[Dict[str, 'Argument']] = None, |
| 1095 | type_expr: Optional[Any] = None) -> Node: |
| 1096 | """ |
| 1097 | Insert a ``call_module`` ``Node`` into the ``Graph``. A ``call_module`` node |
| 1098 | represents a call to the forward() function of a ``Module`` in the ``Module`` |
| 1099 | hierarchy. |
| 1100 | |
| 1101 | Args: |
| 1102 | |
| 1103 | module_name (str): The qualified name of the ``Module`` in the ``Module`` |
| 1104 | hierarchy to be called. For example, if the traced ``Module`` has a |
| 1105 | submodule named ``foo``, which has a submodule named ``bar``, the |
| 1106 | qualified name ``foo.bar`` should be passed as ``module_name`` to |
| 1107 | call that module. |
| 1108 | |
| 1109 | args (Optional[Tuple[Argument, ...]]): The positional arguments to be passed |
| 1110 | to the called method. Note that this should *not* include a ``self`` argument. |
| 1111 | |
| 1112 | kwargs (Optional[Dict[str, Argument]]): The keyword arguments to be passed |
| 1113 | to the called method |
| 1114 | |
| 1115 | type_expr (Optional[Any]): an optional type annotation representing the |
| 1116 | Python type the output of this node will have. |
| 1117 | |
| 1118 | Returns: |
| 1119 | |
| 1120 | The newly-created and inserted ``call_module`` node. |
| 1121 | |
| 1122 | .. note:: |
| 1123 | The same insertion point and type expression rules apply for this method |
| 1124 | as :meth:`Graph.create_node`. |
| 1125 | """ |
| 1126 | if (self.owning_module and |
| 1127 | self.owning_module.get_submodule(module_name) is None): |
| 1128 | warnings.warn("Attempted to insert a call_module Node with " |
| 1129 | "no underlying reference in the owning " |
| 1130 | "GraphModule! Call " |
| 1131 | "GraphModule.add_submodule to add the " |
| 1132 | "necessary submodule") |
| 1133 | return self.create_node('call_module', module_name, args, kwargs, type_expr=type_expr) |
| 1134 | |
| 1135 | @compatibility(is_backward_compatible=True) |
| 1136 | def call_method(self, |