Skip to content

Commit 9078b49

Browse files
Arm backend: Add VGF unit tests to operators (Part 1) (#13032)
- Included aten.abs to aten.full Signed-off-by: Yufeng Shi <[email protected]>
1 parent a42c8f4 commit 9078b49

39 files changed

+1691
-11
lines changed

backends/arm/test/ops/test_abs.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
EthosU85PipelineINT,
1616
TosaPipelineFP,
1717
TosaPipelineINT,
18+
VgfPipeline,
1819
)
1920

2021
aten_op = "torch.ops.aten.abs.default"
@@ -66,3 +67,25 @@ def test_abs_u85_INT(test_data: torch.Tensor):
6667
Abs(), test_data(), aten_op, exir_op, run_on_fvp=True
6768
)
6869
pipeline.run()
70+
71+
72+
@common.parametrize("test_data", Abs.test_parameters)
73+
@common.SkipIfNoModelConverter
74+
def test_abs_vgf_FP(test_data: input_t1):
75+
pipeline = VgfPipeline[input_t1](
76+
Abs(), test_data(), aten_op, exir_op, tosa_version="TOSA-1.0+FP"
77+
)
78+
pipeline.run()
79+
80+
81+
@common.parametrize("test_data", Abs.test_parameters)
82+
@common.SkipIfNoModelConverter
83+
def test_abs_vgf_INT(test_data: input_t1):
84+
pipeline = VgfPipeline[input_t1](
85+
Abs(),
86+
test_data(),
87+
aten_op,
88+
exir_op,
89+
tosa_version="TOSA-1.0+INT",
90+
)
91+
pipeline.run()

backends/arm/test/ops/test_acosh.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
EthosU85PipelineINT,
1515
TosaPipelineFP,
1616
TosaPipelineINT,
17+
VgfPipeline,
1718
)
1819

1920
input_t = Tuple[torch.Tensor] # Input x
@@ -112,3 +113,27 @@ def test_acosh_u85_INT_xfail(test_data: Tuple):
112113
run_on_fvp=False,
113114
)
114115
pipeline.run()
116+
117+
118+
@common.parametrize("test_data", test_data_suite)
119+
@common.SkipIfNoModelConverter
120+
def test_acosh_vgf_FP(test_data: Tuple):
121+
pipeline = VgfPipeline[input_t](
122+
Acosh(),
123+
(test_data(),),
124+
aten_op,
125+
tosa_version="TOSA-1.0+FP",
126+
)
127+
pipeline.run()
128+
129+
130+
@common.parametrize("test_data", test_data_suite)
131+
@common.SkipIfNoModelConverter
132+
def test_acosh_vgf_INT(test_data: Tuple):
133+
pipeline = VgfPipeline[input_t](
134+
Acosh(),
135+
(test_data(),),
136+
aten_op,
137+
tosa_version="TOSA-1.0+INT",
138+
)
139+
pipeline.run()

backends/arm/test/ops/test_adaptive_avg_pool2d.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
EthosU85PipelineINT,
1515
TosaPipelineFP,
1616
TosaPipelineINT,
17+
VgfPipeline,
1718
)
1819

1920
exir_op = "executorch_exir_dialects_edge__ops_aten_avg_pool2d_default"
@@ -161,3 +162,31 @@ def test_adaptive_avg_pool2d_u85_INT(test_module):
161162
exir_ops=exir_op,
162163
)
163164
pipeline.run()
165+
166+
167+
@common.parametrize("test_module", test_modules)
168+
@common.SkipIfNoModelConverter
169+
def test_adaptive_avg_pool2d_vgf_FP(test_module):
170+
model, input_tensor = test_module()
171+
pipeline = VgfPipeline[input_t](
172+
model,
173+
input_tensor,
174+
[],
175+
exir_op,
176+
tosa_version="TOSA-1.0+FP",
177+
)
178+
pipeline.run()
179+
180+
181+
@common.parametrize("test_module", test_modules)
182+
@common.SkipIfNoModelConverter
183+
def test_adaptive_avg_pool2d_vgf_INT(test_module):
184+
model, input_tensor = test_module()
185+
pipeline = VgfPipeline[input_t](
186+
model,
187+
input_tensor,
188+
[],
189+
exir_op,
190+
tosa_version="TOSA-1.0+INT",
191+
)
192+
pipeline.run()

backends/arm/test/ops/test_addmm.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
EthosU85PipelineINT,
1414
TosaPipelineFP,
1515
TosaPipelineINT,
16+
VgfPipeline,
1617
)
1718

