Skip to content

Commit ce6e2cf

Browse files
NXP Backend: Update Neutron Software to version SDK_25.09 (#14591)
### Summary Update Neutron Software to version SDK 25.09. Test updated, as there is a known issue with SDK 25.09, tracked internally as AIR-13336. ### Test plan Unit test updated.
1 parent c1d0d3e commit ce6e2cf

12 files changed

+89
-28
lines changed

backends/nxp/nxp_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def neutron_compile_spec(
6464
Args:
6565
config: Neutron accelerator configuration, e.g. "imxrt700"
6666
neutron_converter_flavor: Flavor of the neutron-converter module to use. Neutron-converter module named "
67-
"'neutron_converter_SDK_25_06' has flavor 'SDK_25_06'.
67+
"'neutron_converter_SDK_25_09' has flavor 'SDK_25_09'.
6868
extra_flags: Extra flags for the Neutron compiler
6969
operators_not_to_delegate: List of operators that should not be delegated
7070
"""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
--index-url https://eiq.nxp.com/repository
2-
neutron_converter_SDK_25_06
2+
neutron_converter_SDK_25_09

backends/nxp/runtime/NeutronDriver.h

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,6 @@ extern "C" {
1818

1919
#include "NeutronErrors.h"
2020

21-
/* Neutron Driver error category codes */
22-
typedef enum ERROR_CATEGORY_DRIVER {
23-
ERROR_CATEGORY_DRIVER_GENERIC, /* Generic error category */
24-
ERROR_CATEGORY_DRIVER_UNSUPPORTED, /* Unsupported function */
25-
ERROR_CATEGORY_DRIVER_UCODE, /* Microcode bad magic or version incompatible.
26-
*/
27-
ERROR_CATEGORY_DRIVER_INVALID, /* Invalid arguments */
28-
ERROR_CATEGORY_DRIVER_BAD_HANDLE, /* Bad inference handle */
29-
ERROR_CATEGORY_DRIVER_NO_MEMORY, /* Not enough memory */
30-
ERROR_CATEGORY_DRIVER_INTERNAL_FAULT, /* Internal error */
31-
ERROR_CATEGORY_DRIVER_UNKNOWN_ARCH, /* Unknown architecture */
32-
ERROR_CATEGORY_DRIVER_TRACE_NOT_RUN, /* Tracing did not run, but trace buffer
33-
was requested. */
34-
ERROR_CATEGORY_DRIVER_TIMEOUT /* Timeout error. */
35-
} ERROR_CATEGORY_DRIVER;
36-
3721
/// Trace configuration to enable kernel level tracing.
3822
#define TRACE_CONFIG_KERNEL_LEVEL (1U << 0)
3923

@@ -169,6 +153,12 @@ NeutronError neutronCustomExec(
169153
NeutronModelHandle hdl,
170154
const NeutronDataConfig* neutron_dcfg);
171155

156+
/// - Setup the input and output data ptr to use Neutron memory area.
157+
/// - The input and ouput data ptr is stored in neutron_dcfg.
158+
NeutronError neutronDataSetup(
159+
NeutronModelHandle hdl,
160+
NeutronDataConfig* neutron_dcfg);
161+
172162
/// - Prepare Neutron execution for a model with the given configuration.
173163
/// - This function only prepares the execution by transferring the parameters
174164
/// to the firmware.
@@ -245,6 +235,29 @@ void* neutronMemAlloc(size_t alignment, size_t size);
245235
/// - This function is only available for Neutron-S in the Linux environment.
246236
void neutronMemFree(void* ptr);
247237

238+
/// - Allocates size bytes large buffer in DDR to be used for specialized
239+
/// kernels (e.g. batch matmul)
240+
/// Uses Linux CMA allocator
241+
NeutronError allocateBuffer(uint64_t size, void** pBuffer, bool userspace);
242+
243+
/// - Frees buffer allocated via allocateBuffer function
244+
NeutronError releaseBuffer(void* buffer);
245+
246+
/// - Clean/flush cache for DDR allocated buffer
247+
/// TODO: rename function as "cleanCache" to satisfy neutron-software naming
248+
/// convention
249+
NeutronError clean_cache(const void* addr, int size);
250+
251+
/// - Function for calling firmware for specialized kernel (matmul)
252+
NeutronError matmul(
253+
const void* info,
254+
int sizeInfo,
255+
const void* in,
256+
int sizeIn,
257+
const void* out,
258+
int sizeOut,
259+
int idxSlot);
260+
248261
/// Other functions to control the state of driver/firmware.
249262
#ifdef __cplusplus
250263
}

backends/nxp/runtime/NeutronErrors.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,32 @@ typedef enum ERROR_COMPONENT_ID {
3939
ERROR_COMPONENT_DRIVER = 0x3
4040
} ERROR_COMPONENT_ID;
4141

42+
/* Neutron Firmware error category codes */
43+
typedef enum ERROR_CATEGORY_FW {
44+
ERROR_CATEGORY_FW_GENERIC, /* Generic error category */
45+
ERROR_CATEGORY_FW_UCODE, /* Microcode bad magic or version incompatible. */
46+
ERROR_CATEGORY_FW_BUFFER_OVERFLOW, /* Buffer overflow error category */
47+
ERROR_CATEGORY_FW_NULL_POINTER, /* Pointer is null */
48+
ERROR_CATEGORY_FW_INTR_ERROR, /* Interrupt triggering error */
49+
ERROR_CATEGORY_FW_DMAPI_ERROR, /* DM API parameter error */
50+
} ERROR_CATEGORY_FW;
51+
52+
/* Neutron Driver error category codes */
53+
typedef enum ERROR_CATEGORY_DRIVER {
54+
ERROR_CATEGORY_DRIVER_GENERIC, /* Generic error category */
55+
ERROR_CATEGORY_DRIVER_UNSUPPORTED, /* Unsupported function */
56+
ERROR_CATEGORY_DRIVER_UCODE, /* Microcode bad magic or version incompatible.
57+
*/
58+
ERROR_CATEGORY_DRIVER_INVALID, /* Invalid arguments */
59+
ERROR_CATEGORY_DRIVER_BAD_HANDLE, /* Bad inference handle */
60+
ERROR_CATEGORY_DRIVER_NO_MEMORY, /* Not enough memory */
61+
ERROR_CATEGORY_DRIVER_INTERNAL_FAULT, /* Internal error */
62+
ERROR_CATEGORY_DRIVER_UNKNOWN_ARCH, /* Unknown architecture */
63+
ERROR_CATEGORY_DRIVER_TRACE_NOT_RUN, /* Tracing did not run, but trace buffer
64+
was requested. */
65+
ERROR_CATEGORY_DRIVER_TIMEOUT /* Timeout error. */
66+
} ERROR_CATEGORY_DRIVER;
67+
4268
/// Retrieve component name as string from NeutronError code.
4369
char* getNeutronErrorComponent(NeutronError ne);
4470

backends/nxp/tests/executorch_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def to_quantized_edge_program(
8585
[tuple[ModelInputSpec, ...]], list[tuple[torch.Tensor, ...]]
8686
] = get_random_calibration_inputs,
8787
target="imxrt700",
88-
neutron_converter_flavor="SDK_25_06",
88+
neutron_converter_flavor="SDK_25_09",
8989
remove_quant_io_ops=False,
9090
custom_delegation_options=CustomDelegationOptions(), # noqa B008
9191
get_quantizer_fn=lambda: NeutronQuantizer(),

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,18 @@ def test_conv1d_quant_conversion(stride, dilation, kernel_size, mocker):
7676

7777
@pytest.mark.parametrize("stride", [1, 2])
7878
@pytest.mark.parametrize("dilation", [2, 1])
79-
@pytest.mark.parametrize("kernel_size", [(1,), (3,)])
79+
@pytest.mark.parametrize(
80+
"kernel_size",
81+
[
82+
pytest.param(
83+
(1,),
84+
marks=pytest.mark.xfail(
85+
reason="Regression in Neutron SW 2.1.x (AIR-13336)", strict=True
86+
),
87+
),
88+
(3,),
89+
],
90+
)
8091
@pytest.mark.parametrize("padding", [(1,), 2])
8192
def test_conv1d_quant_conversion__padded(
8293
stride, dilation, kernel_size, padding, mocker
@@ -179,7 +190,18 @@ def test_conv1d_quant_conversion__depthwise(stride, dilation, kernel_size, mocke
179190

180191
@pytest.mark.parametrize("stride", [1, 2])
181192
@pytest.mark.parametrize("dilation", [2, 1])
182-
@pytest.mark.parametrize("kernel_size", [(1,), (3,)])
193+
@pytest.mark.parametrize(
194+
"kernel_size",
195+
[
196+
pytest.param(
197+
(1,),
198+
marks=pytest.mark.xfail(
199+
reason="Regression in Neutron SW 2.1.x (AIR-13336)", strict=True
200+
),
201+
),
202+
(3,),
203+
],
204+
)
183205
@pytest.mark.parametrize("padding", [(1,), 2])
184206
def test_conv1d_quant_conversion__depthwise__padded(
185207
stride, dilation, kernel_size, padding, mocker

backends/nxp/tests/test_neutron_converter_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_conv2d_neutron_conversion__default_flavor():
3030

3131
neutron_converter_manager = NeutronConverterManager()
3232
neutron_model = neutron_converter_manager.convert(
33-
tflite_model, "imxrt700", "SDK_25_06"
33+
tflite_model, "imxrt700", "SDK_25_09"
3434
)
3535

3636
assert len(

backends/nxp/tests/test_split_group_convolution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _quantize_and_lower_module(
5353
edge_compile_config=edge_compile_config,
5454
)
5555

56-
compile_spec = generate_neutron_compile_spec(target, "SDK_25_06")
56+
compile_spec = generate_neutron_compile_spec(target, "SDK_25_09")
5757
partitioner = NeutronPartitioner(compile_spec)
5858
return edge_program_manager.to_backend(partitioner)
5959

examples/nxp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $ examples/nxp/setup.sh
1313
2. Now run the `aot_neutron_compile.py` example with the `cifar10` model
1414
```commandline
1515
$ python -m examples.nxp.aot_neutron_compile --quantize \
16-
--delegate --neutron_converter_flavor SDK_25_06 -m cifar10
16+
--delegate --neutron_converter_flavor SDK_25_09 -m cifar10
1717
```
1818

1919
3. It will generate you `cifar10_nxp_delegate.pte` file which can be used with the MXUXpresso SDK `cifarnet_example` project, presented [here](https://mcuxpresso.nxp.com/mcuxsdk/latest/html/middleware/eiq/executorch/docs/nxp/topics/example_applications.html#how-to-build-and-run-executorch-cifarnet-example).

examples/nxp/aot_neutron_compile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ def _get_batch_size(data):
163163
"-c",
164164
"--neutron_converter_flavor",
165165
required=False,
166-
default="SDK_25_06",
166+
default="SDK_25_09",
167167
help="Flavor of installed neutron-converter module. Neutron-converter module named "
168-
"'neutron_converter_SDK_24_12' has flavor 'SDK_24_12'.",
168+
"'neutron_converter_SDK_25_09' has flavor 'SDK_25_09'.",
169169
)
170170
parser.add_argument(
171171
"-q",

0 commit comments

Comments
 (0)