Get an attribute from a module by dotted path. Args: module (torch.nn.Module | torch.fx.GraphModule): Root module. target_str (str): Dotted attribute path, e.g., ``"sub.weight"``. Returns: Any: Resolved attribute on the module.
(module: torch.nn.Module | torch.fx.GraphModule, target_str: str)
| 258 | |
| 259 | |
| 260 | def _get_node_target(module: torch.nn.Module | torch.fx.GraphModule, target_str: str): |
| 261 | """Get an attribute from a module by dotted path. |
| 262 | |
| 263 | Args: |
| 264 | module (torch.nn.Module | torch.fx.GraphModule): Root module. |
| 265 | target_str (str): Dotted attribute path, e.g., ``"sub.weight"``. |
| 266 | |
| 267 | Returns: |
| 268 | Any: Resolved attribute on the module. |
| 269 | |
| 270 | """ |
| 271 | targets = target_str.split(".") |
| 272 | for target in targets[:-1]: |
| 273 | module = module.get_submodule(target) |
| 274 | return getattr(module, targets[-1]) |
| 275 | |
| 276 | |
| 277 | def _is_large_scalar(node: Node, gm: torch.fx.GraphModule): |
no test coverage detected