Skip to content

Commit 0f6325d

Browse files
Merge branch 'main' into tosa_dialect_rescale
2 parents a3491bb + 50e5ec0 commit 0f6325d

18 files changed

+827
-173
lines changed

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_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):

backends/arm/test/ops/test_mean_dim.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,7 @@ def test_mean_dim_tosa_INT(test_data):
286286
pipeline.run()
287287

288288

289-
xfails = {
290-
"rank5_01234": "Rank 5 graph input currently not supported in EthosUBackend (passes since CHW are all averaged over so data order does not matter in this case)",
291-
"rank5_234": "Rank 5 graph input currently not supported in EthosUBackend (passes since CHW are all averaged over so data order does not matter in this case)",
292-
"rank5_12": "Rank 5 graph input currently not supported in EthosUBackend",
293-
"rank5_2": "Rank 5 graph input currently not supported in EthosUBackend",
294-
}
295-
296-
297-
@common.parametrize("test_data", MeanDim.test_data_suite, xfails=xfails, strict=False)
289+
@common.parametrize("test_data", MeanDim.test_data_suite)
298290
@common.XfailIfNoCorstone300
299291
def test_mean_dim_u55_INT(test_data):
300292
test_data, dim, keep_dim = test_data()
@@ -313,7 +305,7 @@ def test_mean_dim_u55_INT(test_data):
313305
pipeline.run()
314306

315307

316-
@common.parametrize("test_data", MeanDim.test_data_suite, xfails=xfails, strict=False)
308+
@common.parametrize("test_data", MeanDim.test_data_suite)
317309
@common.XfailIfNoCorstone320
318310
def test_mean_dim_u85_INT(test_data):
319311
test_data, dim, keep_dim = test_data()

backends/arm/test/ops/test_ne.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ def test_ne_scalar_u55_INT(test_module):
159159
@common.parametrize(
160160
"test_module",
161161
test_data_tensor,
162-
xfails={
163-
"ne_tensor_rank4_randn": "MLETORCH-517: Batch size > 1 not fully supported",
164-
},
165162
strict=False,
166163
)
167164
@common.XfailIfNoCorstone320
@@ -179,7 +176,6 @@ def test_ne_tensor_u85_INT(test_module):
179176
"test_module",
180177
test_data_scalar,
181178
xfails={
182-
"ne_scalar_rank4_randn": "MLETORCH-517: Batch size > 1 not fully supported",
183179
"ne_scalar_rank4_randn_1batch": "MLETORCH-847: Boolean ne result unstable on U85",
184180
},
185181
strict=False,

backends/arm/test/ops/test_pixel_shuffling.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
from typing import Tuple
88

9-
import pytest
10-
119
import torch
1210

1311
from executorch.backends.arm.constants import MAX_RANK
@@ -192,9 +190,12 @@ def test_pixel_unshuffle_u55_INT(test_data: input_t1):
192190
pipeline.run()
193191

194192

