Skip to content

Arm backend: Validate TOSA resize parameters#19757

Merged
rascani merged 1 commit into
pytorch:mainfrom
perheld:ph-validate-tosa-with-buck
May 26, 2026
Merged

Arm backend: Validate TOSA resize parameters#19757
rascani merged 1 commit into
pytorch:mainfrom
perheld:ph-validate-tosa-with-buck

Conversation

@perheld
Copy link
Copy Markdown
Collaborator

@perheld perheld commented May 25, 2026

Re-upload with BUCK changes.

Share TOSA RESIZE parameter validation between upsample support checks and fake RESIZE lowering so invalid nearest and bilinear resize parameters are rejected before delegation.

Change-Id: I57c267aca96d733879ae90329267e44adce399c6

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

Re-upload with BUCK changes.

Share TOSA RESIZE parameter validation between upsample support checks
and fake RESIZE lowering so invalid nearest and bilinear resize
parameters are rejected before delegation.

Signed-off-by: Per Held <per.held@arm.com>
Change-Id: I57c267aca96d733879ae90329267e44adce399c6
Copilot AI review requested due to automatic review settings May 25, 2026 12:15
@perheld perheld added the partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm label May 25, 2026
@perheld perheld requested a review from digantdesai as a code owner May 25, 2026 12:15
@perheld perheld added ciflow/trunk release notes: arm Changes to the ARM backend delegate labels May 25, 2026
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 25, 2026

🔗 Helpful Links

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

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

❌ 1 New Failure, 3 Unrelated Failures

As of commit fd3a3e7 with merge base ee4c90a (image):

NEW FAILURE - The following job has failed:

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 May 25, 2026
@github-actions github-actions Bot added the module: arm Issues related to arm backend label May 25, 2026
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 centralizes TOSA RESIZE parameter validation so upsample support checks and fake RESIZE lowering reject the same invalid nearest/bilinear resize cases before delegation.

Changes:

  • Adds shared RESIZE validation and output-shape calculation helpers.
  • Wires fake TOSA RESIZE and upsample operator support checks to the shared validation.
  • Adds tests for invalid 1/16 downscale and scale numerator limits, plus build target updates.

Reviewed changes

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

Show a summary per file
File Description
backends/arm/tosa/resize_utils.py Adds shared TOSA RESIZE validation and output size calculation utilities.
backends/arm/tosa/dialect/ops/resize.py Reuses shared validation and output-shape calculation in fake RESIZE.
backends/arm/operator_support/upsample_support.py Applies shared validation to nearest and bilinear upsample support checks.
backends/arm/tosa/BUCK Adds the resize_utils Python target.
backends/arm/tosa/dialect/BUCK Adds dependency on resize_utils.
backends/arm/operator_support/TARGETS Adds dependency on resize_utils.
backends/arm/test/ops/test_upsample_nearest2d.py Adds coverage for rejecting exact 1/16 nearest downscale delegation.
backends/arm/test/misc/tosa_dialect/test_tosa_resize.py Expands fake RESIZE validation tests for nearest/bilinear and numerator limits.
Comments suppressed due to low confidence (2)

backends/arm/tosa/resize_utils.py:85

  • When any scale component is symbolic, _validate_scale returns before checking the concrete components for positivity, numerator limits, ratio limits, or the downscale floor. A mixed symbolic scale with a concrete invalid denominator or numerator can therefore bypass validation and later either fail during fake shape calculation or emit invalid TOSA. Please validate the concrete elements independently and defer only comparisons that genuinely depend on symbolic values.
    scale_ints = _as_concrete_ints(scale)
    if scale_ints is None:
        return None

backends/arm/tosa/resize_utils.py:250

  • Returning as soon as scale_ints is None skips offset, border, and output-shape validation for mixed symbolic cases, even when one axis has fully concrete scale/offset/border values. This allows concrete invalid parameters on that axis to pass support checks and fake RESIZE validation. Consider validating each axis independently and only skipping the checks whose operands are symbolic.
    if scale_ints is None:
        return None

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

Comment thread backends/arm/tosa/resize_utils.py
Copy link
Copy Markdown
Collaborator

@zingo zingo left a comment

Choose a reason for hiding this comment

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

OK to merge, added file but buck2 files have been updated.

@perheld
Copy link
Copy Markdown
Collaborator Author

perheld commented May 25, 2026

@metascroy Hi! This is the revert of the revert but I have added buck things. Can you see if this works for your internal CI?

@perheld perheld added the help wanted Extra attention is needed label May 25, 2026
@perheld perheld requested a review from metascroy May 25, 2026 18:28
@rascani
Copy link
Copy Markdown
Contributor

rascani commented May 26, 2026

@metascroy Hi! This is the revert of the revert but I have added buck things. Can you see if this works for your internal CI?

I've kicked off an internal test run.

@rascani rascani self-requested a review May 26, 2026 15:54
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented May 26, 2026

@rascani has imported this pull request. If you are a Meta employee, you can view this in D106382504.

@rascani
Copy link
Copy Markdown
Contributor

rascani commented May 26, 2026

@metascroy Hi! This is the revert of the revert but I have added buck things. Can you see if this works for your internal CI?

I've kicked off an internal test run.

Looks good! Thanks for fixing that @perheld!

@rascani rascani merged commit cedfd48 into pytorch:main May 26, 2026
582 of 595 checks passed
@perheld perheld deleted the ph-validate-tosa-with-buck branch May 27, 2026 06:22
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. help wanted Extra attention is needed module: arm Issues related to arm backend 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