1819
aten_op = "torch.ops.aten.addmm.default"
@@ -155,3 +156,29 @@ def test_addmm_u85_INT(test_data: Tuple):
155156
exir_ops=exir_op,
156157
)
157158
pipeline.run()
159+
160+
161+
@common.parametrize("test_data", test_data_suite)
162+
@common.SkipIfNoModelConverter
163+
def test_addmm_vgf_FP(test_data: input_t1):
164+
pipeline = VgfPipeline[input_t1](
165+
Addmm(),
166+
(*test_data,),
167+
aten_op=aten_op,
168+
exir_op=exir_op,
169+
tosa_version="TOSA-1.0+FP",
170+
)
171+
pipeline.run()
172+
173+
174+
@common.parametrize("test_data", test_data_suite)
175+
@common.SkipIfNoModelConverter
176+
def test_addmm_vgf_INT(test_data: input_t1):
177+
pipeline = VgfPipeline[input_t1](
178+
Addmm(),
179+
(*test_data,),
180+
aten_op=[],
181+
exir_op=exir_op,
182+
tosa_version="TOSA-1.0+INT",
183+
)
184+
pipeline.run()

backends/arm/test/ops/test_alias_copy.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
EthosU85PipelineINT,
1313
TosaPipelineFP,
1414
TosaPipelineINT,
15+
VgfPipeline,
1516
)
1617

1718
input_t1 = Tuple[torch.Tensor]
@@ -83,3 +84,29 @@ def test_alias_u85_INT(test_data: input_t1):
8384
AliasCopy.aten_op,
8485
AliasCopy.exir_op,
8586
).run()
87+
88+
89+
@common.parametrize("test_data", AliasCopy.test_data)
90+
@common.SkipIfNoModelConverter
91+
def test_alias_vgf_FP(test_data: input_t1):
92+
pipeline = VgfPipeline[input_t1](
93+
AliasCopy(),
94+
test_data(),
95+
AliasCopy.aten_op,
96+
AliasCopy.exir_op,
97+
tosa_version="TOSA-1.0+FP",
98+
)
99+
pipeline.run()
100+
101+
102+
@common.parametrize("test_data", AliasCopy.test_data)
103+
@common.SkipIfNoModelConverter
104+
def test_alias_vgf_INT(test_data: input_t1):
105+
pipeline = VgfPipeline[input_t1](
106+
AliasCopy(),
107+
test_data(),
108+
AliasCopy.aten_op,
109+
AliasCopy.exir_op,
110+
tosa_version="TOSA-1.0+INT",
111+
)
112+
pipeline.run()

backends/arm/test/ops/test_amax.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
OpNotSupportedPipeline,
1515
TosaPipelineFP,
1616
TosaPipelineINT,
17+
VgfPipeline,
1718
)
1819

1920

@@ -138,3 +139,57 @@ def test_max_dim_tosa_FP_not_delegated():
138139
data, dim = Max.test_data["rank_4_dim_3"]()
139140
pipeline = OpNotSupportedPipeline[Max.input_t](MaxWithIndex(dim), data, {})
140141
pipeline.run()
142+
143+
144+
@common.parametrize("test_data", Amax.test_data)
145+
@common.SkipIfNoModelConverter
146+
def test_amax_vgf_FP(test_data: Amax.input_t):
147+
data, dim, keep_dims = test_data()
148+
module = Amax(dim, keep_dims)
149+
pipeline = VgfPipeline[Amax.input_t](
150+
module,
151+
data,
152+
Amax.aten_op,
153+
tosa_version="TOSA-1.0+FP",
154+
)
155+
pipeline.run()
156+
157+
158+
@common.parametrize("test_data", Amax.test_data)
159+
@common.SkipIfNoModelConverter
160+
def test_amax_vgf_INT(test_data: Amax.input_t):
161+
data, dim, keep_dims = test_data()
162+
module = Amax(dim, keep_dims)
163+
pipeline = VgfPipeline[Amax.input_t](
164+
module,
165+
data,
166+
Amax.aten_op,
167+
tosa_version="TOSA-1.0+INT",
168+
)
169+
pipeline.run()
170+
171+
172+
@common.parametrize("test_data", Max.test_data)
173+
@common.SkipIfNoModelConverter
174+
def test_max_dim_vgf_FP_to_amax(test_data: Max.input_t):
175+
data, dim = test_data()
176+
pipeline = VgfPipeline[Max.input_t](
177+
Max(dim),
178+
data,
179+
"torch.ops.aten.max",
180+
tosa_version="TOSA-1.0+FP",
181+
)
182+
pipeline.run()
183+
184+
185+
@common.parametrize("test_data", Max.test_data)
186+
@common.SkipIfNoModelConverter
187+
def test_max_dim_vgf_INT_to_amax(test_data: Max.input_t):
188+
data, dim = test_data()
189+
pipeline = VgfPipeline[Max.input_t](
190+
Max(dim),
191+
data,
192+
"torch.ops.aten.amax",
193+
tosa_version="TOSA-1.0+INT",
194+
)
195+
pipeline.run()

