|
27 | 27 | class TestTorchOps(unittest.TestCase): |
28 | 28 | edge_compile_config = executorch.exir.EdgeCompileConfig() |
29 | 29 |
|
30 | | - def _coreml_partitioner(self): |
| 30 | + def _coreml_partitioner(self, *, minimum_deployment_target=ct.target.iOS18): |
31 | 31 | compile_specs = CoreMLBackend.generate_compile_specs( |
32 | | - minimum_deployment_target=ct.target.iOS18 |
| 32 | + minimum_deployment_target=minimum_deployment_target |
33 | 33 | ) |
34 | 34 | return CoreMLPartitioner(compile_specs=compile_specs) |
35 | 35 |
|
@@ -158,6 +158,33 @@ def test_dequantize_affine_c8w_embedding_b4w_linear(self): |
158 | 158 | et_prog = delegated_program.to_executorch() |
159 | 159 | self._compare_outputs(et_prog, model, example_inputs) |
160 | 160 |
|
| 161 | + def test_dequantize_affine_c8w_embedding_c8w_linear_ios16(self): |
| 162 | + model, example_inputs = self._get_test_model() |
| 163 | + quantize_( |
| 164 | + model, |
| 165 | + IntxWeightOnlyConfig(weight_dtype=torch.int8, granularity=PerAxis(0)), |
| 166 | + lambda m, fqn: isinstance(m, torch.nn.Embedding), |
| 167 | + ) |
| 168 | + quantize_( |
| 169 | + model, |
| 170 | + IntxWeightOnlyConfig(weight_dtype=torch.int8, granularity=PerAxis(0)), |
| 171 | + ) |
| 172 | + ep = torch.export.export(model, example_inputs) |
| 173 | + delegated_program = executorch.exir.to_edge_transform_and_lower( |
| 174 | + ep, |
| 175 | + partitioner=[ |
| 176 | + self._coreml_partitioner(minimum_deployment_target=ct.target.iOS16) |
| 177 | + ], |
| 178 | + ) |
| 179 | + for node in delegated_program.exported_program().graph.nodes: |
| 180 | + if node.op == "call_function": |
| 181 | + assert node.target.__name__ in [ |
| 182 | + "executorch_call_delegate", |
| 183 | + "getitem", |
| 184 | + ], f"Got unexpected node target after delegation: {node.target.__name__}" |
| 185 | + et_prog = delegated_program.to_executorch() |
| 186 | + self._compare_outputs(et_prog, model, example_inputs) |
| 187 | + |
161 | 188 | def test_dequantize_codebook_linear_per_grouped_col(self): |
162 | 189 | model, example_inputs = self._get_test_model() |
163 | 190 | quantize_( |
@@ -298,6 +325,7 @@ def forward(self, x): |
298 | 325 | test_runner.test_dequantize_affine_c4w_embedding() |
299 | 326 | test_runner.test_dequantize_affine_c4w_linear() |
300 | 327 | test_runner.test_dequantize_affine_c8w_embedding_b4w_linear() |
| 328 | + test_runner.test_dequantize_affine_c8w_embedding_c8w_linear_ios16() |
301 | 329 | test_runner.test_dequantize_codebook_linear_per_grouped_col() |
302 | 330 | test_runner.test_dequantize_codebook_linear_per_grouped_row() |
303 | 331 | test_runner.test_dequantize_codebook_embedding_per_grouped_col() |
|
0 commit comments