Skip to content

Commit 012bd15

Browse files
authored
Merge branch 'main' into gh/gasoonjia/61/orig
2 parents b0c6e62 + 8292d99 commit 012bd15

39 files changed

+988
-225
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ executorch
3333
│ ├── <a href="backends/openvino">openvino</a> - OpenVINO backend for Intel hardware.
3434
│ ├── <a href="backends/qualcomm">qualcomm</a> - Qualcomm-specific backends. See <a href="docs/source/backends-qualcomm.md">doc</a>.
3535
│ ├── <a href="backends/transforms">transforms</a> - Transformations for backend optimization.
36-
│ ├── <a href="backends/vulkan">vulkan</a> - Vulkan backend for cross-platform GPU support. See <a href="docs/source/backends-vulkan.md">doc</a>.
36+
│ ├── <a href="backends/vulkan">vulkan</a> - Vulkan backend for cross-platform GPU support. See <a href="docs/source/backends/vulkan/vulkan-overview.md">doc</a>.
3737
│ └── <a href="backends/xnnpack">xnnpack</a> - XNNPACK backend for optimized neural network operations. See <a href="docs/source/backends/xnnpack/xnnpack-overview.md">doc</a>.
3838
├── <a href="codegen">codegen</a> - Tooling to autogenerate bindings between kernels and the runtime.
3939
├── <a href="configurations">configurations</a> - Configuration files.

backends/arm/test/models/test_nn_modules.py