backends/arm/test/ops/test_amin.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
OpNotSupportedPipeline,
1616
TosaPipelineFP,
1717
TosaPipelineINT,
18+
VgfPipeline,
1819
)
1920

2021

@@ -150,3 +151,52 @@ def test_min_dim_tosa_FP_not_delegated():
150151
data, dim = Min.test_data["rank_4_dim_3"]()
151152
pipeline = OpNotSupportedPipeline[Min.input_t](MinWithIndex(dim), data, {})
152153
pipeline.run()
154+
155+
156+
@common.parametrize("test_data", Amin.test_data)
157+
@common.SkipIfNoModelConverter
158+
def test_amin_vgf_FP(test_data: Amin.input_t):
159+
data, dim, keep_dims = test_data()
160+
pipeline = VgfPipeline[Amin.input_t](
161+
Amin(dim, keep_dims), data, Amin.aten_op, tosa_version="TOSA-1.0+FP"
162+
)
163+
pipeline.run()
164+
165+
166+
@common.parametrize("test_data", Amin.test_data)
167+
@common.SkipIfNoModelConverter
168+
def test_amin_vgf_INT(test_data: Amin.input_t):
169+
data, dim, keep_dims = test_data()
170+
pipeline = VgfPipeline[Amin.input_t](
171+
Amin(dim, keep_dims),
172+
data,
173+
Amin.aten_op,
174+
tosa_version="TOSA-1.0+INT",
175+
)
176+
pipeline.run()
177+
178+
179+
@common.parametrize("test_data", Min.test_data)
180+
@common.SkipIfNoModelConverter
181+
def test_min_dim_vgf_FP_to_amin(test_data: Min.input_t):
182+
data, dim = test_data()
183+
pipeline = VgfPipeline[Min.input_t](
184+
Min(dim),
185+
data,
186+
"torch.ops.aten.min",
187+
tosa_version="TOSA-1.0+FP",
188+
)
189+
pipeline.run()
190+
191+
192+
@common.parametrize("test_data", Min.test_data)
193+
@common.SkipIfNoModelConverter
194+
def test_min_dim_vgf_INT_to_amin(test_data: Min.input_t):
195+
data, dim = test_data()
196+
pipeline = VgfPipeline[Min.input_t](
197+
Min(dim),
198+
data,
199+
"torch.ops.aten.amin",
200+
tosa_version="TOSA-1.0+INT",
201+
)
202+
pipeline.run()

backends/arm/test/ops/test_any.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
OpNotSupportedPipeline,
1414
TosaPipelineFP,
1515
TosaPipelineINT,
16+
VgfPipeline,
1617
)
1718

1819

@@ -184,3 +185,33 @@ def test_any_u85_INT(test_data: input_t1):
184185
pipeline.pop_stage("quantize")
185186
pipeline.pop_stage("check.quant_nodes")
186187
pipeline.run()
188+
189+
190+
@common.parametrize("test_data", test_data)
191+
@common.SkipIfNoModelConverter
192+
def test_any_vgf_FP(test_data: input_t1):
193+
op, data_fn = test_data()
194+
pipeline = VgfPipeline[input_t1](
195+
op,
196+
data_fn(),
197+
op.aten_op,
198+
op.exir_op,
199+
tosa_version="TOSA-1.0+FP",
200+
)
201+
pipeline.run()
202+
203+
204+
@common.parametrize("test_data", test_data)
205+
@common.SkipIfNoModelConverter
206+
def test_any_vgf_INT(test_data: input_t1):
207+
op, data_fn = test_data()
208+
pipeline = VgfPipeline[input_t1](
209+
op,
210+
data_fn(),
211+
op.aten_op,
212+
op.exir_op,
213+
tosa_version="TOSA-1.0+INT",
214+
)
215+
pipeline.pop_stage("quantize")
216+
pipeline.pop_stage("check.quant_nodes")
217+
pipeline.run()

0 commit comments

Comments
 (0)