Skip to content

Commit 5331790

Browse files
committed
Arm backend: Refactor test infra to enable TOSA V1.0 testing (part 2)
Signed-off-by: Saoirse Stewart <[email protected]> Change-Id: Iccc30f84626a6d32dfe92fbf41ed500e2249bb4d
1 parent eb26096 commit 5331790

25 files changed

+1380
-2035
lines changed

backends/arm/scripts/parse_test_names.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
from executorch.exir.dialects.edge.spec.utils import SAMPLE_INPUT
66

77
# Add edge ops which we lower but which are not included in exir/dialects/edge/edge.yaml here.
8-
CUSTOM_EDGE_OPS = ["linspace.default", "eye.default"]
8+
CUSTOM_EDGE_OPS = [
9+
"linspace.default",
10+
"eye.default",
11+
"hardsigmoid.default",
12+
"hardswish.default",
13+
"linear.default",
14+
"maximum.default",
15+
"adaptive_avg_pool2d.default",
16+
]
917
ALL_EDGE_OPS = SAMPLE_INPUT.keys() | CUSTOM_EDGE_OPS
1018

1119
# Add all targets and TOSA profiles we support here.

backends/arm/test/ops/test_ge.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,25 @@ def get_inputs(self):
6262
op_ge_scalar_rank4_randn = GreaterEqual(torch.randn(3, 2, 2, 2), 0.3)
6363

6464
test_data_tensor = {
65-
"ge_tensor_rank1_ones": op_ge_tensor_rank1_ones,
66-
"ge_tensor_rank2_rand": op_ge_tensor_rank2_rand,
67-
"ge_tensor_rank3_randn": op_ge_tensor_rank3_randn,
68-
"ge_tensor_rank4_randn": op_ge_tensor_rank4_randn,
65+
"ge_tensor_rank1_ones": lambda: op_ge_tensor_rank1_ones,
66+
"ge_tensor_rank2_rand": lambda: op_ge_tensor_rank2_rand,
67+
"ge_tensor_rank3_randn": lambda: op_ge_tensor_rank3_randn,
68+
"ge_tensor_rank4_randn": lambda: op_ge_tensor_rank4_randn,
6969
}
7070

7171
test_data_scalar = {
72-
"ge_scalar_rank1_ones": op_ge_scalar_rank1_ones,
73-
"ge_scalar_rank2_rand": op_ge_scalar_rank2_rand,
74-
"ge_scalar_rank3_randn": op_ge_scalar_rank3_randn,
75-
"ge_scalar_rank4_randn": op_ge_scalar_rank4_randn,
72+
"ge_scalar_rank1_ones": lambda: op_ge_scalar_rank1_ones,
73+
"ge_scalar_rank2_rand": lambda: op_ge_scalar_rank2_rand,
74+
"ge_scalar_rank3_randn": lambda: op_ge_scalar_rank3_randn,
75+
"ge_scalar_rank4_randn": lambda: op_ge_scalar_rank4_randn,
7676
}
7777

7878

