Skip to content

Commit 0139303

Browse files
NXP backend: Add use new flag to custom compilation options, add op aliases (#19184)
### Summary Adds new flag `use_new_flow_neutron_c` to `CustomDelegationOptions`, enable passing it in `to_quantized_edge_program()` for using new Neutron converter conversion flow. Adds ops aliases for more readable tests. ### Test plan No tests at the moment, they will be added for each op. cc @robert-kalmar
1 parent 21531ee commit 0139303

4 files changed

Lines changed: 37 additions & 0 deletions

File tree

backends/nxp/backend/custom_delegation_options.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ class CustomDelegationOptions:
2222
# not create any NeutronGraph that can be called. This is done by the partitioner itself, and is not handled by
2323
# the individual node converters.
2424
allow_no_op_partitions: bool = False
25+
26+
# The new neutron converter flow has different constraints for supported operators. These need to be addressed when
27+
# deciding is operator is delegated or not in _is_supported_on_target().
28+
use_new_flow_neutron_c: bool = False

backends/nxp/nxp_backend.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import numpy as np
1616
import torch
1717

18+
from executorch.backends.nxp.backend.custom_delegation_options import (
19+
CustomDelegationOptions,
20+
)
1821
from executorch.backends.nxp.backend.data_format import DataFormat
1922
from executorch.backends.nxp.backend.edge_program_converter import (
2023
EdgeProgramToIRConverter,
@@ -229,6 +232,9 @@ def preprocess( # noqa C901
229232
edge_program,
230233
neutron_target_spec=NeutronTargetSpec(target),
231234
conversion_config=conversion_config,
235+
custom_delegation_options=CustomDelegationOptions(
236+
use_new_flow_neutron_c=use_new_flow_neutron_c
237+
),
232238
)
233239

234240
neutron_model = NeutronConverterManager(dump_kernel_selection_code).convert(

backends/nxp/tests/executorch_pipeline.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def to_quantized_edge_program(
194194
delegate_to_npu=True,
195195
) -> EdgeProgramManager:
196196
_neutron_target_spec = NeutronTargetSpec(target)
197+
custom_delegation_options.use_new_flow_neutron_c = use_new_flow_neutron_c
197198
if get_quantizer_fn is None:
198199
get_quantizer_fn = partial(
199200
_get_default_quantizer, _neutron_target_spec, use_qat

backends/nxp/tests/ops_aliases.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2026 NXP
2+
#
3+
# This source code is licensed under the BSD-style license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
# This file defines ops aliases for shorter and more readable test description. List is sorted alphabetically.
7+
# When finding a missing alias, add it at the correct place.
8+
9+
import torch
10+
from executorch.exir.dialects._ops import ops as exir_ops
11+
12+
AvgPool2D = exir_ops.edge.aten.avg_pool2d.default
13+
Bmm = exir_ops.edge.aten.bmm.default
14+
ExecutorchDelegateCall = torch.ops.higher_order.executorch_call_delegate
15+
HardTanh = exir_ops.edge.aten.hardtanh.default
16+
HardTanh_ = exir_ops.edge.aten.hardtanh_.default
17+
Slice = exir_ops.edge.aten.slice.Tensor
18+
SliceCopy = exir_ops.edge.aten.slice_copy.Tensor
19+
Softmax = exir_ops.edge.aten._softmax.default
20+
Squeeze = exir_ops.edge.aten.squeeze.default
21+
SqueezeDim = exir_ops.edge.aten.squeeze.dim
22+
SqueezeDims = exir_ops.edge.aten.squeeze.dims
23+
Unsqueeze = exir_ops.edge.aten.unsqueeze.default
24+
UpsampleBilinear2D = exir_ops.edge.aten.upsample_bilinear2d.vec
25+
UpsampleNearest2D = exir_ops.edge.aten.upsample_nearest2d.vec
26+
ViewCopy = exir_ops.edge.aten.view_copy.default

0 commit comments

Comments
 (0)