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
2 changes: 1 addition & 1 deletion backends/arm/operator_support/ethos_u55_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def is_node_supported( # noqa: C901
return False

if node.target in self.target_ops_i8:
if dtype not in (torch.int8,):
if dtype not in (torch.int8, torch.int16):
self.reporter.report_reject(
node, f"Unsupported dtype {dtype} (Supports i8)."
)
Expand Down
105 changes: 103 additions & 2 deletions backends/arm/test/ops/test_rsqrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@
from typing import Tuple

import torch
from executorch.backends.arm.quantizer.arm_quantizer import (
get_symmetric_a16w8_quantization_config,
TOSAQuantizer,
)
from executorch.backends.arm.test import common, conftest

from executorch.backends.arm.test import common
from executorch.backends.arm.test.tester.test_pipeline import (
EthosU55PipelineINT,
EthosU85PipelineINT,
TosaPipelineFP,
TosaPipelineINT,
VgfPipeline,
)

from executorch.backends.arm.tosa import TosaSpecification
from executorch.backends.xnnpack.test.tester import Quantize

aten_op = "torch.ops.aten.rsqrt.default"
input_t1 = Tuple[torch.Tensor] # Input x
Expand Down Expand Up @@ -104,3 +109,99 @@ def test_rsqrt_vgf_INT(test_tensor: torch.Tensor):
tosa_version="TOSA-1.0+INT",
)
pipeline.run()


def get_symmetric_a16w8_rsqrt_quantizer(
u55_config=False, per_channel_quantization=False
):
tosa_version = conftest.get_option("tosa_version")
tosa_profiles = {
"1.0": TosaSpecification.create_from_string("TOSA-1.0+INT+int16"),
}

quantizer = TOSAQuantizer(tosa_profiles[tosa_version])
quantizer.set_global(
get_symmetric_a16w8_quantization_config(is_per_channel=per_channel_quantization)
)
quantizer.set_module_type(
torch.nn.Linear,
get_symmetric_a16w8_quantization_config(
is_per_channel=per_channel_quantization
),
)

return Quantize(
quantizer,
get_symmetric_a16w8_quantization_config(
is_per_channel=per_channel_quantization
),
)


@common.parametrize("test_tensor", Rsqrt.test_parameters)
def test_rsqrt_16a8w_tosa_INT(test_tensor: torch.Tensor):
"""Test rsqrt operation with 16A8W quantization (16-bit activations, 8-bit weights)"""
# Create pipeline with custom 16A8W quantization config
pipeline = TosaPipelineINT[input_t1](
Rsqrt(),
test_tensor(),
aten_op,
exir_op=[],
per_channel_quantization=False,
use_to_edge_transform_and_lower=True,
tosa_extensions=["int16"],
)

pipeline.change_args(
"quantize",
get_symmetric_a16w8_rsqrt_quantizer(
per_channel_quantization=False
),
)
# Run the pipeline
pipeline.run()


@common.parametrize("test_tensor", Rsqrt.test_parameters)
@common.XfailIfNoCorstone300
def test_rsqrt_16a8w_u55_INT16(test_tensor: torch.Tensor):
"""Test rsqrt operation with 16A8W quantization on U55 (16-bit activations, 8-bit weights)"""
pipeline = EthosU55PipelineINT[input_t1](
Rsqrt(),
test_tensor(),
aten_op,
exir_ops=[],
per_channel_quantization=True,
use_to_edge_transform_and_lower=True,
run_on_fvp=True,
)

pipeline.change_args(
"quantize",
get_symmetric_a16w8_rsqrt_quantizer(
per_channel_quantization=True
),
)
pipeline.run()


@common.parametrize("test_tensor", Rsqrt.test_parameters)
@common.XfailIfNoCorstone320
def test_rsqrt_16a8w_u85_INT16(test_tensor: torch.Tensor):
"""Test rsqrt operation with 16A8W quantization on U85 (16-bit activations, 8-bit weights)"""
pipeline = EthosU85PipelineINT[input_t1](
Rsqrt(),
test_tensor(),
aten_op,
exir_ops=[],
use_to_edge_transform_and_lower=True,
run_on_fvp=True,
)

pipeline.change_args(
"quantize",
get_symmetric_a16w8_rsqrt_quantizer(
per_channel_quantization=False
),
)
pipeline.run()
1 change: 1 addition & 0 deletions backends/arm/test/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def define_arm_tests():
"ops/test_cat.py",
"ops/test_linear.py",
"ops/test_mul.py",
"ops/test_rsqrt.py",
"ops/test_slice.py",
"ops/test_sigmoid.py",
"ops/test_sub.py",
Expand Down
Loading