Skip to content

Commit 9cfb684

Browse files
authored
NXP backend: Improve cifarnet speed by removing the initial pading. (#13279)
### Summary NXP backend: Improve cifarnet speed by removing the initial pading. ### Test plan Update to test_remove_io_quant_ops_pass__cifarnet() is part of the diff.
1 parent 4e80cad commit 9cfb684

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

backends/nxp/tests/ir/edge_passes/test_remove_io_quant_ops_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ def test_remove_io_quant_ops_pass__cifarnet():
5858
)
5959

6060
nodes = list(exec_prog.exported_program().graph.nodes)
61-
assert len(nodes) == 17
61+
assert len(nodes) == 11
6262
assert (
6363
nodes[0].meta["val"].dtype == torch.int8
6464
), "Input tensor doesn't have type INT8."
6565
assert (
66-
nodes[16].meta["val"][0].dtype == torch.int8
66+
nodes[10].meta["val"][0].dtype == torch.int8
6767
), "Output tensor doesn't have type INT8."
6868

6969
assert (

backends/nxp/tests/test_integration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 NXP
1+
# Copyright 2024-2025 NXP
22
#
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
@@ -43,8 +43,8 @@ def test_cifarnet():
4343

4444
delegation_info = get_delegation_info(exec_prog.exported_program().graph_module)
4545
assert delegation_info.num_delegated_subgraphs == 1
46-
assert delegation_info.num_non_delegated_nodes == 17
47-
assert delegation_info.num_delegated_nodes == 42
46+
assert delegation_info.num_non_delegated_nodes == 11
47+
assert delegation_info.num_delegated_nodes == 45
4848

4949
nodes = list(exec_prog.exported_program().graph.nodes)
5050
assert nodes[2].name == "quantized_decomposed_quantize_per_tensor_default"
-15.6 KB
Binary file not shown.

examples/nxp/experimental/cifar_net/cifar_net.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2024 NXP
1+
# Copyright 2024-2025 NXP
22
#
33
# This source code is licensed under the BSD-style license found in the
44
# LICENSE file in the root directory of this source tree.
@@ -57,7 +57,7 @@ class CifarNetModel(nn.Module):
5757
def __init__(self):
5858
super().__init__()
5959

60-
self.conv1 = nn.Conv2d(8, 32, 5)
60+
self.conv1 = nn.Conv2d(3, 32, 5)
6161
self.conv2 = nn.Conv2d(32, 32, 5)
6262
self.conv3 = nn.Conv2d(32, 64, 5)
6363
self.pool1 = nn.MaxPool2d(2, 2)
@@ -66,10 +66,7 @@ def __init__(self):
6666
self.softmax = nn.Softmax(1)
6767

6868
def forward(self, x):
69-
70-
# Neutron Backend does not yet have passses for automated padding if number of channels does not
71-
# fit to Neutron constrains (#channels == #MAC units). So define the model explicitly tailored for Neutron-C-64.
72-
x = F.pad(x, (2, 2, 2, 2, 0, 5))
69+
x = F.pad(x, (2, 2, 2, 2))
7370
x = self.conv1(x)
7471
x = self.pool1(x)
7572

0 commit comments

Comments
 (0)