MCPcopy Create free account
hub / github.com/pytorch/executorch / _get_node_target

Function _get_node_target

backends/arm/quantizer/quantization_annotator.py:260–274  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

258
259
260def _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
277def _is_large_scalar(node: Node, gm: torch.fx.GraphModule):

Callers 1

_is_large_scalarFunction · 0.85

Calls 2

splitMethod · 0.80
get_submoduleMethod · 0.80

Tested by

no test coverage detected