7979
@common.parametrize("test_module", test_data_tensor)
8080
def test_ge_tensor_tosa_MI(test_module):
8181
pipeline = TosaPipelineMI[input_t](
82-
test_module,
83-
test_module.get_inputs(),
82+
test_module(),
83+
test_module().get_inputs(),
8484
GreaterEqual.aten_op_tensor,
8585
GreaterEqual.exir_op,
8686
)
@@ -90,8 +90,8 @@ def test_ge_tensor_tosa_MI(test_module):
9090
@common.parametrize("test_module", test_data_scalar)
9191
def test_ge_scalar_tosa_MI(test_module):
9292
pipeline = TosaPipelineMI[input_t](
93-
test_module,
94-
test_module.get_inputs(),
93+
test_module(),
94+
test_module().get_inputs(),
9595
GreaterEqual.aten_op_scalar,
9696
GreaterEqual.exir_op,
9797
)
@@ -101,8 +101,8 @@ def test_ge_scalar_tosa_MI(test_module):
101101
@common.parametrize("test_module", test_data_tensor)
102102
def test_ge_tensor_tosa_BI(test_module):
103103
pipeline = TosaPipelineBI[input_t](
104-
test_module,
105-
test_module.get_inputs(),
104+
test_module(),
105+
test_module().get_inputs(),
106106
GreaterEqual.aten_op_tensor,
107107
GreaterEqual.exir_op,
108108
)
@@ -112,8 +112,8 @@ def test_ge_tensor_tosa_BI(test_module):
112112
@common.parametrize("test_module", test_data_scalar)
113113
def test_ge_scalar_tosa_BI(test_module):
114114
pipeline = TosaPipelineBI[input_t](
115-
test_module,
116-
test_module.get_inputs(),
115+
test_module(),
116+
test_module().get_inputs(),
117117
GreaterEqual.aten_op_tensor,
118118
GreaterEqual.exir_op,
119119
)
@@ -125,8 +125,8 @@ def test_ge_scalar_tosa_BI(test_module):
125125
def test_ge_tensor_u55_BI(test_module):
126126
# GREATER_EQUAL is not supported on U55.
127127
pipeline = OpNotSupportedPipeline[input_t](
128-
test_module,
129-
test_module.get_inputs(),
128+
test_module(),
129+
test_module().get_inputs(),
130130
"TOSA-0.80+BI+u55",
131131
{GreaterEqual.exir_op: 1},
132132
)
@@ -138,8 +138,8 @@ def test_ge_tensor_u55_BI(test_module):
138138
def test_ge_scalar_u55_BI(test_module):
139139
# GREATER_EQUAL is not supported on U55.
140140
pipeline = OpNotSupportedPipeline[input_t](
141-
test_module,
142-
test_module.get_inputs(),
141+
test_module(),
142+
test_module().get_inputs(),
143143
"TOSA-0.80+BI+u55",
144144
{GreaterEqual.exir_op: 1},
145145
n_expected_delegates=1,
@@ -155,8 +155,8 @@ def test_ge_scalar_u55_BI(test_module):
155155
@common.XfailIfNoCorstone320
156156
def test_ge_tensor_u85_BI(test_module):
157157
pipeline = EthosU85PipelineBI[input_t](
158-
test_module,
159-
test_module.get_inputs(),
158+
test_module(),
159+
test_module().get_inputs(),
160160
GreaterEqual.aten_op_tensor,
161161
GreaterEqual.exir_op,
162162
run_on_fvp=True,
@@ -172,8 +172,8 @@ def test_ge_tensor_u85_BI(test_module):
172172
@common.XfailIfNoCorstone320
173173
def test_ge_scalar_u85_BI(test_module):
174174
pipeline = EthosU85PipelineBI[input_t](
175-
test_module,
176-
test_module.get_inputs(),
175+
test_module(),
176+
test_module().get_inputs(),
177177
GreaterEqual.aten_op_tensor,
178178
GreaterEqual.exir_op,
179179
run_on_fvp=True,

backends/arm/test/ops/test_gelu.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,51 +22,51 @@ class Gelu(torch.nn.Module):
2222
exir_op = "executorch_exir_dialects_edge__ops_aten_gelu_default"
2323

2424
test_data: dict[str, Tuple[str, input_t1]] = {
25-
"zeros_none": (
25+
"zeros_none": lambda: (
2626
"none",
2727
torch.zeros(1, 10, 10, 10),
2828
),
29-
"ones_none": (
29+
"ones_none": lambda: (
3030
"none",
3131
torch.ones(10, 10, 10),
3232
),
33-
"rand_none": (
33+
"rand_none": lambda: (
3434
"none",
3535
(torch.rand(10, 10) - 0.5),
3636
),
37-
"randn_pos_none": (
37+
"randn_pos_none": lambda: (
3838
"none",
3939
(torch.randn(1, 4, 4, 4) + 10),
4040
),
41-
"randn_neg_none": (
41+
"randn_neg_none": lambda: (
4242
"none",
4343
(torch.randn(1, 4, 4, 4) - 10),
4444
),
45-
"ramp_none": (
45+
"ramp_none": lambda: (
4646
"none",
4747
torch.arange(-16, 16, 0.2),
4848
),
49-
"zeros_tanh": (
49+
"zeros_tanh": lambda: (
5050
"tanh",
5151
torch.zeros(1, 10, 10, 10),
5252
),
53-
"ones_tanh": (
53+
"ones_tanh": lambda: (
5454
"tanh",
5555
torch.ones(10, 10, 10),
5656
),
57-
"rand_tanh": (
57+
"rand_tanh": lambda: (
5858
"tanh",
5959
(torch.rand(10, 10) - 0.5),
6060
),
61-
"randn_pos_tanh": (
61+
"randn_pos_tanh": lambda: (
6262
"tanh",
6363
(torch.randn(1, 4, 4, 4) + 10),
6464
),
65-
"randn_neg_tanh": (
65+
"randn_neg_tanh": lambda: (
6666
"tanh",
6767
(torch.randn(1, 4, 4, 4) - 10),
6868
),
69-
"ramp_tanh": (
69+
"ramp_tanh": lambda: (
7070
"tanh",
7171
torch.arange(-16, 16, 0.2),
7272
),
@@ -82,10 +82,10 @@ def forward(self, x: torch.Tensor):
8282

8383
@common.parametrize("test_data", Gelu.test_data)
8484
def test_gelu_tosa_MI(test_data: input_t1):
85-
approximate = test_data[0]
85+
approximate, test_data = test_data()
8686
TosaPipelineMI[input_t1](
8787
Gelu(approximate),
88-
(test_data[1],),
88+
(test_data,),
8989
Gelu.aten_op,
9090
Gelu.exir_op,
9191
use_to_edge_transform_and_lower=False,
@@ -94,32 +94,34 @@ def test_gelu_tosa_MI(test_data: input_t1):
9494

9595
@common.parametrize("test_data", Gelu.test_data)
9696
def test_gelu_tosa_BI(test_data: input_t1):
97-
approximate = test_data[0]
97+
approximate, test_data = test_data()
9898
TosaPipelineBI[input_t1](
9999
Gelu(approximate),
100-
(test_data[1],),
100+
(test_data,),
101101
Gelu.aten_op,
102102
Gelu.exir_op,
103103
).run()
104104

105105

106106
@common.parametrize("test_data", Gelu.test_data)
107+
@common.XfailIfNoCorstone300
107108
def test_gelu_u55_BI(test_data: input_t1):
108-
approximate = test_data[0]
109+
approximate, test_data = test_data()
109110
EthosU55PipelineBI[input_t1](
110111
Gelu(approximate),
111-
(test_data[1],),
112+
(test_data,),
112113
Gelu.aten_op,
113114
Gelu.exir_op,
114115
).run()
115116

116117

117118
@common.parametrize("test_data", Gelu.test_data)
119+
@common.XfailIfNoCorstone320
118120
def test_gelu_u85_BI(test_data: input_t1):
119-
approximate = test_data[0]
121+
approximate, test_data = test_data()
120122
EthosU85PipelineBI[input_t1](
121123
Gelu(approximate),
122-
(test_data[1],),
124+
(test_data,),
123125
Gelu.aten_op,
124126
Gelu.exir_op,
125127
).run()

backends/arm/test/ops/test_gt.py

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,48 +63,60 @@ def get_inputs(self):
6363
op_gt_scalar_rank4_randn = Greater(torch.randn(3, 2, 2, 2), 0.3)
6464

6565
test_data_tensor = {
66-
"gt_tensor_rank1_ones": op_gt_tensor_rank1_ones,
67-
"gt_tensor_rank2_rand": op_gt_tensor_rank2_rand,
68-
"gt_tensor_rank3_randn": op_gt_tensor_rank3_randn,
69-
"gt_tensor_rank4_randn": op_gt_tensor_rank4_randn,
66+
"gt_tensor_rank1_ones": lambda: op_gt_tensor_rank1_ones,
67+
"gt_tensor_rank2_rand": lambda: op_gt_tensor_rank2_rand,
68+
"gt_tensor_rank3_randn": lambda: op_gt_tensor_rank3_randn,
69+
"gt_tensor_rank4_randn": lambda: op_gt_tensor_rank4_randn,
7070
}
7171

7272
test_data_scalar = {
73-
"gt_scalar_rank1_ones": op_gt_scalar_rank1_ones,
74-
"gt_scalar_rank2_rand": op_gt_scalar_rank2_rand,
75-
"gt_scalar_rank3_randn": op_gt_scalar_rank3_randn,
76-
"gt_scalar_rank4_randn": op_gt_scalar_rank4_randn,
73+
"gt_scalar_rank1_ones": lambda: op_gt_scalar_rank1_ones,
74+
"gt_scalar_rank2_rand": lambda: op_gt_scalar_rank2_rand,
75+
"gt_scalar_rank3_randn": lambda: op_gt_scalar_rank3_randn,
76+
"gt_scalar_rank4_randn": lambda: op_gt_scalar_rank4_randn,
7777
}
7878

7979

8080
@common.parametrize("test_module", test_data_tensor)
8181
def test_gt_tensor_tosa_MI(test_module):
8282
pipeline = TosaPipelineMI[input_t](
83-
test_module, test_module.get_inputs(), Greater.aten_op_tensor, Greater.exir_op
83+
test_module(),
84+
test_module().get_inputs(),
85+
Greater.aten_op_tensor,
86+
Greater.exir_op,
8487
)
8588
pipeline.run()
8689

8790

8891
@common.parametrize("test_module", test_data_scalar)
8992
def test_gt_scalar_tosa_MI(test_module):
9093
pipeline = TosaPipelineMI[input_t](
91-
test_module, test_module.get_inputs(), Greater.aten_op_scalar, Greater.exir_op
94+
test_module(),
95+
test_module().get_inputs(),
96+
Greater.aten_op_scalar,
97+
Greater.exir_op,
9298
)
9399
pipeline.run()
94100

95101

96102
@common.parametrize("test_module", test_data_tensor)
97103
def test_gt_tensor_tosa_BI(test_module):
98104
pipeline = TosaPipelineBI[input_t](
99-
test_module, test_module.get_inputs(), Greater.aten_op_tensor, Greater.exir_op
105+
test_module(),
106+
test_module().get_inputs(),
107+
Greater.aten_op_tensor,
108+
Greater.exir_op,
100109
)
101110
pipeline.run()
102111

103112

104113
@common.parametrize("test_module", test_data_scalar)
105114
def test_gt_scalar_tosa_BI(test_module):
106115
pipeline = TosaPipelineBI[input_t](
107-
test_module, test_module.get_inputs(), Greater.aten_op_tensor, Greater.exir_op
116+
test_module(),
117+
test_module().get_inputs(),
118+
Greater.aten_op_tensor,
119+
Greater.exir_op,
108120
)
109121
pipeline.run()
110122

@@ -114,8 +126,8 @@ def test_gt_scalar_tosa_BI(test_module):
114126
def test_gt_tensor_u55_BI(test_module):
115127
# Greater is not supported on U55.
116128
pipeline = OpNotSupportedPipeline[input_t](
117-
test_module,
118-
test_module.get_inputs(),
129+
test_module(),
130+
test_module().get_inputs(),
119131
"TOSA-0.80+BI+u55",
120132
{Greater.exir_op: 1},
121133
)
@@ -127,8 +139,8 @@ def test_gt_tensor_u55_BI(test_module):
127139
def test_gt_scalar_u55_BI(test_module):
128140
# Greater is not supported on U55.
129141
pipeline = OpNotSupportedPipeline[input_t](
130-
test_module,
131-
test_module.get_inputs(),
142+
test_module(),
143+
test_module().get_inputs(),
132144
"TOSA-0.80+BI+u55",
133145
{Greater.exir_op: 1},
134146
n_expected_delegates=1,
@@ -146,8 +158,8 @@ def test_gt_scalar_u55_BI(test_module):
146158
@common.XfailIfNoCorstone320
147159
def test_gt_tensor_u85_BI(test_module):
148160
pipeline = EthosU85PipelineBI[input_t](
149-
test_module,
150-
test_module.get_inputs(),
161+
test_module(),
162+
test_module().get_inputs(),
151163
Greater.aten_op_tensor,
152164
Greater.exir_op,
153165
run_on_fvp=True,
@@ -165,8 +177,8 @@ def test_gt_tensor_u85_BI(test_module):
165177
@common.XfailIfNoCorstone320
166178
def test_gt_scalar_u85_BI(test_module):
167179
pipeline = EthosU85PipelineBI[input_t](
168-
test_module,
169-
test_module.get_inputs(),
180+
test_module(),
181+
test_module().get_inputs(),
170182
Greater.aten_op_tensor,
171183
Greater.exir_op,
172184
run_on_fvp=True,

0 commit comments

Comments
 (0)