Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions backends/arm/test/ops/test_conv1d.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Copyright 2024-2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
Expand Down Expand Up @@ -399,3 +399,76 @@
get_symmetric_a8w4_quantization_config(is_per_channel=per_channel_quantization)
)
pipeline.run()


# a16w8 (int16 activation, int8 weight) quantization test configurations
a16w8_conv1d_test_parameters = {
f"{k},per_channel_quant={q}": (lambda v=v, q=q: (v(), q))
for (k, v) in {
"k1_1x2x128_st1": lambda: Conv1d(
in_channels=2, out_channels=1, kernel_size=1,
stride=1, padding=0, length=128, batches=1,
),
"k3_1x3x64_st1_pd1": lambda: Conv1d(
in_channels=3, out_channels=4, kernel_size=3,
stride=1, padding=1, length=64, batches=1,
),
"k5_1x2x64_st1_pd2": lambda: Conv1d(
in_channels=2, out_channels=3, kernel_size=5,
stride=1, padding=2, length=64, batches=1,
),
"k3_1x3x32_st2_pd1": lambda: Conv1d(
in_channels=3, out_channels=4, kernel_size=3,
stride=2, padding=1, length=32, batches=1,
),
"k3_1x3x32_st1_dl2": lambda: Conv1d(
in_channels=3, out_channels=4, kernel_size=3,
stride=1, padding=0, dilation=2, length=32, batches=1,
),
"k3_1x4x32_st1_pd1_depthwise": lambda: Conv1d(
in_channels=4, out_channels=4, kernel_size=3,
stride=1, padding=1, groups=4, length=32, batches=1,
),
"k3_1x3x64_st1_pd1_nobias": lambda: Conv1d(
in_channels=3, out_channels=4, kernel_size=3,
stride=1, padding=1, bias=False, length=64, batches=1,
),
}.items()
for q in [True, False]
}


@common.parametrize("test_data", a16w8_conv1d_test_parameters)
@common.XfailIfNoCorstone300
def test_conv1d_a16w8_u55_INT(test_data):
model, per_channel_quantization = test_data()
pipeline = EthosU55PipelineINT[input_t](
model,
model.get_inputs(),
aten_op,
exir_op,
a16w8_quantization=True,
symmetric_io_quantization=True,
per_channel_quantization=per_channel_quantization,
qtol=128,
epsilon=2**-16,
)
pipeline.run()


@common.parametrize("test_data", a16w8_conv1d_test_parameters)
@common.XfailIfNoCorstone320
def test_conv1d_a16w8_u85_INT(test_data):
model, per_channel_quantization = test_data()
pipeline = EthosU85PipelineINT[input_t](
model,
model.get_inputs(),
aten_op,
exir_op,
a16w8_quantization=True,
symmetric_io_quantization=True,
per_channel_quantization=per_channel_quantization,
qtol=128,
epsilon=2**-16,
)
pipeline.run()
39 changes: 39 additions & 0 deletions backends/arm/test/ops/test_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,42 @@ def test_exp_vgf_quant(test_data: Tuple):
quantize=True,
)
pipeline.run()


a16w8_exp_test_parameters = {
"rank1_rand": lambda: torch.rand(10),
"rank2_rand": lambda: torch.rand(8, 8) - 0.5,
"rank3_rand": lambda: torch.rand(1, 4, 4) * 2 - 1,
}


@common.parametrize("test_data", a16w8_exp_test_parameters)
@common.XfailIfNoCorstone300
def test_exp_a16w8_u55_INT(test_data: Tuple):
pipeline = EthosU55PipelineINT[input_t1](
Exp(),
(test_data(),),
aten_op,
exir_ops=[],
symmetric_io_quantization=True,
a16w8_quantization=True,
qtol=128,
epsilon=2**-16,
)
pipeline.run()


@common.parametrize("test_data", a16w8_exp_test_parameters)
@common.XfailIfNoCorstone320
def test_exp_a16w8_u85_INT(test_data: Tuple):
pipeline = EthosU85PipelineINT[input_t1](
Exp(),
(test_data(),),
aten_op,
exir_ops=[],
symmetric_io_quantization=True,
a16w8_quantization=True,
qtol=128,
epsilon=2**-16,
)
pipeline.run()
40 changes: 40 additions & 0 deletions backends/arm/test/ops/test_gelu.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Tuple

