Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backends/nxp/requirements-eiq.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
--index-url https://eiq.nxp.com/repository
eiq-neutron-sdk==3.1.2
eiq-neutron-sdk==3.1.3
eiq_nsys
130 changes: 13 additions & 117 deletions backends/nxp/tests/ir/converter/node_converter/test_conv_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ def assert_delegated_and_correct(model, input_shape, mocker, request, use_qat):
expected_delegated_ops={Convolution: 1},
expected_non_delegated_ops={},
)
dataset = RandomDatasetCreator(low=-256, high=256)
dataset = RandomDatasetCreator(low=-1, high=1)
Comment thread
MartinPavella marked this conversation as resolved.

# Use quantized dataset and allow single bit error.
remove_quant_io_ops = True
comparator = AllCloseOutputComparator(atol=1)

lower_run_compare(
Expand All @@ -212,6 +215,7 @@ def assert_delegated_and_correct(model, input_shape, mocker, request, use_qat):
dataset,
comparator,
use_qat=use_qat,
remove_quant_io_ops=remove_quant_io_ops,
)

@staticmethod
Expand Down Expand Up @@ -248,40 +252,24 @@ def assert_not_delegated(model, input_shape, use_qat):
oc := 16,
qat := True,
id=f"qat={qat}, basic inference: " + _conv_id(ins, oc),
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (8, 16, 8, 32),
oc := 16,
qat := False,
id=f"qat={qat}, basic inference: " + _conv_id(ins, oc),
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (16, 8, 32, 64),
oc := 32,
qat := True,
id=f"qat={qat}, basic inference: " + _conv_id(ins, oc),
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (16, 8, 32, 64),
oc := 32,
qat := False,
id=f"qat={qat}, basic inference: " + _conv_id(ins, oc),
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (1, 8, 32, 64),
Expand All @@ -300,10 +288,6 @@ def assert_not_delegated(model, input_shape, use_qat):
oc := 24,
qat := True,
id=f"qat={qat}, basic inference: " + _conv_id(ins, oc),
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (1, 32, 48, 8),
Expand Down Expand Up @@ -347,30 +331,18 @@ def test__basic_nsys_inference(
qat := False,
id=f"qat={qat}, basic inference, depthwise: "
+ _conv_id(ins, ins[1], g=ins[1]),
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (16, 8, 32, 64),
qat := True,
id=f"qat={qat}, basic inference, depthwise: "
+ _conv_id(ins, ins[1], g=ins[1]),
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (16, 8, 32, 64),
qat := False,
id=f"qat={qat}, basic inference, depthwise: "
+ _conv_id(ins, ins[1], g=ins[1]),
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (1, 16, 32, 64),
Expand Down Expand Up @@ -398,9 +370,7 @@ def test__basic_nsys_inference(
),
],
)
def test__basic_nsys_inference_depthwise(
self, input_shape, is_qat, request, mocker
):
def test__depthwise(self, input_shape, is_qat, request, mocker):
out_channels = input_shape[1]
group = input_shape[1]
model = Conv2dModule(
Expand Down Expand Up @@ -483,16 +453,10 @@ def test__basic_nsys_inference_depthwise(
oc := 27,
qat := False,
id=f"qat={qat}, unusual shape inference: " + _conv_id(ins, oc),
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
],
)
def test__basic_nsys_inference__unusual_shapes(
self, input_shape, out_channels, is_qat, request, mocker
):
def test__unusual_shapes(self, input_shape, out_channels, is_qat, request, mocker):
model = Conv2dModule(in_channels=input_shape[1], out_channels=out_channels)

self.assert_delegated_and_correct(model, input_shape, mocker, request, is_qat)
Expand Down Expand Up @@ -565,10 +529,6 @@ def test__basic_nsys_inference__unusual_shapes(
qat := True,
id=f"qat={qat}, unusual shape inference, depthwise: "
+ _conv_id(ins, ins[1], g=ins[1]),
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (4, 21, 13, 17),
Expand All @@ -578,9 +538,7 @@ def test__basic_nsys_inference__unusual_shapes(
),
],
)
def test__basic_nsys_inference_depthwise__unusual_shapes(
self, input_shape, is_qat, request, mocker
):
def test__depthwise__unusual_shapes(self, input_shape, is_qat, request, mocker):
out_channels = input_shape[1]
group = input_shape[1]

