-
Notifications
You must be signed in to change notification settings - Fork 654
Arm backend: Add 16A8W FCNode support with BMM dependency fix #13801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ninja91
wants to merge
1
commit into
gh/Ninja91/14/base
Choose a base branch
from
gh/Ninja91/14/head
base: gh/Ninja91/14/base
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,23 @@ | |
|
||
from typing import Tuple | ||
|
||
import pytest | ||
import torch | ||
from executorch.backends.arm.quantizer.arm_quantizer import ( | ||
get_symmetric_a16w8_quantization_config, | ||
TOSAQuantizer, | ||
) | ||
|
||
from executorch.backends.arm.test import common | ||
from executorch.backends.arm.test import common, conftest | ||
from executorch.backends.arm.test.tester.test_pipeline import ( | ||
EthosU55PipelineINT, | ||
EthosU85PipelineINT, | ||
TosaPipelineFP, | ||
TosaPipelineINT, | ||
VgfPipeline, | ||
) | ||
from executorch.backends.arm.tosa_specification import TosaSpecification | ||
from executorch.backends.xnnpack.test.tester import Quantize | ||
|
||
aten_op = "torch.ops.aten.addmm.default" | ||
|
||
|
@@ -182,3 +189,102 @@ def test_addmm_vgf_INT(test_data: input_t1): | |
tosa_version="TOSA-1.0+INT", | ||
) | ||
pipeline.run() | ||
|
||
|
||
def get_symmetric_a16w8_addmm_quantizer(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", test_data_suite) | ||
def test_addmm_16a8w_tosa_INT(test_data: input_t1): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok so this passes but linear doesn't, interesting :) |
||
"""Test addmm (FC layer) operation with 16A8W quantization (16-bit activations, 8-bit weights)""" | ||
per_channel_quantization = False | ||
|
||
pipeline = TosaPipelineINT[input_t1]( | ||
Addmm(), | ||
(*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_addmm_quantizer( | ||
per_channel_quantization=per_channel_quantization | ||
), | ||
) | ||
pipeline.run() | ||
|
||
|
||
@common.parametrize("test_data", test_data_suite) | ||
@common.XfailIfNoCorstone300 | ||
@pytest.mark.xfail( | ||
reason="Vela compilation fails with 'Invalid arguments' for int16 addmm operations" | ||
) | ||
def test_addmm_16a8w_u55_INT16(test_data: input_t1): | ||
"""Test addmm (FC layer) operation with 16A8W quantization on U55 (16-bit activations, 8-bit weights)""" | ||
per_channel_quantization = False | ||
|
||
pipeline = EthosU55PipelineINT[input_t1]( | ||
Addmm(), | ||
(*test_data,), | ||
aten_ops=[], | ||
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_addmm_quantizer( | ||
per_channel_quantization=per_channel_quantization | ||
), | ||
) | ||
pipeline.run() | ||
|
||
|
||
@common.parametrize("test_data", test_data_suite) | ||
@common.XfailIfNoCorstone320 | ||
@pytest.mark.xfail( | ||
reason="Vela compilation fails with 'Invalid arguments' for int16 addmm operations" | ||
) | ||
def test_addmm_16a8w_u85_INT16(test_data: input_t1): | ||
"""Test addmm (FC layer) operation with 16A8W quantization on U85 (16-bit activations, 8-bit weights)""" | ||
per_channel_quantization = False | ||
|
||
pipeline = EthosU85PipelineINT[input_t1]( | ||
Addmm(), | ||
(*test_data,), | ||
aten_ops=[], | ||
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_addmm_quantizer( | ||
per_channel_quantization=per_channel_quantization | ||
), | ||
) | ||
pipeline.run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix mypy!