Skip to content

Commit bfadd84

Browse files
committed
Fixes based on PR comments.
1 parent 0a1c27b commit bfadd84

3 files changed

Lines changed: 23 additions & 14 deletions

File tree

backends/nxp/backend/ir/converter/quantization_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2023-2025 NXP
1+
# Copyright 2023-2026 NXP
22
#
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.

backends/nxp/tests/ir/converter/node_converter/test_clamp_converter.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
)
2525
from executorch.backends.nxp.tests.executors import graph_contains_any_of_ops
2626
from executorch.backends.nxp.tests.graph_verifier import DetailedGraphVerifier
27-
from executorch.backends.nxp.tests.model_output_comparator import (
28-
NumericalStatsOutputComparator,
29-
)
3027
from executorch.backends.nxp.tests.nsys_testing import lower_run_compare
3128
from executorch.backends.nxp.tests.ops_aliases import (
3229
AddTensor,
@@ -81,7 +78,6 @@ def test__qat(self, mocker, min, max, use_qat):
8178
model = AddClampModule(min, max)
8279

8380
x_input_spec = ModelInputSpec(input_shape)
84-
comparator = NumericalStatsOutputComparator()
8581
graph_verifier = DetailedGraphVerifier(
8682
mocker,
8783
expected_delegated_ops={
@@ -95,7 +91,6 @@ def test__qat(self, mocker, min, max, use_qat):
9591
model=model,
9692
input_spec=[x_input_spec],
9793
dlg_model_verifier=graph_verifier,
98-
output_comparator=comparator,
9994
)
10095

10196
@pytest.mark.parametrize(
@@ -125,7 +120,6 @@ def test_convert_clamp__full_pipeline(self, mocker, request, min, max):
125120
model = AddClampModule(min, max)
126121

127122
x_input_spec = ModelInputSpec(input_shape)
128-
comparator = NumericalStatsOutputComparator()
129123
graph_verifier = DetailedGraphVerifier(
130124
mocker,
131125
expected_delegated_ops={
@@ -140,7 +134,6 @@ def test_convert_clamp__full_pipeline(self, mocker, request, min, max):
140134
input_spec=[x_input_spec],
141135
dlg_model_verifier=graph_verifier,
142136
request=request,
143-
output_comparator=comparator,
144137
)
145138

146139
@pytest.mark.parametrize(

backends/nxp/tests/ir/converter/node_converter/test_hardtanh_converter.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def test__invalid_bounds(self, activation_range):
184184
_ = HardTanhModule(*activation_range)
185185

186186
@pytest.mark.parametrize(
187-
"min, max, expected_tflite_ops",
187+
"min, max, expected_neutron_ir_ops",
188188
[
189189
pytest.param(
190190
0.1,
@@ -207,9 +207,23 @@ def test__invalid_bounds(self, activation_range):
207207
[Ops.ADD, Ops.RELU],
208208
id="min = 0, max = infinity (Relu)",
209209
),
210+
pytest.param(
211+
0,
212+
1.0,
213+
[Ops.ADD, Ops.RELU_0_TO_1],
214+
id="min = 0, max = 1 (Relu0To1)",
215+
),
216+
pytest.param(
217+
0,
218+
6.0,
219+
[Ops.ADD, Ops.RELU6],
220+
id="min = 0, max = 6 (Relu6)",
221+
),
210222
],
211223
)
212-
def test_convert_clamp__relu_vs_maxmin(self, mocker, min, max, expected_tflite_ops):
224+
def test_convert_clamp__relu_vs_maxmin(
225+
self, mocker, min, max, expected_neutron_ir_ops
226+
):
213227
input_shape = (23,)
214228
model = AddHardTanhModule(min, max)
215229

@@ -228,15 +242,17 @@ def test_convert_clamp__relu_vs_maxmin(self, mocker, min, max, expected_tflite_o
228242
intermediate_ep = converter_spy.call_args.args[1]
229243
quant_node = list(intermediate_ep.graph.nodes)[-2]
230244
dequant_node = list(intermediate_ep.graph.nodes)[-4]
231-
tflite_internal_ops = [
245+
neutron_ir_internal_ops = [
232246
op.builtin_code for op in neutron_ir_spy.spy_return.operator_codes.vector
233247
]
234248

235249
assert graph_contains_any_of_ops(intermediate_ep.graph, [HardTanh])
236-
assert len(tflite_internal_ops) == len(expected_tflite_ops) + 1 # Transpose
237-
assert all(op in tflite_internal_ops for op in expected_tflite_ops)
250+
assert (
251+
len(neutron_ir_internal_ops) == len(expected_neutron_ir_ops) + 1
252+
) # Transpose
253+
assert all(op in neutron_ir_internal_ops for op in expected_neutron_ir_ops)
238254

239-
if len(expected_tflite_ops) == 3:
255+
if len(expected_neutron_ir_ops) == 3:
240256
# Min/Max variant should have same input and output quantization
241257
assert all(
242258
q == dq for q, dq in zip(quant_node.args[1:], dequant_node.args[1:])

0 commit comments

Comments
 (0)