Skip to content
Merged
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
69 changes: 69 additions & 0 deletions backends/arm/test/ops/test_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Tuple

import pytest

import torch
from executorch.backends.arm.quantizer.arm_quantizer import (
get_symmetric_a16w8_quantization_config,
Expand Down Expand Up @@ -308,3 +309,71 @@ def test_linear_16a8w_tosa_INT(test_data: torch.Tensor):
)
# Run the pipeline
pipeline.run()


@common.parametrize("test_data", test_data_rank1_INT | test_data_rank4_INT)
@common.XfailIfNoCorstone300
@pytest.mark.xfail(
reason="Ethos-U55 A16W8 linear: int16 matmul not yet supported; pending backend support or linear->conv1x1 lowering. See: https://github.com/pytorch/executorch/issues/13947",
strict=False,
)
def test_linear_16a8w_u55_INT16(test_data: torch.Tensor):
"""Test linear operation with 16A8W quantization on U55 (16-bit activations, 8-bit weights)"""
test_data, out_features, has_bias, per_channel_quantization = test_data()
in_features = test_data.shape[-1]

pipeline = EthosU55PipelineINT[input_t1](
Linear(
in_features=in_features,
out_features=out_features,
bias=has_bias,
),
(test_data,),
aten_op,
exir_ops=[],
per_channel_quantization=per_channel_quantization,
use_to_edge_transform_and_lower=True,
run_on_fvp=True,
)

pipeline.change_args(
"quantize",
get_symmetric_a16w8_linear_quantizer(
per_channel_quantization=per_channel_quantization
),
)
pipeline.run()


@common.parametrize("test_data", test_data_rank1_INT | test_data_rank4_INT)
@common.XfailIfNoCorstone320
@pytest.mark.xfail(
reason="Ethos-U55 A16W8 linear: int16 matmul not yet supported; pending backend support or linear->conv1x1 lowering. See: https://github.com/pytorch/executorch/issues/13947",
strict=False,
)
def test_linear_16a8w_u85_INT16(test_data: torch.Tensor):
"""Test linear operation with 16A8W quantization on U85 (16-bit activations, 8-bit weights)"""
test_data, out_features, has_bias, per_channel_quantization = test_data()
in_features = test_data.shape[-1]

pipeline = EthosU85PipelineINT[input_t1](
Linear(
in_features=in_features,
out_features=out_features,
bias=has_bias,
),
(test_data,),
aten_op,
exir_ops=[],
per_channel_quantization=per_channel_quantization,
use_to_edge_transform_and_lower=True,
run_on_fvp=True,
)

pipeline.change_args(
"quantize",
get_symmetric_a16w8_linear_quantizer(
per_channel_quantization=per_channel_quantization
),
)
pipeline.run()
2 changes: 2 additions & 0 deletions backends/arm/tosa/quant_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from executorch.backends.arm.tosa.mapping import TosaArg
from torch.fx import Node

from tosa.RoundingMode import RoundingMode # type: ignore


Expand Down Expand Up @@ -318,6 +319,7 @@ def build_rescale(
per_channel=False,
):
import serializer.tosa_serializer as ts # type: ignore

import tosa.Op as TosaOp # type: ignore

scaleWidth = 32
Expand Down
Loading