195-
@common.parametrize("test_data", PixelUnShuffle.test_data_generators)
193+
@common.parametrize(
194+
"test_data",
195+
PixelUnShuffle.test_data_generators,
196+
xfails={"rand_4d": "MLETORCH-1424: rand test fails"},
197+
)
196198
@common.XfailIfNoCorstone320
197-
@pytest.mark.xfail(reason="MLETORCH-1424: rand test fails")
198199
def test_pixel_unshuffle_u85_INT(test_data: input_t1):
199200
pipeline = EthosU85PipelineINT[input_t1](
200201
PixelUnShuffle(),
@@ -219,9 +220,12 @@ def test_pixel_shuffle_u55_INT(test_data: input_t1):
219220
pipeline.run()
220221

221222

222-
@common.parametrize("test_data", PixelShuffle.test_data_generators)
223+
@common.parametrize(
224+
"test_data",
225+
PixelShuffle.test_data_generators,
226+
xfails={"rand_4d": "MLETORCH-1424: rand test fails"},
227+
)
223228
@common.XfailIfNoCorstone320
224-
@pytest.mark.xfail(reason="MLETORCH-1424: rand test fails")
225229
def test_pixel_shuffle_u85_INT(test_data: input_t1):
226230
pipeline = EthosU85PipelineINT[input_t1](
227231
PixelShuffle(),

backends/arm/test/ops/test_pow.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ class Pow_TensorScalar(torch.nn.Module):
6262

6363
test_data = {
6464
# Test whole number exponents
65-
"exp_minus_three": lambda: (torch.randn((10, 5)), -3.0),
66-
"exp_minus_one": lambda: (torch.randn((42,)), -1.0),
67-
"exp_zero": lambda: (torch.randn((1, 2, 3, 7)), 0.0),
68-
"exp_one": lambda: (torch.randn((1, 4, 6, 2)), 1.0),
65+
"exp_minus_three": lambda: (torch.randn((10, 5)).relu() + 0.1, -3.0),
66+
"exp_minus_one": lambda: (torch.randn((42,)).relu() + 0.1, -1.0),
67+
"exp_zero": lambda: (torch.randn((1, 2, 3, 7)).relu(), 0.0),
68+
"exp_one": lambda: (torch.randn((1, 4, 6, 2)).relu(), 1.0),
6969
"exp_two": lambda: (torch.randn((1, 2, 3, 6)), 2.0),
7070
# Test decimal exponent (base must be non-negative)
7171
"non_neg_base_exp_pos_decimal": lambda: (
@@ -117,11 +117,7 @@ def test_pow_tensor_tensor_vgf_FP(test_data: Pow_TensorTensor.input_t):
117117

118118

119119
x_fail = {
120-
"exp_minus_three": "TOSA constraints: If x == 0 and y ⇐ 0, the result is undefined.",
121-
"exp_minus_one": "TOSA constraints: If x == 0 and y ⇐ 0, the result is undefined.",
122-
"exp_zero": "TOSA constraints: If x == 0 and y ⇐ 0, the result is undefined.",
123-
"exp_one": "TOSA constraints: If x == 0 and y ⇐ 0, the result is undefined.",
124-
"exp_two": "TOSA constraints: If x == 0 and y ⇐ 0, the result is undefined.",
120+
"exp_two": "TOSA constraints: If x <0 .",
125121
"non_neg_base_exp_pos_decimal": "TOSA constraints: If x == 0 and y ⇐ 0, the result is undefined.",
126122
}
127123

@@ -138,7 +134,7 @@ def test_pow_tensor_scalar_tosa_FP(test_data: Pow_TensorScalar.input_t):
138134
pipeline.run()
139135

140136

141-
@common.parametrize("test_data", Pow_TensorScalar.test_data, x_fail, strict=False)
137+
@common.parametrize("test_data", Pow_TensorScalar.test_data, strict=False)
142138
def test_pow_tensor_scalar_tosa_INT(test_data: Pow_TensorScalar.input_t):
143139
base, exp = test_data()
144140
pipeline = TosaPipelineINT[Pow_TensorScalar.input_t](

backends/arm/test/ops/test_unflatten.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,7 @@ def test_unflatten_int_tosa_INT(test_data: test_data_t):
5757
pipeline.run()
5858

5959

60-
xfails = {
61-
"rand_3d_batch3": "Batch size > 1 currently not supported for FVP tests",
62-
"randn_4d_dim1": "Batch size > 1 currently not supported for FVP tests",
63-
}
64-
65-
66-
@common.parametrize("test_data", Unflatten.test_data, xfails=xfails, strict=False)
60+
@common.parametrize("test_data", Unflatten.test_data, strict=False)
6761
@common.XfailIfNoCorstone300
6862
def test_unflatten_int_u55_INT(test_data: test_data_t):
6963
module, inputs = test_data()
@@ -75,7 +69,7 @@ def test_unflatten_int_u55_INT(test_data: test_data_t):
7569
pipeline.run()
7670

7771

78-
@common.parametrize("test_data", Unflatten.test_data, xfails=xfails, strict=False)
72+
@common.parametrize("test_data", Unflatten.test_data, strict=False)
7973
@common.XfailIfNoCorstone320
8074
def test_unflatten_int_u85_INT(test_data: test_data_t):
8175
module, inputs = test_data()

backends/cadence/aot/ops_registrations.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,10 @@ def _validate_ref_impl_exists() -> None:
5353
# 1. be removed
5454
# 2. have a reference implementation added to ref_implementations.py
5555
_WARN_ONLY = {
56-
"cadence::quantized_add", # We should only support per_tensor variant, should remove
5756
"cadence::_softmax_f32_f32",
58-
"cadence::requantize", # We should only support per_tensor variant, should remove
5957
"cadence::quantized_softmax.per_tensor",
60-
"cadence::quantized_conv2d_nchw", # We should only support per_tensor variant, should remove
61-
"cadence::quantized_relu", # We should only support per_tensor variant, should remove
62-
"cadence::quantized_conv2d_nhwc", # We should only support per_tensor variant, should remove
6358
"cadence::quantized_softmax",
6459
"cadence::quantized_w8a32_gru",
65-
"cadence::quantized_layer_norm", # We should only support per_tensor variant, should remove
6660
}
6761

6862
ref_impls = get_registered_ref_implementations()

0 commit comments

Comments
 (0)