-
Couldn't load subscription status.
- Fork 700
Arm backend: Add support for sigmoid and tanh int16x8 #15101
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
| "zeros": lambda: torch.zeros(10, 10, 10, 10), | ||
| "ones": lambda: torch.ones(10, 10, 10), | ||
| "rand": lambda: torch.rand(10, 10) - 0.5, | ||
| "rand_4d": lambda: torch.rand(1, 1, 5, 10), | ||
| "randn_pos": lambda: torch.randn(10) + 10, | ||
| "randn_neg": lambda: torch.randn(10) - 10, | ||
| "ramp": lambda: torch.arange(-16, 16, 0.2), | ||
|
|
@@ -269,22 +270,23 @@ def get_symmetric_a16w8_sigmoid_quantizer(per_channel_quantization=False): | |
| } | ||
|
|
||
| quantizer = TOSAQuantizer(tosa_profiles[tosa_version]) | ||
|
|
||
| # Use a smaller episilon value to not greatly inflate [qmin, qmax] | ||
| quantizer.set_global( | ||
| get_symmetric_a16w8_quantization_config(is_per_channel=per_channel_quantization) | ||
| get_symmetric_a16w8_quantization_config( | ||
| is_per_channel=per_channel_quantization, epsilon=2**-16 | ||
|
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. How does this change impact other ops? 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. Thanks for review! 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. It's set in unit tests so that the sig/tanh can be partitioned to U55/U85, right? 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. As mentioned below, this is just to ensure we get the correct values on the output. |
||
| ) | ||
| ) | ||
|
|
||
| return Quantize( | ||
| quantizer, | ||
| get_symmetric_a16w8_quantization_config( | ||
| is_per_channel=per_channel_quantization | ||
| is_per_channel=per_channel_quantization, epsilon=2**-16 | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| @common.parametrize("test_data", test_data_suite) | ||
| @pytest.mark.xfail( | ||
| reason="missing int16 sigmoid ops support; fails at TOSA reference model with Unsupported operation type or rank. See: https://github.com/pytorch/executorch/issues/13974" | ||
| ) | ||
| def test_sigmoid_16a8w_tosa_INT(test_data: torch.Tensor): | ||
| """Test sigmoid operation with 16A8W quantization (16-bit activations, 8-bit weights)""" | ||
| per_channel_quantization = False | ||
|
|
@@ -311,7 +313,7 @@ def test_sigmoid_16a8w_tosa_INT(test_data: torch.Tensor): | |
| @common.parametrize("test_data", test_data_suite) | ||
| @common.XfailIfNoCorstone300 | ||
| @pytest.mark.xfail( | ||
| reason="Vela compilation fails with 'Invalid arguments' for int16 sigmoid operations" | ||
| reason="MLETORCH-707: AssertionError: Output 0 does not match reference output." | ||
|
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. This indicates we don't yet have full support for U55. Can you comment on what's remaining? cc: @3l1 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. This is more so a limitation in terms of U55 support and not a int16x8 specific issue. |
||
| ) | ||
| def test_sigmoid_16a8w_u55_INT16(test_data: torch.Tensor): | ||
| """Test sigmoid operation with 16A8W quantization on U55 (16-bit activations, 8-bit weights)""" | ||
|
|
@@ -337,9 +339,6 @@ def test_sigmoid_16a8w_u55_INT16(test_data: torch.Tensor): | |
|
|
||
| @common.parametrize("test_data", test_data_suite) | ||
| @common.XfailIfNoCorstone320 | ||
| @pytest.mark.xfail( | ||
| reason="Vela compilation fails with 'Invalid arguments' for int16 sigmoid operations" | ||
| ) | ||
| def test_sigmoid_16a8w_u85_INT16(test_data: torch.Tensor): | ||
| """Test sigmoid operation with 16A8W quantization on U85 (16-bit activations, 8-bit weights)""" | ||
| per_channel_quantization = False | ||
|
|
||
This file was deleted.
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.
Ok so in order for sig/tanh to be able to partition, we need to set this to 2**-16 right?
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.
It can be partitioned without it, this is more so for numerical behavior. If the set epsilon is too high, the quantization arguments can be inflated resulting in an incorrect output.
Thank you for review!