(node: torch.fx.Node, attr: str, return_first: bool = True)
| 1655 | |
| 1656 | |
| 1657 | def 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 | |
| 1671 | def get_node_storage_type(node: torch.fx.Node) -> Optional[VkStorageType]: |
no outgoing calls
no test coverage detected