Skip to content

Arm backend: use full_like in LeakyReLU decomposition#18127

Merged
mansnils merged 2 commits intopytorch:mainfrom
mansnils:ops
Mar 13, 2026
Merged

Arm backend: use full_like in LeakyReLU decomposition#18127
mansnils merged 2 commits intopytorch:mainfrom
mansnils:ops

Conversation

@mansnils
Copy link
Collaborator

@mansnils mansnils commented Mar 12, 2026

Replace full(x.shape, slope) with full_like(x, slope).

This avoids capturing export-time shape metadata and lets the created tensor inherit dtype/device from the runtime input tensor, preventing shape and device mismatches across export flows (e.g. QAT/PT2E vs already-quantized export).

Because of this LeakyRelu pass need to go before full_like_to_full conversion pass.

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

Replace `full(x.shape, slope)` with `full_like(x, slope)`.

This avoids capturing export-time shape metadata and lets the created
tensor inherit dtype/device from the runtime input tensor, preventing
shape and device mismatches across export flows (e.g. QAT/PT2E vs
already-quantized export).

Because of ths LeakyRelu pass need to go before full_like_to_full
conversion pass.

Signed-off-by: Måns Nilsson <mans.nilsson@arm.com>
Change-Id: I2cbae091c34eb3b905e402f2f122b10742b0ae1d
@mansnils mansnils requested a review from digantdesai as a code owner March 12, 2026 16:30
Copilot AI review requested due to automatic review settings March 12, 2026 16:30
@mansnils mansnils added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk labels Mar 12, 2026
@pytorch-bot
Copy link

pytorch-bot bot commented Mar 12, 2026

🔗 Helpful Links

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

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

❌ 1 New Failure, 2 Pending, 15 Unrelated Failures

As of commit 3ec5eb1 with merge base be0cdee (image):

NEW FAILURE - The following job has failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but were 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 Mar 12, 2026
@github-actions
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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Arm backend LeakyReLU decomposition to use full_like instead of full(shape, ...), reducing reliance on export-time shape/device metadata and aligning the created tensor with the runtime input tensor’s dtype/device. The TOSA pass pipeline is also reordered so the decomposition runs before the full_likefull conversion pass.

Changes:

  • Switch LeakyReLU decomposition from aten.full to aten.full_like and stop reading dtype/device from meta["val"].
  • Reorder the TOSA pipeline so DecomposeLeakyReLUPass runs before ConvertFullLikeToFullPass.
  • Update the decomposition’s docstring example accordingly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
backends/arm/_passes/decompose_leaky_relu_pass.py Use full_like(x, slope) during LeakyReLU decomposition to inherit properties from the runtime input.
backends/arm/_passes/arm_pass_manager.py Move DecomposeLeakyReLUPass earlier so any emitted full_like can be normalized by ConvertFullLikeToFullPass.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Måns Nilsson <mans.nilsson@arm.com>
Change-Id: If3947587dd806e349f4040fd0cb8b94214037145
@mansnils mansnils merged commit 4437685 into pytorch:main Mar 13, 2026
443 of 471 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. partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants