Skip to content

Arm backend: Support division with integer tensors#20536

Merged
Erik-Lundell merged 4 commits into
pytorch:mainfrom
Erik-Lundell:arm/identity-cast-quantized-fold
Jun 29, 2026
Merged

Arm backend: Support division with integer tensors#20536
Erik-Lundell merged 4 commits into
pytorch:mainfrom
Erik-Lundell:arm/identity-cast-quantized-fold

Conversation

@Erik-Lundell

@Erik-Lundell Erik-Lundell commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator
Arm backend: Support integer division.

torch.div() with two integer tensors and a rounding mode
gives integer output. The decomposition for this case instead
yielded floating point output, causing issues in indexing
operations which is typically where such integer division happens.

When supported, utilize the TOSA operator INTDIV. It directly
corresponds to the trunc case, and can be adjusted in the floor case.
When not supported, use float path by first casting int tensors
to float, and then casting the output back.

Additionally
- Improve scalar handling.
- Add cast op to u55 testrunner to match u85 better.

Arm backend: Support quantizing no-op fp casts.

If a int to fp cast goes directly into a quantized
operator, the cast is a noop if it is quantized
with unit quantization parameters (scale=1, zp=0).
This means it can be handled, even if the backend
doesn't support fp.

- Add Fixed unit qparam annotation to such a cast.
- Allow it in the partitioner.
- Finally, make sure the cast dtype is correct after
folding quant nodes.

This pattern can appear in the wild in a model,
or in a decomposition where you want to quantize
an integer tensor.

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani

@pytorch-bot

pytorch-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⏳ No Failures, 69 Pending

As of commit b5d4e18 with merge base 821b5a9 (image):
💚 Looks good so far! There are no failures yet. 💚

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 Jun 26, 2026
@github-actions github-actions Bot added ciflow/trunk module: arm Issues related to arm backend labels Jun 26, 2026
@Erik-Lundell Erik-Lundell added release notes: none Do not include this in the release notes partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm labels Jun 26, 2026
torch.div() with two integer tensors and a rounding mode
gives integer output. The decomposition for this case instead
yielded floating point output, causing issues in indexing
operations which is typically where such integer division happens.

When supported, utilize the TOSA operator INTDIV. It directly
corresponds to the trunc case, and can be adjusted in the floor case.
When not supported, use float path by first casting int tensors
to float, and then casting the output back.

Additionally
- Improve scalar handling.
- Add cast op to u55 testrunner to match u85 better.

Signed-off-by: Erik Lundell <erik.lundell@arm.com>
Change-Id: Ia5e3c956d5b83b4183171a8a230a510fc7a52149
If a int to fp cast goes directly into a quantized
operator, the cast is a noop if it is quantized
with unit quantization parameters (scale=1, zp=0).
This means it can be handled, even if the backend
doesn't support fp.

- Add Fixed unit qparam annotation to such a cast.
- Allow it in the partitioner.
- Finally, make sure the cast dtype is correct after
folding quant nodes.

This pattern can appear in the wild in a model,
or in a decomposition where you want to quantize
an integer tensor.

Signed-off-by: Erik Lundell <erik.lundell@arm.com>
Change-Id: I93bfd17ba51e25f121f61cbe3003e9c6b9891401
Signed-off-by: Erik Lundell <erik.lundell@arm.com>
Change-Id: I27bd905a66c5d8027a1a50a7cf662e0851bddde7
@Erik-Lundell Erik-Lundell force-pushed the arm/identity-cast-quantized-fold branch from 6037e6e to 54c5fab Compare June 29, 2026 07:24
Signed-off-by: Erik Lundell <erik.lundell@arm.com>
Change-Id: Ibb542ad564baae3a6e1c03470ac98c4c2ce676a3
@Erik-Lundell Erik-Lundell merged commit f11805c into pytorch:main Jun 29, 2026
488 of 489 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: arm Issues related to arm backend partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants