(self, *args, **kwargs)
| 139 | ) |
| 140 | |
| 141 | def __call__(self, *args, **kwargs): |
| 142 | assert self.to(GraphModule)._type == GraphBlockType.MODULE |
| 143 | self.__print(0, 1, self._shallow_repr()) |
| 144 | |
| 145 | args_tree = ArgsTree( |
| 146 | (args, kwargs), |
| 147 | True, |
| 148 | "_" |
| 149 | + self.to(GraphModule).name_prefix |
| 150 | + self.to(GraphModule).name |
| 151 | + "_input", |
| 152 | None, |
| 153 | ) |
| 154 | |
| 155 | for (name, arg) in args_tree.iter_named_nodes(): |
| 156 | if arg.is_leaf(): |
| 157 | arg_value = arg.value() |
| 158 | meta_repr_str = ( |
| 159 | arg_value._meta_repr() |
| 160 | if isinstance(arg_value, Tensor) |
| 161 | else str(type(arg_value)) |
| 162 | ) |
| 163 | in_str = "(INPUT:" + name + ":" + meta_repr_str + ")" |
| 164 | if not isinstance(arg_value, Tensor): |
| 165 | in_str = "[WARNING]" + in_str |
| 166 | self.to(GraphModule)._args_repr.append(in_str) |
| 167 | self.__print(0, 1, in_str) |
| 168 | |
| 169 | def _print_state(d): |
| 170 | for (_, n) in d.items(): |
| 171 | self.__print(0, 1, n._shallow_repr()) |
| 172 | |
| 173 | _print_state(self._parameters) |
| 174 | _print_state(self._buffers) |
| 175 | |
| 176 | # NOTE: The original nn.Module's __call__ method is ignored, which means |
| 177 | # that hooks of nn.Modules are ignored. It is not recommended |
| 178 | # to use hooks of nn.Module in nn.Graph for the moment. |
| 179 | with graph_build_util.DebugScopeContext( |
| 180 | self.to(GraphModule)._debug_min_s_level, |
| 181 | self.to(GraphModule)._debug_max_v_level, |
| 182 | self.to(GraphModule)._debug, |
| 183 | self.to(GraphModule)._debug_max_py_stack_depth, |
| 184 | self.to(GraphModule)._debug_only_user_py_stack, |
| 185 | ): |
| 186 | result = self.__block_forward(*args, **kwargs) |
| 187 | |
| 188 | outputs = () |
| 189 | if not (type(result) is tuple or type(result) is list): |
| 190 | outputs = (result,) |
| 191 | else: |
| 192 | outputs = result |
| 193 | |
| 194 | args_tree = ArgsTree( |
| 195 | (outputs, {}), |
| 196 | True, |
| 197 | "_" |
| 198 | + self.to(GraphModule).name_prefix |
nothing calls this directly
no test coverage detected