Skip to content

Conversation

@YufengShi-dudu
Copy link
Collaborator

@YufengShi-dudu YufengShi-dudu commented Dec 16, 2025

Decompose aten.clamp.Tensor to a chain of minimum/maximum operations, since TOSA clamp only supports scalar min/max bounds.

This change:

  • Rename DecomposeInt32ClampPass to DecomposeTOSAUnsupportedClampPass
  • Extend the pass to handle aten.clamp.Tensor variants already annotated by ArmQuantizer
  • Mark aten.clamp.Tensor as supported in the TOSA operator support lists
  • Fix clamp decomposition to apply max with the lower bound, then min with the upper bound (y_i = min(max(x_i, min_i), max_i)), matching torch.clamp semantics even when min > max
  • Align the memory layout of lifted tensor constants in process_inputs_to_lifted_tensor_constants with the TOSA memory format

Change-Id: Iee52062599c1ef58421bc772a47b165646de435c

cc @freddan80 @per @zingo @oscarandersson8218 @digantdesai

@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 Dec 16, 2025
@pytorch-bot
Copy link

pytorch-bot bot commented Dec 16, 2025

🔗 Helpful Links

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

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

❌ 3 New Failures, 2 Unrelated Failures

As of commit f4183b4 with merge base df626bd (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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 Dec 16, 2025
Decompose aten.clamp.Tensor to a chain of minimum/maximum operations,
since TOSA clamp only supports scalar min/max bounds.

This change:
- Rename DecomposeInt32ClampPass to DecomposeTOSAUnsupportedClampPass
- Extend the pass to handle aten.clamp.Tensor variants already
  annotated by ArmQuantizer
- Mark aten.clamp.Tensor as supported in the TOSA operator support lists
- Fix clamp decomposition to apply max with the lower bound, then min
  with the upper bound (y_i = min(max(x_i, min_i), max_i)), matching
  torch.clamp semantics even when min > max

Change-Id: Iee52062599c1ef58421bc772a47b165646de435c
Signed-off-by: Yufeng Shi <yufeng.shi@arm.com>
Co-authored-by: Ryan O'Shea <ryan.oshea3@arm.com>
Co-authored-by: Oscar Andersson <oscar.andersson@arm.com>
@YufengShi-dudu
Copy link
Collaborator Author

Issues around lifted tensor constants have been fixed in this PR #16274

@zingo
Copy link
Collaborator

zingo commented Dec 16, 2025

This got a merge conflict in process_node.py and need a rebase.

@YufengShi-dudu YufengShi-dudu force-pushed the add-clamp-tensor-support branch from efb206b to a6182b2 Compare December 16, 2025 16:19
@zingo
Copy link
Collaborator

zingo commented Dec 17, 2025

Failed tests are unrelated

@zingo zingo merged commit 486b3a8 into pytorch:main Dec 17, 2025
507 of 529 checks passed
xingguo01 pushed a commit to xingguo01/executorch that referenced this pull request Dec 18, 2025
Decompose aten.clamp.Tensor to a chain of minimum/maximum operations,
since TOSA clamp only supports scalar min/max bounds.

This change:
- Rename DecomposeInt32ClampPass to DecomposeTOSAUnsupportedClampPass
- Extend the pass to handle aten.clamp.Tensor variants already annotated
by ArmQuantizer
- Mark aten.clamp.Tensor as supported in the TOSA operator support lists
- Fix clamp decomposition to apply max with the lower bound, then min
with the upper bound (y_i = min(max(x_i, min_i), max_i)), matching
torch.clamp semantics even when min > max
- Align the memory layout of lifted tensor constants in
process_inputs_to_lifted_tensor_constants with the TOSA memory format

Signed-off-by: Yufeng Shi <yufeng.shi@arm.com>
Co-authored-by: Ryan O'Shea <ryan.oshea3@arm.com>
Co-authored-by: Oscar Andersson <oscar.andersson@arm.com>
jirioc pushed a commit to nxp-upstream/executorch that referenced this pull request Dec 19, 2025
Decompose aten.clamp.Tensor to a chain of minimum/maximum operations,
since TOSA clamp only supports scalar min/max bounds.

This change:
- Rename DecomposeInt32ClampPass to DecomposeTOSAUnsupportedClampPass
- Extend the pass to handle aten.clamp.Tensor variants already annotated
by ArmQuantizer
- Mark aten.clamp.Tensor as supported in the TOSA operator support lists
- Fix clamp decomposition to apply max with the lower bound, then min
with the upper bound (y_i = min(max(x_i, min_i), max_i)), matching
torch.clamp semantics even when min > max
- Align the memory layout of lifted tensor constants in
process_inputs_to_lifted_tensor_constants with the TOSA memory format

Signed-off-by: Yufeng Shi <yufeng.shi@arm.com>
Co-authored-by: Ryan O'Shea <ryan.oshea3@arm.com>
Co-authored-by: Oscar Andersson <oscar.andersson@arm.com>
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.

2 participants