Skip to content

Arm backend: Support division with integer tensors#20536

Open
Erik-Lundell wants to merge 2 commits into
pytorch:mainfrom
Erik-Lundell:arm/identity-cast-quantized-fold
Open

Arm backend: Support division with integer tensors#20536
Erik-Lundell wants to merge 2 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

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
@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.

❌ 2 New Failures, 4 Unrelated Failures, 1 Unclassified Failure

As of commit e55e878 with merge base a8cfb75 (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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
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