Skip to content

Commit 0129dc9

Browse files
authored
Arm backend: Add more tests to VGF (#21454)
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani Signed-off-by: Elena Zhelezina <elena.zhelezina@arm.com>
1 parent 4a740f5 commit 0129dc9

3 files changed

Lines changed: 85 additions & 1 deletion

File tree

backends/arm/test/ops/test_argmax.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55

66
from typing import Tuple
77

8+
import pytest
89
import torch
910
from executorch.backends.arm.test import common
1011
from executorch.backends.arm.test.tester.test_pipeline import (
1112
OpNotSupportedPipeline,
1213
TosaPipelineFP,
1314
TosaPipelineINT,
15+
VgfPipeline,
1416
)
1517

1618
aten_op = "torch.ops.aten.argmax.default"
@@ -131,3 +133,49 @@ def test_argmax_tosa_INT(test_data: Tuple[input_t, int]):
131133
)
132134
pipeline.count_tosa_ops({"ARGMAX": 1})
133135
pipeline.run()
136+
137+
138+
@pytest.mark.xfail(
139+
reason=(
140+
"VGF ARGMAX output contract mismatch: MLTORCH-2372"
141+
"ExecuTorch output is allocated as int64 while TOSA/VGF emits int32."
142+
),
143+
strict=True,
144+
)
145+
@common.parametrize(
146+
"test_data",
147+
Argmax.test_data | Argmax.test_data_fp16 | Argmax.test_data_bf16,
148+
)
149+
@common.SkipIfNoModelConverter
150+
def test_argmax_vgf_no_quant(test_data: Tuple[input_t, int]):
151+
data, dim = test_data()
152+
pipeline = VgfPipeline[input_t](
153+
Argmax(dim),
154+
data,
155+
aten_op,
156+
exir_op,
157+
quantize=False,
158+
tosa_extensions=["bf16"],
159+
)
160+
pipeline.run()
161+
162+
163+
@pytest.mark.xfail(
164+
reason=(
165+
"VGF ARGMAX output contract mismatch: MLTORCH-2372"
166+
"ExecuTorch output is allocated as int64 while TOSA/VGF emits int32."
167+
),
168+
strict=True,
169+
)
170+
@common.parametrize("test_data", Argmax.test_data)
171+
@common.SkipIfNoModelConverter
172+
def test_argmax_vgf_quant(test_data: Tuple[input_t, int]):
173+
data, dim = test_data()
174+
pipeline = VgfPipeline[input_t](
175+
Argmax(dim),
176+
data,
177+
aten_op,
178+
exir_op,
179+
quantize=True,
180+
)
181+
pipeline.run()

backends/arm/test/ops/test_pow.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ class Pow_TensorTensor(torch.nn.Module):
5757
),
5858
}
5959

60+
test_data_quant = {
61+
"positive_base_positive_exp": lambda: (
62+
torch.rand(2, 3, 4) * 1.5 + 0.25,
63+
torch.rand(2, 3, 4) * 1.5 + 0.25,
64+
),
65+
"broadcast_exp": lambda: (
66+
torch.rand(1, 3, 4, 4) * 1.5 + 0.25,
67+
torch.rand(1, 3, 1, 1) * 1.5 + 0.25,
68+
),
69+
"integer_valued_exp": lambda: (
70+
torch.rand(2, 4) * 1.5 + 0.25,
71+
torch.full((2, 4), 2.0),
72+
),
73+
}
74+
6075
def forward(self, x: torch.Tensor | float, y: torch.Tensor | float):
6176
return torch.pow(x, y)
6277

@@ -238,3 +253,24 @@ def test_pow_tensor_scalar_vgf_quant(test_data: Pow_TensorScalar.input_t):
238253
quantize=True,
239254
)
240255
pipeline.run()
256+
257+
258+
@common.parametrize("test_data", Pow_TensorTensor.test_data_quant)
259+
@common.SkipIfNoModelConverter
260+
def test_pow_tensor_tensor_vgf_quant(
261+
test_data: Pow_TensorTensor.input_t,
262+
):
263+
pipeline = VgfPipeline[Pow_TensorTensor.input_t](
264+
Pow_TensorTensor(),
265+
test_data(),
266+
Pow_TensorTensor.aten_op,
267+
Pow_TensorTensor.exir_op,
268+
quantize=True,
269+
)
270+
271+
pipeline.run_and_compare_to_initial_model(
272+
frobenius_threshold=0.3,
273+
cosine_threshold=0.9,
274+
)
275+
276+
pipeline.run()

backends/arm/test/ops/test_sign.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
)
1818

1919
aten_op = "torch.ops.aten.sign.default"
20-
exir_op = "executorch_exir_dialects_edge__ops_aten__sign_default"
20+
exir_op = "executorch_exir_dialects_edge__ops_aten_sign_default"
2121

2222
input_t1 = Tuple[torch.Tensor]
2323

0 commit comments

Comments
 (0)