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

Function process_inputs_to_buffers

backends/arm/process_node.py:164–193  ·  view source on GitHub ↗

Serialize quantized weights.

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

Source from the content-addressed store, hash-verified

162
163
164def process_inputs_to_buffers(
165 node: torch.fx.Node,
166 tosa_graph: Any,
167 edge_program: ExportedProgram,
168 tosa_spec: TosaSpecification,
169):
170 """Serialize quantized weights."""
171 try:
172 tosa_arg = TosaArg(node, tosa_spec)
173 except ValueError as e:
174 raise ValueError(
175 f"Failed processing buffer placeholder: {node.name}. "
176 "Is the original torch function supported?"
177 ) from e
178 buffer_data = get_buffer(edge_program, node)
179
180 if not isinstance(buffer_data, torch.Tensor):
181 raise TypeError(
182 f"Expected buffer '{node.name}' to be a torch.Tensor, got "
183 f"{type(buffer_data).__name__}"
184 )
185 buffer_values = _tensor_to_numpy(buffer_data)
186 buffer_values = _prepare_const_values_for_tosa_dtype(buffer_values, tosa_arg.dtype)
187
188 tosa_graph.addConst(
189 normalize_symint(buffer_values.shape),
190 tosa_arg.dtype,
191 buffer_values,
192 name=tosa_arg.name,
193 )
194
195
196def process_inputs_to_lifted_tensor_constants(

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