Skip to content

Commit 5d8308d

Browse files
Ninja91facebook-github-bot
authored andcommitted
Add 16A8W support and test for sigmoid operation
Summary: Add 16A8W quantization support and test for the sigmoid operation in ExecutorTorch ARM backend. This follows the pattern established for linear and mul operations, extending int16 support to sigmoid operations. Changes: - Add INT16 dtype validation support in op_sigmoid.py - Add test_sigmoid_tensor_16a8w_tosa_INT test function - Enable test_sigmoid.py in test targets configuration The 16A8W configuration uses 16-bit activations with 8-bit weights, enabling higher precision for activations while maintaining weight efficiency. Differential Revision: D80510729
1 parent 8f6f9b4 commit 5d8308d

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

backends/arm/test/ops/test_sigmoid.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@
99
from typing import Tuple
1010

1111
import torch
12-
from executorch.backends.arm.test import common
12+
from executorch.backends.arm.quantizer.arm_quantizer import (
13+
get_symmetric_a16w8_quantization_config,
14+
TOSAQuantizer,
15+
)
16+
from executorch.backends.arm.test import common, conftest
1317
from executorch.backends.arm.test.tester.test_pipeline import (
1418
EthosU55PipelineINT,
1519
EthosU85PipelineINT,
1620
TosaPipelineFP,
1721
TosaPipelineINT,
1822
VgfPipeline,
1923
)
24+
from executorch.backends.arm.tosa_specification import TosaSpecification
25+
from executorch.backends.xnnpack.test.tester import Quantize
2026

2127
aten_op = "torch.ops.aten.sigmoid.default" # Used for checking that we do not have softmax in the graph after decompose
2228
exir_op = "executorch_exir_dialects_edge__ops_aten_sigmoid_default"
@@ -253,3 +259,48 @@ def test_sigmoid_vgf_INT_add_3():
253259
tosa_version="TOSA-1.0+INT",
254260
)
255261
pipeline.run()
262+
263+
264+
def get_symmetric_a16w8_sigmoid_quantizer(
265+
u55_config=False, per_channel_quantization=False
266+
):
267+
tosa_version = conftest.get_option("tosa_version")
268+
tosa_profiles = {
269+
"1.0": TosaSpecification.create_from_string("TOSA-1.0+INT+int16"),
270+
}
271+
272+
quantizer = TOSAQuantizer(tosa_profiles[tosa_version])
273+
quantizer.set_global(
274+
get_symmetric_a16w8_quantization_config(is_per_channel=per_channel_quantization)
275+
)
276+
277+
return Quantize(
278+
quantizer,
279+
get_symmetric_a16w8_quantization_config(
280+
is_per_channel=per_channel_quantization
281+
),
282+
)
283+
284+
285+
@common.parametrize("test_data", test_data_suite)
286+
def test_sigmoid_16a8w_tosa_INT(test_data: torch.Tensor):
287+
"""Test sigmoid operation with 16A8W quantization (16-bit activations, 8-bit weights)"""
288+
per_channel_quantization = False
289+
290+
pipeline = TosaPipelineINT[input_t1](
291+
Sigmoid(),
292+
(test_data(),),
293+
aten_op,
294+
exir_op=[],
295+
per_channel_quantization=per_channel_quantization,
296+
use_to_edge_transform_and_lower=True,
297+
tosa_extensions=["int16"],
298+
)
299+
300+
pipeline.change_args(
301+
"quantize",
302+
get_symmetric_a16w8_sigmoid_quantizer(
303+
per_channel_quantization=per_channel_quantization
304+
),
305+
)
306+
pipeline.run()

0 commit comments

Comments
 (0)