Skip to content

Commit 3eaa702

Browse files
committed
NXP backend: Replace CustomDelegationOptions with NeutronTargetSpec in new Neutron C flow references
1 parent 1111348 commit 3eaa702

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

backends/nxp/backend/ir/converter/node_converters/ops_converters/relu_converter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ def supports_partitioning_result(
4343
node, partition_list, filter_fn=is_not_qdq_node
4444
)
4545
if is_alone_in_partition:
46-
return activation_supported_on_target(node, neutron_target_spec)
46+
neutron_c = getattr(
47+
custom_delegation_options, "use_new_flow_neutron_c", False
48+
)
49+
return activation_supported_on_target(
50+
node, neutron_target_spec, use_new_flow_neutron_c=neutron_c
51+
)
4752

4853
return True
4954

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import numpy as np
77
import pytest
88
import torch
9-
109
from executorch.backends.nxp.backend.edge_program_converter import (
1110
EdgeProgramToIRConverter,
1211
exir_ops,
@@ -21,7 +20,9 @@
2120
ToNCHWPreprocess,
2221
ToNHWCPreprocess,
2322
)
23+
from executorch.backends.nxp.tests.graph_verifier import BaseGraphVerifier
2424
from executorch.backends.nxp.tests.models import Conv2dModule, LinearModule, ReLUModule
25+
from executorch.backends.nxp.tests.nsys_testing import lower_run_compare
2526
from torch.export import ExportedProgram
2627
from executorch.backends.nxp.tests.use_qat import * # noqa F403
2728

@@ -37,10 +38,10 @@ def reseed_model_per_test_run():
3738

3839

3940
class ConvReLUModule(torch.nn.Module):
40-
def __init__(self):
41+
def __init__(self, out_channels=8):
4142
super().__init__()
4243

43-
self.conv = Conv2dModule()
44+
self.conv = Conv2dModule(out_channels=out_channels)
4445
self.relu = torch.nn.ReLU()
4546

4647
def forward(self, x):
@@ -146,3 +147,27 @@ def test_relu_conversion__unsupported(mocker, input_shape):
146147
# Make sure the `relu` was NOT delegated.
147148
assert not graph_contains_any_of_ops(delegated_ep.graph, [ExecutorchDelegateCall])
148149
assert graph_contains_any_of_ops(delegated_ep.graph, [ReLU])
150+
151+
152+
@pytest.mark.parametrize(
153+
["model", "input_shape"],
154+
[
155+
pytest.param(
156+
LinearReLUModule(),
157+
(3, 9, 32),
158+
id="Linear: num_channels not divisible by NUM_MACS",
159+
),
160+
pytest.param(
161+
ConvReLUModule(out_channels=9),
162+
(1, 4, 32, 32),
163+
id="Conv: num_channels not divisible by NUM_MACS",
164+
),
165+
],
166+
)
167+
def test_relu_conversion__new_flow_support(mocker, model, input_shape):
168+
graph_verifier = BaseGraphVerifier(
169+
exp_num_delegate_call_nodes=1,
170+
exp_non_delegated_nodes=[],
171+
)
172+
173+
lower_run_compare(model, input_shape, graph_verifier, use_new_flow_neutron_c=True)

0 commit comments

Comments
 (0)