(self, name)
| 247 | def _wrap_mnode_getattr(orig_getattr): |
| 248 | @functools.wraps(orig_getattr) |
| 249 | def wraped_fn(self, name): |
| 250 | if is_tracing_module() and _graph_surgery_mode(): |
| 251 | obj = self.owner |
| 252 | current_graph = active_module_tracer().current_scope() |
| 253 | if self.top_graph is not None: |
| 254 | current_graph._add_input(self) |
| 255 | attr = getattr(obj, name) |
| 256 | node = attr |
| 257 | if not isinstance(attr, TracedModuleBuilder): |
| 258 | if isinstance(attr, Module): |
| 259 | attr = TracedModuleBuilder(attr) |
| 260 | setattr(obj, name, attr) |
| 261 | |
| 262 | if isinstance(attr, (NodeMixin, RawTensor)): |
| 263 | NodeMixin.wrap( |
| 264 | attr, |
| 265 | lambda: GetAttr.make( |
| 266 | self, |
| 267 | type=NodeMixin.get_wrapped_type(attr), |
| 268 | attr_name=name, |
| 269 | name="", |
| 270 | ), |
| 271 | ) |
| 272 | if isinstance(attr, (NodeMixin, RawTensor)): |
| 273 | node = NodeMixin.get(attr) |
| 274 | if isinstance(node, ModuleNode) and isinstance(attr, (NodeMixin, Module)): |
| 275 | node._owner = weakref.ref(attr) |
| 276 | return node |
| 277 | else: |
| 278 | node = object.__getattribute__(self, name) |
| 279 | return node |
| 280 | |
| 281 | return wraped_fn |
| 282 |
nothing calls this directly
no test coverage detected