Skip to content

Conversation

Ninja91
Copy link
Contributor

@Ninja91 Ninja91 commented Oct 15, 2025

Summary:

Summary

Add INT16 dtype support to the permute (transpose) operation in the ARM TOSA backend, following the same pattern as other int16-enabled operations like conv2d.

Problem

The aten.permute_copy.default operation only supported INT8, INT32, and FP32 dtypes. INT16 support was missing, which blocks int16 quantized models that use permutation operations (e.g., LSTM with int16 activations).

Solution

  • Added INT16 to the list of valid dtypes for permute operation
  • Used proper TOSA spec extension check: tosa_spec.support_extension("int16")
  • Follows the established pattern from other int16-enabled operations

Implementation Details

# Build list of valid dtypes based on TOSA spec
valid_dtypes = [ts.DType.INT8, ts.DType.INT32, ts.DType.FP32]
if isinstance(output.tosa_spec, Tosa_1_00) and output.tosa_spec.support_extension("int16"):
    valid_dtypes.append(ts.DType.INT16)

This ensures INT16 support is only enabled when:

  1. Using TOSA 1.0 spec
  2. The "int16" extension is supported by the target hardware

TOSA Specification

According to TOSA spec, the TRANSPOSE operation (used by permute) supports INT16 when the int16 extension is enabled. This change aligns the implementation with the specification.

Impact

  • Enables int16 quantized models to use permutation operations
  • Required for LSTM int16 quantization support
  • Follows existing patterns in codebase (low risk)

Files Changed

  • fbcode/executorch/backends/arm/operators/op_permute.py
  • xplat/executorch/backends/arm/operators/op_permute.py (mirrored)

Generated by RACER, powered by Confucius
Session

Differential Revision: D84642353

Summary:
## Summary
Add INT16 dtype support to the permute (transpose) operation in the ARM TOSA backend, following the same pattern as other int16-enabled operations like conv2d.

## Problem
The `aten.permute_copy.default` operation only supported INT8, INT32, and FP32 dtypes. INT16 support was missing, which blocks int16 quantized models that use permutation operations (e.g., LSTM with int16 activations).

## Solution
- Added INT16 to the list of valid dtypes for permute operation
- Used proper TOSA spec extension check: `tosa_spec.support_extension("int16")`
- Follows the established pattern from other int16-enabled operations

## Implementation Details
```python
# Build list of valid dtypes based on TOSA spec
valid_dtypes = [ts.DType.INT8, ts.DType.INT32, ts.DType.FP32]
if isinstance(output.tosa_spec, Tosa_1_00) and output.tosa_spec.support_extension("int16"):
    valid_dtypes.append(ts.DType.INT16)
```

This ensures INT16 support is only enabled when:
1. Using TOSA 1.0 spec
2. The "int16" extension is supported by the target hardware

## TOSA Specification
According to TOSA spec, the TRANSPOSE operation (used by permute) supports INT16 when the int16 extension is enabled. This change aligns the implementation with the specification.

## Impact
- Enables int16 quantized models to use permutation operations
- Required for LSTM int16 quantization support
- Follows existing patterns in codebase (low risk)

## Files Changed
- `fbcode/executorch/backends/arm/operators/op_permute.py`
- `xplat/executorch/backends/arm/operators/op_permute.py` (mirrored)

---
> Generated by [RACER](https://www.internalfb.com/wiki/RACER_(Risk-Aware_Code_Editing_and_Refactoring)/), powered by [Confucius](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/)
[Session](https://www.internalfb.com/confucius?session_id=d505e146-a8c6-11f0-942f-6b00b4b362c1&tab=Chat)

Differential Revision: D84642353
@Ninja91 Ninja91 requested a review from digantdesai as a code owner October 15, 2025 00:51
Copy link

pytorch-bot bot commented Oct 15, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/15138

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure

As of commit fefed27 with merge base 926312e (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 15, 2025
Copy link

meta-codesync bot commented Oct 15, 2025

@Ninja91 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D84642353.

Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant