Skip to content

Conversation

@YufengShi-dudu
Copy link
Collaborator

@YufengShi-dudu YufengShi-dudu commented Jul 7, 2025

  • Pytorch .to() truncates values toward zeros, while TOSA's CAST rounds values to the nearest int. They will show different behaviours on fp32->int32 casting.
  • Fix the mismatched behaviour with the following transformation:
    Before:
    output = to_copy(x, torch.int32)
    After:
    is_non_negative = x >= 0
    floor_x = floor(x)
    ceil_x = ceil(x)
    decorated_x = where(is_non_negative, floor_x, ceil_x)
    output = to_copy(decorated_x, torch.int32)

Change-Id: I21286432eeb0a5e2f21865f3ac097051c921a9b3

cc @digantdesai @freddan80 @per @zingo @oscarandersson8218

- Pytorch .to() truncates values toward zeros, while TOSA's CAST
  rounds values to the nearest int. They will show different
  behaviours on fp32->int32 casting.
- Fix the mismatched behaviour with the following transformation:
  Before:
    output = to_copy(x, torch.int32)
  After:
    is_non_negative = x >= 0
    floor_x = floor(x)
    ceil_x = ceil(x)
    decorated_x = where(is_non_negative, floor_x, ceil_x)
    output = to_copy(decorated_x, torch.int32)

Change-Id: I21286432eeb0a5e2f21865f3ac097051c921a9b3
Signed-off-by: Yufeng Shi <[email protected]>
@YufengShi-dudu YufengShi-dudu added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk release notes: arm Changes to the ARM backend delegate labels Jul 7, 2025
@pytorch-bot
Copy link

pytorch-bot bot commented Jul 7, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure, 1 Cancelled Job, 4 Unrelated Failures

As of commit 4e19b63 with merge base b342f83 (image):

NEW FAILURE - The following job has failed:

CANCELLED JOB - The following job was cancelled. Please retry:

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.

@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 Jul 7, 2025
Copy link
Collaborator

@oscarandersson8218 oscarandersson8218 left a comment

Choose a reason for hiding this comment

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

Unrelated CI failures. LGTM!

@oscarandersson8218 oscarandersson8218 merged commit 1315388 into pytorch:main Jul 8, 2025
192 of 198 checks passed
Tanish2101 pushed a commit to Tanish2101/executorch that referenced this pull request Jul 9, 2025
…ytorch#12243)

- Pytorch .to() truncates values toward zeros, while TOSA's CAST rounds
values to the nearest int. They will show different behaviours on
fp32->int32 casting.
- Fix the mismatched behaviour with the following transformation: 
   Before:
     output = to_copy(x, torch.int32) 
   After:
     is_non_negative = x >= 0
     floor_x = floor(x)
     ceil_x = ceil(x)
     decorated_x = where(is_non_negative, floor_x, ceil_x)
     output = to_copy(decorated_x, torch.int32)

Change-Id: I21286432eeb0a5e2f21865f3ac097051c921a9b3



cc @digantdesai @freddan80 @per @zingo @oscarandersson8218

Signed-off-by: Yufeng Shi <[email protected]>
psiddh added a commit to psiddh/executorch that referenced this pull request Jul 9, 2025
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.

4 participants