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

Function get_node_tensor_specs

exir/memory_planning.py:892–916  ·  view source on GitHub ↗

r""" Return the list of the tensor specs for the node or empty list if the node has no tensor specs.

(
    node: torch.fx.Node,
)

Source from the content-addressed store, hash-verified

890
891
892def get_node_tensor_specs(
893 node: torch.fx.Node,
894) -> Union[List[TensorSpec], Tuple[TensorSpec]]:
895 r"""
896 Return the list of the tensor specs for the node or empty list if the node
897 has no tensor specs.
898 """
899 # get tensor specs
900 if node.target == memory.view:
901 base = node.args[0]
902 assert isinstance(base, torch.fx.Node)
903 specs = base.meta.get("spec")
904 else:
905 specs = node.meta.get("spec")
906
907 if isinstance(specs, TensorSpec):
908 specs = [specs]
909 if not isinstance(specs, (list, tuple)):
910 return []
911 else:
912 return [
913 spec
914 for spec in specs
915 if not isinstance(spec, (int, float, bool, str, type(None)))
916 ]
917
918
919# Little bit hacky to check if the graph contains

Callers 9

_get_spec_from_nodeFunction · 0.90
_set_alloc_node_specMethod · 0.90
count_planned_inputsMethod · 0.90
get_graph_input_tensorsFunction · 0.85
get_graph_output_tensorsFunction · 0.85
collect_specs_from_nodesFunction · 0.85

Calls 1

getMethod · 0.45

Tested by 1

count_planned_inputsMethod · 0.72