Skip to content
Closed
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/operators/op_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def define_node(
validate_valid_dtype(
self.target,
[*inputs, output],
[ts.DType.INT8, ts.DType.INT32],
[ts.DType.INT8, ts.DType.INT16, ts.DType.INT32],
output.tosa_spec,
)

Expand Down
50 changes: 50 additions & 0 deletions backends/arm/test/ops/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
import pytest
import torch
from executorch.backends.arm.quantizer import arm_quantizer
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.tester.test_pipeline import (
EthosU55PipelineINT,
Expand Down Expand Up @@ -216,3 +220,49 @@ def test_add_tensor_vgf_INT(test_data: input_t1):
tosa_version="TOSA-1.0+INT",
)
pipeline.run()


def get_symmetric_a16w8_add_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)
)

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


@common.parametrize("test_data", Add.test_data)
@pytest.mark.xfail(
reason="missing int16 add ops support; fails at TOSA reference model with Unsupported operation type or rank"
)
def test_add_tensor_16a8w_tosa_INT(test_data: input_t1):
"""Test add operation with 16A8W quantization (16-bit activations, 8-bit weights)"""
per_channel_quantization = False

pipeline = TosaPipelineINT[input_t1](
Add(),
test_data(),
aten_op,
exir_op=[],
per_channel_quantization=per_channel_quantization,
use_to_edge_transform_and_lower=True,
tosa_extensions=["int16"],
)

pipeline.change_args(
"quantize",
get_symmetric_a16w8_add_quantizer(
per_channel_quantization=per_channel_quantization
),
)
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 @@ -13,6 +13,7 @@ def define_arm_tests():

# Operators
test_files += [
"ops/test_add.py",
"ops/test_avg_pool2d.py",
"ops/test_linear.py",
"ops/test_slice.py",
Expand Down
Loading