import torch

from executorch.backends.arm.test import common
from executorch.backends.arm.test.tester.test_pipeline import (
EthosU55PipelineINT,
Expand Down Expand Up @@ -176,3 +177,42 @@ def test_gelu_vgf_quant(test_data: input_t1):
quantize=True,
)
pipeline.run()


a16w8_gelu_test_parameters = {
"rank1_rand": lambda: torch.rand(10),
"rank2_rand": lambda: torch.rand(8, 8) - 0.5,
"rank3_randn": lambda: torch.randn(1, 4, 4) + 2,
}


@common.parametrize("test_data", a16w8_gelu_test_parameters)
@common.XfailIfNoCorstone300
def test_gelu_a16w8_u55_INT(test_data: input_t1):
pipeline = EthosU55PipelineINT[input_t1](
Gelu(),
(test_data(),),
Gelu.aten_op,
Gelu.exir_op,
a16w8_quantization=True,
symmetric_io_quantization=True,
qtol=128,
epsilon=2**-16,
)
pipeline.run()


@common.parametrize("test_data", a16w8_gelu_test_parameters)
@common.XfailIfNoCorstone320
def test_gelu_a16w8_u85_INT(test_data: input_t1):
pipeline = EthosU85PipelineINT[input_t1](
Gelu(),
(test_data(),),
Gelu.aten_op,
Gelu.exir_op,
a16w8_quantization=True,
symmetric_io_quantization=True,
qtol=128,
epsilon=2**-16,
)
pipeline.run()
47 changes: 47 additions & 0 deletions backends/arm/test/ops/test_mean_dim.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,50 @@ def test_mean_tosa_INT(test_data):
symmetric_io_quantization=True,
)
pipeline.run()


a16w8_mean_test_parameters = {
"rank_1_keepdim": lambda: (torch.rand(7), 0, True),
"rank_2_keepdim": lambda: (torch.rand(7, 3), (0, 1), True),
"rank_3_keepdim": lambda: (torch.rand(5, 7, 3), (0, 1, 2), True),
"rand_1_keepdim": lambda: (torch.rand(1, 5, 7, 3), (1), True),
"rand_23_keepdim": lambda: (torch.rand(1, 5, 7, 3), (2, 3), True),
"rand_0123_keepdim": lambda: (torch.rand(1, 5, 7, 3), (0, 1, 2, 3), True),
"rand_none_keepdim": lambda: (torch.rand(1, 5, 7, 3), None, True),
"rank_1": lambda: (torch.rand(7), (-1), False),
"rank_2": lambda: (torch.rand(5, 7), (-2, -1), False),
"rand_3": lambda: (torch.rand(1, 5, 7, 3), (-1), False),
"rand_123": lambda: (torch.rand(1, 5, 7, 3), (-3, -2, -1), False),
}


@common.parametrize("test_data", a16w8_mean_test_parameters)
@common.XfailIfNoCorstone300
def test_mean_dim_a16w8_u55_INT(test_data):
test_data, dim, keep_dim = test_data()
pipeline = EthosU55PipelineINT[input_t](
MeanDim(dim, keep_dim),
(test_data,),
[],
symmetric_io_quantization=True,
a16w8_quantization=True,
qtol=128,
epsilon=2**-16,
)
pipeline.run()


@common.parametrize("test_data", a16w8_mean_test_parameters)
@common.XfailIfNoCorstone320
def test_mean_dim_a16w8_u85_INT(test_data):
test_data, dim, keep_dim = test_data()
pipeline = EthosU85PipelineINT[input_t](
MeanDim(dim, keep_dim),
(test_data,),
[],
symmetric_io_quantization=True,
a16w8_quantization=True,
qtol=128,
epsilon=2**-16,
)
pipeline.run()
39 changes: 39 additions & 0 deletions backends/arm/test/ops/test_reciprocal.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,42 @@ def test_reciprocal_vgf_quant(test_data: torch.Tensor):
quantize=True,
)
pipeline.run()


