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

Function process_inputs_to_parameters

backends/arm/process_node.py:130–161  ·  view source on GitHub ↗

Serialize bias and non-quantized weights.

(
    node: torch.fx.Node,
    tosa_graph: Any,
    edge_program: ExportedProgram,
    tosa_spec: TosaSpecification,
)

Source from the content-addressed store, hash-verified

128
129
130def process_inputs_to_parameters(
131 node: torch.fx.Node,
132 tosa_graph: Any,
133 edge_program: ExportedProgram,
134 tosa_spec: TosaSpecification,
135):
136 """Serialize bias and non-quantized weights."""
137 try:
138 tosa_arg = TosaArg(node, tosa_spec)
139 except ValueError as e:
140 raise ValueError(
141 f"Failed processing parameter placeholder: {node.name}. "
142 "Is the original torch function supported?"
143 ) from e
144 parameter_data = get_param(edge_program, node)
145
146 if not isinstance(parameter_data, torch.Tensor):
147 raise TypeError(
148 f"Expected parameter '{node.name}' to be a torch.Tensor, got "
149 f"{type(parameter_data).__name__}"
150 )
151 parameter_values = _tensor_to_numpy(parameter_data)
152 parameter_values = _prepare_const_values_for_tosa_dtype(
153 parameter_values, tosa_arg.dtype
154 )
155
156 tosa_graph.addConst(
157 normalize_symint(parameter_values.shape),
158 tosa_arg.dtype,
159 parameter_values,
160 name=tosa_arg.name,
161 )
162
163
164def process_inputs_to_buffers(

Callers 1

process_placeholderFunction · 0.85

Calls 5

TosaArgClass · 0.90
normalize_symintFunction · 0.90
_tensor_to_numpyFunction · 0.85
addConstMethod · 0.80

Tested by

no test coverage detected