Serialize bias and non-quantized weights.
(
node: torch.fx.Node,
tosa_graph: Any,
edge_program: ExportedProgram,
tosa_spec: TosaSpecification,
)
| 128 | |
| 129 | |
| 130 | def 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 | |
| 164 | def process_inputs_to_buffers( |
no test coverage detected