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

Function get_param_tensor

backends/transforms/utils.py:78–95  ·  view source on GitHub ↗
(
    exp_prog: ExportedProgram, node: torch.fx.Node
)

Source from the content-addressed store, hash-verified

76
77
78def get_param_tensor(
79 exp_prog: ExportedProgram, node: torch.fx.Node
80) -> Optional[torch.Tensor]:
81 if node is None:
82 return None
83 elif is_param(exp_prog, node):
84 return get_param(exp_prog, node)
85 elif is_buffer(exp_prog, node):
86 return get_buffer(exp_prog, node)
87 elif is_lifted_tensor_constant(exp_prog, node):
88 return get_lifted_tensor_constant(exp_prog, node)
89 elif is_get_attr_node(node):
90 # This is a hack to support both lifted and unlifted graph
91 try:
92 return getattr(node.graph.owning_module, node.target)
93 except AttributeError:
94 return getattr(exp_prog.graph_module, node.target)
95 raise RuntimeError(f"unsupported param type, {node.op}.")
96
97
98def create_constant_placeholder(

Callers 15

_get_bmm_replacementMethod · 0.90
annotateMethod · 0.90
update_kernelMethod · 0.90
get_tensorFunction · 0.90
callMethod · 0.90

Calls 1

is_get_attr_nodeFunction · 0.70

Tested by

no test coverage detected