Expand All @@ -607,9 +565,7 @@ def test__basic_nsys_inference_depthwise__unusual_shapes(
),
],
)
def test__basic_nsys_inference__implicit_batch(
self, input_shape, out_channels, is_qat, mocker, request
):
def test__implicit_batch(self, input_shape, out_channels, is_qat, mocker, request):
in_channels = input_shape[0]

model = Conv2dModule(in_channels=in_channels, out_channels=out_channels)
Expand Down Expand Up @@ -716,10 +672,6 @@ def test__basic_nsys_inference__implicit_batch(
d := (1, 4096),
qat := True,
id=f"qat={qat}, bounds of dilation width: {_conv_id(ins, oc, ks=ks, s=s, d=d)}",
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (3, 3, 3, 8500),
Expand All @@ -729,10 +681,6 @@ def test__basic_nsys_inference__implicit_batch(
d := (1, 4096),
qat := False,
id=f"qat={qat}, bounds of dilation width: {_conv_id(ins, oc, ks=ks, s=s, d=d)}",
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (4, 3, 8500, 3),
Expand All @@ -742,10 +690,6 @@ def test__basic_nsys_inference__implicit_batch(
d := (4096, 1),
qat := True,
id=f"qat={qat}, bounds of dilation height: {_conv_id(ins, oc, ks=ks, s=s, d=d)}",
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (4, 3, 8500, 3),
Expand All @@ -755,10 +699,6 @@ def test__basic_nsys_inference__implicit_batch(
d := (4096, 1),
qat := False,
id=f"qat={qat}, bounds of dilation height: {_conv_id(ins, oc, ks=ks, s=s, d=d)}",
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (2, 80, 35, 34),
Expand Down Expand Up @@ -788,7 +728,7 @@ def test__basic_nsys_inference__implicit_batch(
),
],
)
def test__basic_nsys_inference__big(
def test__big(
self,
input_shape,
out_channels,
Expand Down Expand Up @@ -907,10 +847,6 @@ def test__basic_nsys_inference__big(
d := (4096, 1),
qat := False,
id=f"qat={qat}, bounds of dilation height: {_conv_id(ins, ins[1], ks=ks, s=s, d=d, g=ins[1])}",
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (2, 80, 35, 34),
Expand All @@ -919,10 +855,6 @@ def test__basic_nsys_inference__big(
d := 1,
qat := True,
id=f"qat={qat}, bounds of kernel_h * kernel_w * input_channels: {_conv_id(ins, ins[1], ks=ks, s=s, d=d, g=ins[1])}",
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (2, 80, 35, 34),
Expand All @@ -931,14 +863,10 @@ def test__basic_nsys_inference__big(
d := 1,
qat := False,
id=f"qat={qat}, bounds of kernel_h * kernel_w * input_channels: {_conv_id(ins, ins[1], ks=ks, s=s, d=d, g=ins[1])}",
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
],
)
def test__basic_nsys_inference_depthwise__big(
def test__depthwise__big(
self, input_shape, kernel_size, stride, dilation, is_qat, request, mocker
):
out_channels = input_shape[1]
Expand Down Expand Up @@ -968,10 +896,6 @@ def test__basic_nsys_inference_depthwise__big(
b := True,
qat := True,
id=f"qat={qat}, some params not default: {_conv_id(ins, oc, ks=ks, s=s, d=d, p=p, b=b)}",
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (1, 8, 32, 32),
Expand Down Expand Up @@ -1038,10 +962,6 @@ def test__basic_nsys_inference_depthwise__big(
b := False,
qat := True,
id=f"qat={qat}, some params not default: {_conv_id(ins, oc, ks=ks, s=s, d=d, p=p, b=b)}",
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (3, 2, 40, 20),
Expand All @@ -1053,10 +973,6 @@ def test__basic_nsys_inference_depthwise__big(
b := False,
qat := False,
id=f"qat={qat}, some params not default: {_conv_id(ins, oc, ks=ks, s=s, d=d, p=p, b=b)}",
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (4, 6, 30, 30),
Expand All @@ -1068,10 +984,6 @@ def test__basic_nsys_inference_depthwise__big(
b := True,
qat := True,
id=f"qat={qat}, some params not default: {_conv_id(ins, oc, ks=ks, s=s, d=d, p=p, b=b)}",
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (4, 6, 30, 30),
Expand Down Expand Up @@ -1130,7 +1042,7 @@ def test__basic_nsys_inference_depthwise__big(
),
],
)
def test__nsys_inference__non_default_params(
def test__non_default_params(
self,
input_shape,
out_channels,
Expand Down Expand Up @@ -1207,10 +1119,6 @@ def test__nsys_inference__non_default_params(
b := True,
qat := True,
id=f"qat={qat}, some params not default: {_conv_id(ins, ins[1], ks=ks, s=s, d=d, p=p, b=b, g=ins[1])}",
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
),
pytest.param(
ins := (2, 12, 28, 28),
Expand All @@ -1230,10 +1138,6 @@ def test__nsys_inference__non_default_params(
p := (0, 2),
b := False,
qat := True,
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
id=f"qat={qat}, some params not default: {_conv_id(ins, ins[1], ks=ks, s=s, d=d, p=p, b=b, g=ins[1])}",
),
pytest.param(
Expand All @@ -1244,10 +1148,6 @@ def test__nsys_inference__non_default_params(
p := (0, 2),
b := False,
qat := False,
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
id=f"qat={qat}, some params not default: {_conv_id(ins, ins[1], ks=ks, s=s, d=d, p=p, b=b, g=ins[1])}",
),
pytest.param(
Expand All @@ -1258,10 +1158,6 @@ def test__nsys_inference__non_default_params(
p := (2, 2),
b := True,
qat := True,
marks=pytest.mark.xfail(
reason="AIR-14679",
strict=True,
),
id=f"qat={qat}, some params not default: {_conv_id(ins, ins[1], ks=ks, s=s, d=d, p=p, b=b, g=ins[1])}",
),
pytest.param(
Expand Down Expand Up @@ -1316,7 +1212,7 @@ def test__nsys_inference__non_default_params(
),
],
)
def test__nsys_inference_depthwise__non_default_params(
def test__depthwise__non_default_params(
self,
input_shape,
kernel_size,
Expand Down
2 changes: 1 addition & 1 deletion backends/nxp/tests/model_output_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def compare_sample(self, sample_dir, cpu_output_tensors, npu_output_tensors):
all_close = np.allclose(cpu_tensor, npu_tensor, atol=self.atol)
max_diff = None
if not all_close:
max_diff = np.abs(cpu_tensor - npu_tensor).max()
max_diff = np.abs(np.float32(cpu_tensor) - np.float32(npu_tensor)).max()
assert (
all_close
), f"NPU output doesn't match reference. Maximum absolute difference: {max_diff}"
Expand Down
6 changes: 3 additions & 3 deletions docs/source/backends/nxp/nxp-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ Among currently supported machine learning models are:
## Development Requirements

- [MCUXpresso IDE](https://www.nxp.com/design/design-center/software/development-software/mcuxpresso-software-and-tools-/mcuxpresso-integrated-development-environment-ide:MCUXpresso-IDE) or [MCUXpresso Visual Studio Code extension](https://www.nxp.com/design/design-center/software/development-software/mcuxpresso-software-and-tools-/mcuxpresso-for-visual-studio-code:MCUXPRESSO-VSC)
- [MCUXpresso SDK 25.12](https://mcuxpresso.nxp.com/mcuxsdk/25.12.00/html/index.html)
- eIQ Neutron SDK version 3.1.2, what you can download from eIQ PyPI:
- [MCUXpresso SDK 26.06](https://mcuxpresso.nxp.com/mcuxsdk/26.06.00/html/index.html)
- eIQ Neutron SDK version 3.1.3, what you can download from eIQ PyPI:

```commandline
$ pip install --index-url https://eiq.nxp.com/repository eiq-neutron-sdk==3.1.2
$ pip install --index-url https://eiq.nxp.com/repository eiq-neutron-sdk==3.1.3
```

Instead of manually installing requirements, except MCUXpresso IDE and SDK, you can use the setup script:
Expand Down
2 changes: 1 addition & 1 deletion examples/nxp/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -u
EIQ_PYPI_URL="${EIQ_PYPI_URL:-https://eiq.nxp.com/repository}"

# Install eIQ Neutron dependencies - SDK and simulator
pip install --index-url ${EIQ_PYPI_URL} eiq-neutron-sdk==3.1.2 eiq_nsys
pip install --index-url ${EIQ_PYPI_URL} eiq-neutron-sdk==3.1.3 eiq_nsys

# Get the directory of the current script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
Expand Down
Loading