a16w8_reciprocal_test_parameters = {
"rank1": lambda: torch.rand(10) + 0.5,
"rank2": lambda: torch.rand(5, 10) + 0.5,
"rank3": lambda: torch.rand(2, 5, 10) + 0.5,
}


@common.parametrize("test_data", a16w8_reciprocal_test_parameters)
@common.XfailIfNoCorstone300
def test_reciprocal_a16w8_u55_INT(test_data: torch.Tensor):
pipeline = EthosU55PipelineINT[input_t1](
Reciprocal(),
(test_data(),),
aten_op,
exir_ops=[],
a16w8_quantization=True,
symmetric_io_quantization=True,
qtol=128,
epsilon=2**-16,
)
pipeline.run()


@common.parametrize("test_data", a16w8_reciprocal_test_parameters)
@common.XfailIfNoCorstone320
def test_reciprocal_a16w8_u85_INT(test_data: torch.Tensor):
pipeline = EthosU85PipelineINT[input_t1](
Reciprocal(),
(test_data(),),
aten_op,
exir_ops=[],
a16w8_quantization=True,
symmetric_io_quantization=True,
qtol=128,
epsilon=2**-16,
)
pipeline.run()
43 changes: 41 additions & 2 deletions backends/arm/test/ops/test_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class Var(torch.nn.Module):
),
}

test_parameters_ethosu = {
"var_4d_keep_dim_0_correction": lambda: (torch.randn(1, 50, 10, 20), True, 0),
"var_4d_keep_dim_1_correction": lambda: (torch.randn(1, 30, 15, 20), True, 1),
}

def __init__(self, keepdim: bool = True, correction: int = 0):
super().__init__()
self.keepdim = keepdim
Expand Down Expand Up @@ -170,7 +175,7 @@ def test_var_dim_tosa_INT_no_dim(test_data: Tuple):
pipeline.run()


@common.parametrize("test_data", Var.test_parameters)
@common.parametrize("test_data", Var.test_parameters_ethosu)
@common.XfailIfNoCorstone300
def test_var_dim_u55_INT_no_dim(test_data: Tuple):
test_data, keepdim, correction = test_data()
Expand All @@ -183,7 +188,7 @@ def test_var_dim_u55_INT_no_dim(test_data: Tuple):
pipeline.run()


@common.parametrize("test_data", Var.test_parameters)
@common.parametrize("test_data", Var.test_parameters_ethosu)
@common.XfailIfNoCorstone320
def test_var_dim_u85_INT_no_dim(test_data: Tuple):
test_data, keepdim, correction = test_data()
Expand Down Expand Up @@ -224,6 +229,40 @@ def test_var_dim_vgf_quant_no_dim(test_data: Tuple):
pipeline.run()


@common.parametrize("test_data", Var.test_parameters_ethosu)
@common.XfailIfNoCorstone300
def test_var_a16w8_u55_INT(test_data: Tuple):
test_data, keepdim, correction = test_data()
pipeline = EthosU55PipelineINT[input_t1](
Var(keepdim, correction),
(test_data,),
aten_ops=[],
exir_ops=[],
a16w8_quantization=True,
symmetric_io_quantization=True,
qtol=128,
epsilon=2**-16,
)
pipeline.run()


@common.parametrize("test_data", Var.test_parameters_ethosu)
@common.XfailIfNoCorstone320
def test_var_a16w8_u85_INT(test_data: Tuple):
test_data, keepdim, correction = test_data()
pipeline = EthosU85PipelineINT[input_t1](
Var(keepdim, correction),
(test_data,),
aten_ops=[],
exir_ops=[],
a16w8_quantization=True,
symmetric_io_quantization=True,
qtol=128,
epsilon=2**-16,
)
pipeline.run()


#############
## VarDim ###
#############
Expand Down
6 changes: 6 additions & 0 deletions backends/arm/test/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def define_arm_tests():
"ops/test_view.py",
"ops/test_cos.py",
"ops/test_to_copy.py",
"ops/test_exp.py",
"ops/test_reciprocal.py",
"ops/test_mean_dim.py",
"ops/test_var.py",
"ops/test_conv1d.py",
"ops/test_gelu.py",
]

# Quantization
Expand Down
Loading