Lines changed: 77 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,91 @@
1717
- Transformer
1818
"""
1919

20+
from typing import Callable
21+
2022
import torch
2123
from executorch.backends.arm.test.common import parametrize
2224
from executorch.backends.arm.test.tester.test_pipeline import (
2325
TosaPipelineFP,
2426
TosaPipelineINT,
2527
)
2628

29+
30+
def make_module_wrapper(
31+
name: str, module_factory: Callable[[], torch.nn.Module]
32+
) -> torch.nn.Module:
33+
class ModuleWrapper(torch.nn.Module):
34+
def __init__(self):
35+
super().__init__()
36+
self._module = module_factory()
37+
38+
def forward(self, *args, **kwargs):
39+
return self._module(*args, **kwargs)
40+
41+
ModuleWrapper.__name__ = name
42+
ModuleWrapper.__qualname__ = name
43+
return ModuleWrapper()
44+
45+
2746
example_input = torch.rand(1, 6, 16, 16)
2847

2948
module_tests = [
30-
(torch.nn.Embedding(10, 10), (torch.LongTensor([[1, 2, 4, 5], [4, 3, 2, 9]]),)),
31-
(torch.nn.LeakyReLU(), (example_input,)),
32-
(torch.nn.BatchNorm1d(16), (torch.rand(6, 16, 16),)),
33-
(torch.nn.AdaptiveAvgPool2d((12, 12)), (example_input,)),
34-
(torch.nn.ConvTranspose2d(6, 3, 2), (example_input,)),
35-
(torch.nn.GRU(10, 20, 2), (torch.randn(5, 3, 10), torch.randn(2, 3, 20))),
36-
(torch.nn.GroupNorm(2, 6), (example_input,)),
37-
(torch.nn.InstanceNorm2d(16), (example_input,)),
38-
(torch.nn.PReLU(), (example_input,)),
3949
(
40-
torch.nn.Transformer(
41-
d_model=64,
42-
nhead=1,
43-
num_encoder_layers=1,
44-
num_decoder_layers=1,
45-
dtype=torch.float32,
50+
make_module_wrapper(
51+
"EmbeddingModule",
52+
lambda: torch.nn.Embedding(10, 10),
53+
),
54+
(torch.LongTensor([[1, 2, 4, 5], [4, 3, 2, 9]]),),
55+
),
56+
(
57+
make_module_wrapper("LeakyReLUModule", torch.nn.LeakyReLU),
58+
(example_input,),
59+
),
60+
(
61+
make_module_wrapper("BatchNorm1dModule", lambda: torch.nn.BatchNorm1d(16)),
62+
(torch.rand(6, 16, 16),),
63+
),
64+
(
65+
make_module_wrapper(
66+
"AdaptiveAvgPool2dModule",
67+
lambda: torch.nn.AdaptiveAvgPool2d((12, 12)),
68+
),
69+
(example_input,),
70+
),
71+
(
72+
make_module_wrapper(
73+
"ConvTranspose2dModule", lambda: torch.nn.ConvTranspose2d(6, 3, 2)
74+
),
75+
(example_input,),
76+
),
77+
(
78+
make_module_wrapper("GRUModule", lambda: torch.nn.GRU(10, 20, 2)),
79+
(torch.randn(5, 3, 10), torch.randn(2, 3, 20)),
80+
),
81+
(
82+
make_module_wrapper("GroupNormModule", lambda: torch.nn.GroupNorm(2, 6)),
83+
(example_input,),
84+
),
85+
(
86+
make_module_wrapper(
87+
"InstanceNorm2dModule", lambda: torch.nn.InstanceNorm2d(16)
88+
),
89+
(example_input,),
90+
),
91+
(
92+
make_module_wrapper("PReLUModule", torch.nn.PReLU),
93+
(example_input,),
94+
),
95+
(
96+
make_module_wrapper(
97+
"TransformerModule",
98+
lambda: torch.nn.Transformer(
99+
d_model=64,
100+
nhead=1,
101+
num_encoder_layers=1,
102+
num_decoder_layers=1,
103+
dtype=torch.float32,
104+
),
46105
),
47106
(torch.rand((10, 32, 64)), torch.rand((20, 32, 64))),
48107
),
@@ -78,9 +137,9 @@ def test_nn_Modules_FP(test_data):
78137
"test_data",
79138
test_parameters,
80139
xfails={
81-
"GRU": "RuntimeError: Node aten_linear_default with op <EdgeOpOverload: aten.linear[...]> was not decomposed or delegated.",
82-
"PReLU": "RuntimeError: mul(): functions with out=... arguments don't support automatic differentiation, but one of the arguments requires grad.",
83-
"Transformer": "AssertionError: Output 0 does not match reference output.",
140+
"GRUModule": "RuntimeError: Node aten_linear_default with op <EdgeOpOverload: aten.linear[...]> was not decomposed or delegated.",
141+
"PReLUModule": "RuntimeError: mul(): functions with out=... arguments don't support automatic differentiation, but one of the arguments requires grad.",
142+
"TransformerModule": "AssertionError: Output 0 does not match reference output.",
84143
},
85144
)
86145
def test_nn_Modules_INT(test_data):

backends/arm/test/models/test_resnet18.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ def test_resnet_u55_INT(per_channel_quantization):
7979

8080

8181
@pytest.mark.slow
82-
@pytest.mark.xfail(
83-
reason="For resnet18 for Ethos-U85, the SRAM memory footprint is very high. The compiler team is investigating."
84-
)
8582
@common.XfailIfNoCorstone320
8683
@common.parametrize("per_channel_quantization", quant_test_data)
8784
def test_resnet_u85_INT(per_channel_quantization):

backends/arm/test/models/test_torch_functions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ def test_torch_fns_FP(test_data):
128128
"Requires dynamic output shape.",
129129
"topk": "NotImplementedError: No registered serialization name for <class 'torch.return_types.topk'> found",
130130
"sort": "NotImplementedError: No registered serialization name for <class 'torch.return_types.sort'> found",
131-
"t": "MLETORCH-855: Issue with Quantization folding.",
132131
},
133132
strict=False,
134133
)

backends/arm/test/ops/test_conv2d.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,26 @@ def forward(self, x):
117117
return x
118118

119119

120-
conv2d_2x2_3x2x40x40_nobias = Conv2d(
120+
conv2d_2x2_3x2x14x14_nobias = Conv2d(
121121
in_channels=2,
122122
out_channels=3,
123123
kernel_size=(2, 2),
124124
stride=1,
125125
bias=False,
126126
padding=0,
127-
width=40,
128-
height=40,
129-
batches=3,
127+
width=14,
128+
height=14,
129+
batches=2,
130130
)
131131

132-
conv2d_3x3_1x3x256x256_st1 = Conv2d(
132+
conv2d_3x3_1x3x24x24_st1 = Conv2d(
133133
in_channels=3,
134134
out_channels=10,
135135
kernel_size=(3, 3),
136136
stride=1,
137137
padding=0,
138-
width=256,
139-
height=256,
138+
width=24,
139+
height=24,
140140
batches=1,
141141
)
142142

@@ -151,14 +151,14 @@ def forward(self, x):
151151
batches=1,
152152
)
153153

154-
conv2d_1x1_1x2x128x128_st1 = Conv2d(
154+
conv2d_1x1_1x2x16x16_st1 = Conv2d(
155155
in_channels=2,
156156
out_channels=1,
157157
kernel_size=(1, 1),
158158
stride=1,
159159
padding=0,
160-
width=128,
161-
height=128,
160+
width=16,
161+
height=16,
162162
batches=1,
163163
)
164164

@@ -173,25 +173,25 @@ def forward(self, x):
173173
batches=1,
174174
)
175175

176-
conv2d_5x5_3x2x128x128_st1 = Conv2d(
176+
conv2d_5x5_3x2x24x24_st1 = Conv2d(
177177
in_channels=2,
178178
out_channels=3,
179179
kernel_size=(5, 5),
180180
stride=1,
181181
padding=0,
182-
width=128,
183-
height=128,
184-
batches=3,
182+
width=24,
183+
height=24,
184+
batches=2,
185185
)
186186

187-
conv2d_3x3_1x3x224x224_st2_pd1 = Conv2d(
187+
conv2d_3x3_1x3x28x28_st2_pd1 = Conv2d(
188188
in_channels=3,
189189
out_channels=16,
190190
kernel_size=(3, 3),
191191
stride=2,
192192
padding=1,
193-
width=224,
194-
height=224,
193+
width=28,
194+
height=28,
195195
batches=1,
196196
)
197197

@@ -304,8 +304,8 @@ def forward(self, x):
304304

305305
two_conv2d_nobias = Conv2d(
306306
nbr_conv=2,
307-
width=256,
308-
height=256,
307+
width=32,
308+
height=32,
309309
in_channels=[3, 10],
310310
out_channels=[10, 15],
311311
kernel_size=[(5, 5), (5, 5)],
@@ -317,8 +317,8 @@ def forward(self, x):
317317

318318
two_conv2d = Conv2d(
319319
nbr_conv=2,
320-
width=256,
321-
height=256,
320+
width=32,
321+
height=32,
322322
in_channels=[3, 10],
323323
out_channels=[10, 15],
324324
kernel_size=[(5, 5), (5, 5)],
@@ -359,10 +359,10 @@ def forward(self, x):
359359
# Shenanigan to get a nicer output when test fails. With unittest it looks like:
360360
# FAIL: test_convolution_2d_tosa_INT_2_3x3_1x3x12x12_st2_pd1
361361
test_data_FP = {
362-
"2x2_3x2x40x40_nobias": lambda: conv2d_2x2_3x2x40x40_nobias,
363-
"3x3_1x3x256x256_st1": lambda: conv2d_3x3_1x3x256x256_st1,
362+
"2x2_3x2x14x14_nobias": lambda: conv2d_2x2_3x2x14x14_nobias,
363+
"3x3_1x3x24x24_st1": lambda: conv2d_3x3_1x3x24x24_st1,
364364
"3x3_1x3x12x12_st2_pd1": lambda: conv2d_3x3_1x3x12x12_st2_pd1,
365-
"1x1_1x2x128x128_st1": lambda: conv2d_1x1_1x2x128x128_st1,
365+
"1x1_1x2x16x16_st1": lambda: conv2d_1x1_1x2x16x16_st1,
366366
"2x2_1x1x14x13_st2_needs_adjust_pass": lambda: conv2d_2x2_1x1x14x13_st2,
367367
"5x5_1x3x14x15_st3_pd1_needs_adjust_pass": lambda: conv2d_5x5_1x3x14x15_st3_pd1,
368368
"7x7_1x3x16x16_st2_pd1_dl2_needs_adjust_pass": lambda: conv2d_7x7_1x3x16x16_st2_pd1_dl2,
@@ -373,8 +373,8 @@ def forward(self, x):
373373
"3x3_1x3x8x9_st3_pd0_dl1_needs_adjust_pass": lambda: conv2d_3x3_1x3x8x9_st3_pd0_dl1,
374374
"3x4_1x3x7x7_st3_pd0_dl1_needs_adjust_pass": lambda: conv2d_3x4_1x3x7x7_st3_pd0_dl1,
375375
"4x3_1x3x7x7_st3_pd0_dl1_needs_adjust_pass": lambda: conv2d_4x3_1x3x7x7_st3_pd0_dl1,
376-
"5x5_3x2x128x128_st1": lambda: conv2d_5x5_3x2x128x128_st1,
377-
"3x3_1x3x224x224_st2_pd1": lambda: conv2d_3x3_1x3x224x224_st2_pd1,
376+
"5x5_3x2x24x24_st1": lambda: conv2d_5x5_3x2x24x24_st1,
377+
"3x3_1x3x28x28_st2_pd1": lambda: conv2d_3x3_1x3x28x28_st2_pd1,
378378
"two_conv2d_nobias": lambda: two_conv2d_nobias,
379379
"two_conv2d": lambda: two_conv2d,
380380
"groups": lambda: conv2d_groups,

backends/arm/test/ops/test_conv_combos.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self):
4848
# 1. 1x1 CONV2d + ReLU6 (Pointwise)
4949
self.pointwise_conv2d = torch.nn.Conv2d(
5050
in_channels=16, out_channels=96, kernel_size=1, stride=1, groups=1
51-
) ## (1, 128, 81, 81)
51+
) ## Example output shape (1, 96, 33, 33)
5252
self.batch_norm2d_16 = torch.nn.BatchNorm2d(96, affine=False)
5353
self.relu6 = torch.nn.ReLU6()
5454

@@ -60,15 +60,15 @@ def __init__(self):
6060
padding=1,
6161
stride=1,
6262
groups=96,
63-
) ## (1, 128, H, W)
63+
) ## Example output shape (1, 96, H, W)
6464

6565
# 3. Linear 1x1 Conv2d
6666
self.pointwise_conv2d_linear = torch.nn.Conv2d(
6767
in_channels=96, out_channels=16, kernel_size=1, stride=1, groups=1
68-
) ## (1, 32, 81, 81)
68+
) ## Example output shape (1, 16, 33, 33)
6969

7070
def get_inputs(self) -> Tuple[torch.Tensor]:
71-
return (torch.randn(1, 16, 81, 81),)
71+
return (torch.randn(1, 16, 33, 33),)
7272

7373
def forward(self, x):
7474
input = x
@@ -106,7 +106,7 @@ def __init__(self):
106106
self.adaptive_avg_pool2d = torch.nn.AdaptiveAvgPool2d((1, 1))
107107

108108
def get_inputs(self) -> Tuple[torch.Tensor]:
109-
return (torch.randn(1, 3, 128, 128),)
109+
return (torch.randn(1, 3, 48, 48),)
110110

111111
def forward(self, x):
112112
x = self.conv2d(x)
@@ -145,7 +145,7 @@ def __init__(self, affine: bool):
145145
self.relu6 = torch.nn.ReLU6()
146146

147147
def get_inputs(self) -> Tuple[torch.Tensor]:
148-
return (torch.randn(1, 3, 256, 256),)
148+
return (torch.randn(1, 3, 64, 64),)
149149

150150
def forward(self, x):
151151
x = self.conv2d(x)
@@ -161,11 +161,11 @@ class ComboConvRelu6(torch.nn.Module):
161161
]
162162

163163
test_data_FP = {
164-
"combo_conv_relu_2_x_4d": lambda: (2 * torch.randn(1, 3, 256, 256),),
165-
"combo_conv_relu_0_5_x_4d": lambda: (0.5 * torch.randn(1, 3, 256, 256),),
166-
"combo_conv_relu_4d": lambda: (torch.randn(1, 3, 256, 256),),
167-
"combo_conv_relu_neg_0_5_x_4d": lambda: (-0.5 * torch.randn(1, 3, 256, 256),),
168-
"combo_conv_relu_neg_2_x_4d": lambda: (-2 * torch.randn(1, 3, 256, 256),),
164+
"combo_conv_relu_2_x_4d": lambda: (2 * torch.randn(1, 3, 64, 64),),
165+
"combo_conv_relu_0_5_x_4d": lambda: (0.5 * torch.randn(1, 3, 64, 64),),
166+
"combo_conv_relu_4d": lambda: (torch.randn(1, 3, 64, 64),),
167+
"combo_conv_relu_neg_0_5_x_4d": lambda: (-0.5 * torch.randn(1, 3, 64, 64),),
168+
"combo_conv_relu_neg_2_x_4d": lambda: (-2 * torch.randn(1, 3, 64, 64),),
169169
}
170170

171171
# Generate a new test set paired with per_channel_quant=True/False.
@@ -196,10 +196,10 @@ class ComboConvAvgPool2d(torch.nn.Module):
196196
]
197197

198198
test_data_FP = {
199-
"combo_conv_avgpool_20_x_4d": lambda: (20 * torch.randn(1, 3, 64, 32),),
200-
"combo_conv_avgpool_4d": lambda: (torch.randn(1, 3, 100, 200),),
201-
"combo_conv_avgpool_5_x_4d_randn": lambda: (5 * torch.randn(1, 3, 256, 256),),
202-
"combo_conv_avgpool_2_x_4d": lambda: (torch.rand(1, 3, 512, 128),),
199+
"combo_conv_avgpool_20_x_4d": lambda: (20 * torch.randn(1, 3, 48, 24),),
200+
"combo_conv_avgpool_4d": lambda: (torch.randn(1, 3, 60, 120),),
201+
"combo_conv_avgpool_5_x_4d_randn": lambda: (5 * torch.randn(1, 3, 64, 64),),
202+
"combo_conv_avgpool_2_x_4d": lambda: (torch.rand(1, 3, 96, 32),),
203203
}
204204

205205
# Generate a new test set paired with per_channel_quant=True/False.

backends/arm/test/ops/test_cosh.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ def test_cosh_u55_INT(test_data: Tuple):
7676
@common.parametrize(
7777
"test_data",
7878
test_data_suite,
79-
xfails={
80-
"ones_4D": "MLBEDSW-11046 - Incorrect output for TABLE followed by RESHAPE"
81-
},
8279
strict=False,
8380
)
8481
def test_cosh_u85_INT(test_data: Tuple):

0 commit comments

Comments
 (0)