Skip to content

Arm backend: Fix conversion from uint8 to fp32 for img_class application#18607

Open
gggekov wants to merge 1 commit intopytorch:mainfrom
gggekov:fix_uint8_to_fp32_conversion
Open

Arm backend: Fix conversion from uint8 to fp32 for img_class application#18607
gggekov wants to merge 1 commit intopytorch:mainfrom
gggekov:fix_uint8_to_fp32_conversion

Conversation

@gggekov
Copy link
Copy Markdown
Collaborator

@gggekov gggekov commented Mar 31, 2026

Change-Id: I8aca840519f61e3b37100f7fefa58f2e0bd65be9
Signed-off-by: George Gekov <george.gekov@arm.com>
Copilot AI review requested due to automatic review settings March 31, 2026 09:18
@gggekov gggekov requested a review from digantdesai as a code owner March 31, 2026 09:18
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Mar 31, 2026

🔗 Helpful Links

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

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

❌ 6 Cancelled Jobs, 4 Unrelated Failures

As of commit 6efa5e8 with merge base 07c5a54 (image):

CANCELLED JOBS - The following jobs were 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.

@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 31, 2026
@gggekov gggekov added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk labels Mar 31, 2026
@github-actions
Copy link
Copy Markdown

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

This PR updates the image preprocessing used by the Arm Ethos-U image classification runtime example so that RGB pixel values are converted from uint8 [0..255] into fp32 values in the model’s expected [-1..1] range.

Changes:

  • Adjust input normalization from / 255.0 to / 127.5 - 1 to map [0..255] → [-1..1].
  • Add explanatory comments describing the normalization rationale.
  • Update the copyright header year range.

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

data = np.array(img_channels_first, dtype=np.float32) / 255.0
# The PIL Image function returns the image represented in the range [0;255].
# However, the NN was trained on fp32 numbers in the range [-1;1].
# To pass from [0;255] to [-1;1], we divide by 127.5(the middle of the range)
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

There’s a missing space in the comment: 127.5(the middle of the range) reads as a typo. Please add a space after 127.5 for readability.

Suggested change
# To pass from [0;255] to [-1;1], we divide by 127.5(the middle of the range)
# To pass from [0;255] to [-1;1], we divide by 127.5 (the middle of the range)

Copilot uses AI. Check for mistakes.
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