Skip to content

Commit 7096412

Browse files
committed
NXP backend: Test avg_pool1d and max_pool1d with new Neutron flow.
1 parent 3c38936 commit 7096412

2 files changed

Lines changed: 49 additions & 3 deletions

File tree

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
ToNCHWPreprocess,
2929
ToNHWCPreprocess,
3030
)
31-
from executorch.backends.nxp.tests.graph_verifier import BaseGraphVerifier
31+
from executorch.backends.nxp.tests.graph_verifier import (
32+
BaseGraphVerifier,
33+
NonDelegatedNode,
34+
)
3235
from executorch.backends.nxp.tests.models import AvgPool2dConvModule, AvgPool2dModule
3336

3437
from executorch.backends.nxp.tests.nsys_testing import lower_run_compare
@@ -370,3 +373,23 @@ def test__stride_limit_exceeded(self):
370373
delegated_ep.graph, [ExecutorchDelegateCall]
371374
)
372375
assert graph_contains_any_of_ops(delegated_ep.graph, [AvgPool2D])
376+
377+
378+
class TestAvgPool1DNewNeutronFlow:
379+
380+
# Just a basic test to verify that the operator gets extended to the 2D variant correctly.
381+
def test__basic_nsys_inference__view_not_delegated(self):
382+
input_shape = (2, 4, 6) # The old flow limited the batch size to 1.
383+
model = AvgPool1DModule()
384+
graph_verifier = BaseGraphVerifier(
385+
exp_num_delegate_call_nodes=1, # Delegated AvgPool.
386+
exp_non_delegated_nodes=[
387+
NonDelegatedNode(
388+
"aten_view_copy_default", 2
389+
) # Non delegated due to shape requirements.
390+
],
391+
)
392+
393+
lower_run_compare(
394+
model, input_shape, graph_verifier, use_new_flow_neutron_c=True
395+
)

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import operator
77

88
import numpy as np
9-
import pytest
109
import torch
1110

1211
from executorch.backends.nxp.backend.edge_program_converter import (
@@ -19,9 +18,13 @@
1918
ToChannelFirstPreprocess,
2019
ToChannelLastPreprocess,
2120
)
22-
from executorch.backends.nxp.tests.graph_verifier import BaseGraphVerifier
21+
from executorch.backends.nxp.tests.graph_verifier import (
22+
BaseGraphVerifier,
23+
NonDelegatedNode,
24+
)
2325
from executorch.backends.nxp.tests.nsys_testing import lower_run_compare
2426
from executorch.backends.nxp.tests.use_qat import * # noqa F403
27+
import pytest
2528

2629
# noinspection PyProtectedMember
2730
from executorch.exir.dialects._ops import ops as exir_ops
@@ -353,3 +356,23 @@ def test__padding_to_kernel_ratio_exceeded(self):
353356
RuntimeError, match="pad should be at most half of effective kernel size"
354357
):
355358
to_quantized_edge_program(model, input_shape, use_new_flow_neutron_c=True)
359+
360+
361+
class TestMaxPool1DNewNeutronFlow:
362+
363+
# Just a basic test to verify that the operator gets extended to the 2D variant correctly.
364+
def test__basic_nsys_inference__view_not_delegated(self):
365+
input_shape = (2, 4, 6) # The old flow limited the batch size to 1.
366+
model = MaxPool1DModule()
367+
graph_verifier = BaseGraphVerifier(
368+
exp_num_delegate_call_nodes=1, # Delegated MaxPool.
369+
exp_non_delegated_nodes=[
370+
NonDelegatedNode(
371+
"aten_view_copy_default", 2
372+
) # Non delegated due to shape requirements.
373+
],
374+
)
375+
376+
lower_run_compare(
377+
model, input_shape, graph_verifier, use_new_flow_neutron_c=True
378+
)

0 commit comments

Comments
 (0)