|
15 | 15 | from executorch.backends.nxp.aten_passes.split_group_convolution import ( |
16 | 16 | SplitGroupConvolution, |
17 | 17 | ) |
18 | | -from executorch.backends.nxp.neutron_partitioner import NeutronPartitioner |
19 | | -from executorch.backends.nxp.nxp_backend import generate_neutron_compile_spec |
20 | | -from executorch.backends.nxp.tests.executorch_pipeline import ( |
21 | | - _quantize_model, |
22 | | - get_random_calibration_inputs, |
23 | | - to_model_input_spec, |
24 | | -) |
| 18 | +from executorch.backends.nxp.tests.executorch_pipeline import to_quantized_edge_program |
25 | 19 | from executorch.backends.nxp.tests.executors import graph_contains_any_of_ops |
26 | 20 | from executorch.backends.nxp.tests.models import ( |
27 | 21 | Conv1dModule, |
28 | 22 | Conv2dModule, |
29 | 23 | Conv3dModule, |
30 | 24 | ) |
31 | | -from executorch.exir import EdgeCompileConfig, EdgeProgramManager |
32 | 25 | from executorch.exir.dialects._ops import ops as exir_ops |
33 | | -from executorch.extension.export_util import export_to_edge |
34 | 26 | from parameterized import parameterized |
35 | | -from torch.fx import GraphModule |
36 | | - |
37 | | - |
38 | | -def _quantize_and_lower_module( |
39 | | - module: GraphModule, input_shape: tuple[int, ...], target="imxrt700" |
40 | | -) -> EdgeProgramManager: |
41 | | - calibration_inputs = get_random_calibration_inputs(to_model_input_spec(input_shape)) |
42 | | - |
43 | | - exir_program_aten__module_quant = _quantize_model(module, calibration_inputs) |
44 | | - |
45 | | - edge_compile_config = EdgeCompileConfig(_check_ir_validity=False) |
46 | | - edge_program_manager = export_to_edge( |
47 | | - exir_program_aten__module_quant, |
48 | | - calibration_inputs[0], |
49 | | - edge_compile_config=edge_compile_config, |
50 | | - ) |
51 | | - |
52 | | - compile_spec = generate_neutron_compile_spec(target, "SDK_25_03") |
53 | | - partitioner = NeutronPartitioner(compile_spec) |
54 | | - return edge_program_manager.to_backend(partitioner) |
55 | 27 |
|
56 | 28 |
|
57 | 29 | class TestSplitGroupConvolution(unittest.TestCase): |
@@ -109,7 +81,7 @@ def test_split_group_convolution__2d(self, _, input_shape: list[int], group: int |
109 | 81 | assert np.allclose(out1, out2, atol=2.0e-7) |
110 | 82 |
|
111 | 83 | # Make sure the graph can be correctly quantized and lowered to edge. |
112 | | - ep = _quantize_and_lower_module( |
| 84 | + ep = to_quantized_edge_program( |
113 | 85 | modified_module, tuple(input_shape) |
114 | 86 | ).exported_program() |
115 | 87 | nodes = list(ep.graph.nodes) |
@@ -166,7 +138,7 @@ def test_split_group_convolution__1d(self, _, input_shape: list[int], group: int |
166 | 138 | assert np.allclose(out1, out2, atol=2.0e-7) |
167 | 139 |
|
168 | 140 | # Make sure the graph can be correctly quantized and lowered to edge. |
169 | | - ep = _quantize_and_lower_module( |
| 141 | + ep = to_quantized_edge_program( |
170 | 142 | modified_module, tuple(input_shape) |
171 | 143 | ).exported_program() |
172 | 144 | nodes = list(ep.graph.nodes) |
@@ -254,7 +226,7 @@ def test_split_group_convolution__applied_by_default(self): |
254 | 226 | assert np.allclose(out1, out2, atol=5.0e-7) |
255 | 227 |
|
256 | 228 | # Make sure the graph can be correctly quantized and lowered to edge. |
257 | | - ep = _quantize_and_lower_module( |
| 229 | + ep = to_quantized_edge_program( |
258 | 230 | modified_module, tuple(input_shape) |
259 | 231 | ).exported_program() |
260 | 232 | nodes = list(ep.graph.nodes) |
|
0 commit comments