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

Function get_node_spec_attr

backends/vulkan/utils.py:1657–1668  ·  view source on GitHub ↗
(node: torch.fx.Node, attr: str, return_first: bool = True)

Source from the content-addressed store, hash-verified

1655
1656
1657def get_node_spec_attr(node: torch.fx.Node, attr: str, return_first: bool = True):
1658 assert "spec" in node.meta
1659 spec = node.meta["spec"]
1660 if isinstance(spec, TensorSpec):
1661 return getattr(spec, attr) if hasattr(spec, attr) else None
1662 elif isinstance(spec, (list, tuple)):
1663 if return_first:
1664 return getattr(spec[0], attr) if hasattr(spec[0], attr) else None
1665 else:
1666 return [getattr(s, attr) if hasattr(s, attr) else None for s in spec]
1667 else:
1668 raise RuntimeError(f"Cannot get attr for spec of type {type(spec)}")
1669
1670
1671def get_node_storage_type(node: torch.fx.Node) -> Optional[VkStorageType]:

Callers 3

get_node_storage_typeFunction · 0.85
get_node_memory_layoutFunction · 0.85
get_node_reprFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected