Skip to content

Arm backend: Fix bug of inserting unnecessary casts for aten.where.self #11816

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

Merged
merged 3 commits into from
Jun 19, 2025

Conversation

YufengShi-dudu
Copy link
Collaborator

@YufengShi-dudu YufengShi-dudu commented Jun 19, 2025

  • In MatchWhereSelfDtypePass, target_dtype was initialized with fp32. This works when at least one of the inputs is fp32. But when both inputs are int32, the pass will incorrectly insert int32->fp32 casts. These casts are unnecessary and may introduce operand dtype mismatch issues.
  • Fix it by initializing target_dtype with input_dtype.

Change-Id: Id67aed8e90f886dc2f2491946847ad01702d5aa5

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218

- In MatchWhereSelfDtypePass, target_dtype was initialized with fp32.
  This works when at least one of the inputs is fp32. But when both
  inputs are int32, the pass will incorrectly insert int32->fp32
  casts. These casts are unnecessary and may introduce operand
  dtype mismatch issues.
- Fix it by initializing target_dtype with input_dtype.

Change-Id: Id67aed8e90f886dc2f2491946847ad01702d5aa5
Signed-off-by: Yufeng Shi <[email protected]>
@YufengShi-dudu YufengShi-dudu requested a review from zingo June 19, 2025 12:02
@YufengShi-dudu YufengShi-dudu added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk labels Jun 19, 2025
Copy link

pytorch-bot bot commented Jun 19, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit b042484 with merge base 994752e (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot facebook-github-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 19, 2025
@YufengShi-dudu
Copy link
Collaborator Author

Unrelated fail: macos-job
@zingo

@zingo zingo added the release notes: arm Changes to the ARM backend delegate label Jun 19, 2025
@zingo zingo merged commit 10f0d22 into pytorch:main Jun 19, 2025
336 of 341 checks passed
hinriksnaer pushed a commit to hinriksnaer/executorch that referenced this pull request Jun 26, 2025
…lf (pytorch#11816)

- In MatchWhereSelfDtypePass, target_dtype was initialized with fp32.
This works when at least one of the inputs is fp32. But when both inputs
are int32, the pass will incorrectly insert int32->fp32 casts. These
casts are unnecessary and may introduce operand dtype mismatch issues.
- Fix it by initializing target_dtype with input_dtype.

Signed-off-by: Yufeng Shi <[email protected]>
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 release notes: arm Changes to the ARM backend delegate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants