Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
ToNHWCPreprocess,
)
from executorch.backends.nxp.tests.graph_verifier import DetailedGraphVerifier
from executorch.backends.nxp.tests.model_output_comparator import (
NumericalStatsOutputComparator,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, why did you use the NumericalStatsOutputComparator for the QAT tests?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was inspired by our internal tests where we use it.

)
from executorch.backends.nxp.tests.models import AvgPool2dConvModule, AvgPool2dModule

from executorch.backends.nxp.tests.nsys_testing import lower_run_compare
Expand Down Expand Up @@ -314,6 +317,23 @@ def test__basic_nsys_inference(self, mocker):
model, input_shape, graph_verifier, use_new_flow_neutron_c=True
)

def test__basic_nsys_inference_qat(self, mocker):
input_shape = (2, 9, 6, 15)
model = AvgPool2dModule(False, 0)
comparator = NumericalStatsOutputComparator()
graph_verifier = DetailedGraphVerifier(
mocker, expected_delegated_ops={AvgPool2D: 1}, expected_non_delegated_ops={}
)

lower_run_compare(
model,
input_shape,
graph_verifier,
output_comparator=comparator,
use_new_flow_neutron_c=True,
use_qat=True,
)

def test__kernel_size_limit(self, mocker):
kernel_size = (1, 4096)
input_shape = (1, 4) + kernel_size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
ToChannelLastPreprocess,
)
from executorch.backends.nxp.tests.graph_verifier import DetailedGraphVerifier
from executorch.backends.nxp.tests.model_output_comparator import (
NumericalStatsOutputComparator,
)
from executorch.backends.nxp.tests.nsys_testing import lower_run_compare
from executorch.backends.nxp.tests.ops_aliases import (
ExecutorchDelegateCall,
Expand Down Expand Up @@ -280,6 +283,25 @@ def test__basic_nsys_inference(self, mocker):
model = MaxPool2dModule()
self.assert_delegated(model, input_shape, mocker)

def test__basic_nsys_inference_qat(self, mocker):
input_shape = (2, 11, 7, 16) # The old flow limited the batch size to 1.
model = MaxPool2dModule()
comparator = NumericalStatsOutputComparator()
graph_verifier = DetailedGraphVerifier(
mocker,
expected_delegated_ops={MaxPool2DWithIndices: 1, GetItem: 1},
expected_non_delegated_ops={},
)

lower_run_compare(
model,
input_shape,
graph_verifier,
output_comparator=comparator,
use_new_flow_neutron_c=True,
use_qat=True,
)

def test__kernel_size_limit(self, mocker):
kernel_size = (1, 4096)
input_shape = (1, 4) + kernel_size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
ToChannelFirstPreprocess,
ToChannelLastPreprocess,
)
from executorch.backends.nxp.tests.graph_verifier import BaseGraphVerifier
from executorch.backends.nxp.tests.graph_verifier import DetailedGraphVerifier
from executorch.backends.nxp.tests.model_output_comparator import (
NumericalStatsOutputComparator,
)
from executorch.backends.nxp.tests.models import (
MulTensorConvModule,
MulTensorModule,
Expand Down Expand Up @@ -229,19 +232,42 @@ class TestMulTensorNewNeutronFlow:
pytest.param((1, 4, 8, 8), id="4D."),
],
)
def test__basic_nsys_inference(self, x_input_shape):
def test__basic_nsys_inference(self, x_input_shape, mocker):
x_input_spec = ModelInputSpec(x_input_shape)
model = MulTensorModule()
graph_verifier = DetailedGraphVerifier(
mocker, expected_delegated_ops={MulTensor: 1}, expected_non_delegated_ops={}
)

lower_run_compare(
model,
[x_input_spec, x_input_spec],
graph_verifier,
use_new_flow_neutron_c=True,
)

@pytest.mark.parametrize(
"x_input_shape",
[
pytest.param((1, 4, 8), id="3D."),
pytest.param((1, 4, 8, 8), id="4D."),
],
)
def test__basic_nsys_inference_qat(self, x_input_shape, mocker):
x_input_spec = ModelInputSpec(x_input_shape)
model = MulTensorModule()
graph_verifier = BaseGraphVerifier(
exp_num_delegate_call_nodes=1,
exp_non_delegated_nodes=[],
comparator = NumericalStatsOutputComparator()
graph_verifier = DetailedGraphVerifier(
mocker, expected_delegated_ops={MulTensor: 1}, expected_non_delegated_ops={}
)

lower_run_compare(
model,
[x_input_spec, x_input_spec],
graph_verifier,
output_comparator=comparator,
use_new_flow_neutron_c=True,
use_qat=True,
)

@pytest.mark.parametrize(
Expand All @@ -259,11 +285,10 @@ def test__basic_nsys_inference(self, x_input_shape):
),
],
)
def test__correct_broadcast(self, input_spec):
def test__correct_broadcast(self, input_spec, mocker):
model = MulTensorModule()
graph_verifier = BaseGraphVerifier(
exp_num_delegate_call_nodes=1,
exp_non_delegated_nodes=[],
graph_verifier = DetailedGraphVerifier(
mocker, expected_delegated_ops={MulTensor: 1}, expected_non_delegated_ops={}
)

lower_run_compare(
Expand Down Expand Up @@ -308,16 +333,17 @@ def test__incorrect_broadcast(self, input_spec):
),
],
)
def test__w_conv(self, x_input_shape):
def test__w_conv(self, x_input_shape, mocker):
model = MulTensorConvModule()

n, c, h, w = x_input_shape
y_input_spec = ModelInputSpec((n, 8, h, w))
x_input_spec = ModelInputSpec(x_input_shape)

graph_verifier = BaseGraphVerifier(
exp_num_delegate_call_nodes=1,
exp_non_delegated_nodes=[],
graph_verifier = DetailedGraphVerifier(
mocker,
expected_delegated_ops={MulTensor: 1, Convolution: 1},
expected_non_delegated_ops={},
)

lower_run_compare(
Expand Down
Loading