Skip to content

Cortex-M: remove extractScalarToInt helpers, use static_cast directly#17543

Merged
rascani merged 6 commits intopytorch:mainfrom
rascani:cortex-m-remove-extractscalar
Mar 5, 2026
Merged

Cortex-M: remove extractScalarToInt helpers, use static_cast directly#17543
rascani merged 6 commits intopytorch:mainfrom
rascani:cortex-m-remove-extractscalar

Conversation

@rascani
Copy link
Copy Markdown
Contributor

@rascani rascani commented Feb 18, 2026

Summary

Since #16322 changed all Scalar parameters to int64_t, the extractScalarToInt32 and extractScalarToInt helpers in cortex_m_ops_common.h are unnecessary indirection — they called Scalar::to<int64_t>() then cast, but the values are already int64_t.

Replace all call sites with direct static_cast and remove the helpers, the unused Scalar type alias, and the scalar_utils.h include. Also update the quantized_mul Python schema in operators.py to use int instead of Scalar, matching the C++ kernel and operators.yaml.

Additionally remove a duplicate kernel_includes.h include from cortex_m_ops_common.h.

Test plan

pytest backends/cortex_m/test/

cc @digantdesai @SS-JIA @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @psiddh @AdrianLundell

Since pytorch#16322 changed all Scalar parameters to int64_t, the
extractScalarToInt32 and extractScalarToInt helpers in
cortex_m_ops_common.h are unnecessary indirection — they called
Scalar::to<int64_t>() then cast, but the values are already int64_t.

Replace all call sites with direct static_cast and remove the helpers,
the unused Scalar type alias, and the scalar_utils.h include. Also
update the quantized_mul Python schema in operators.py to use int
instead of Scalar, matching the C++ kernel and operators.yaml.

Additionally remove a duplicate kernel_includes.h include from
cortex_m_ops_common.h.

Co-authored-by: Claude <noreply@anthropic.com>
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Feb 18, 2026

🔗 Helpful Links

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

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

❌ 2 New Failures, 8 Pending

As of commit 973ae3c with merge base 2cb1ef5 (image):

NEW FAILURES - The following jobs have failed:

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

@rascani rascani requested a review from psiddh February 18, 2026 23:16
@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 Feb 18, 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.

@rascani
Copy link
Copy Markdown
Contributor Author

rascani commented Feb 23, 2026

Bumping this.

@rascani rascani requested a review from mansnils February 23, 2026 18:48
@zingo zingo added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm module: microcontrollers For embedded MCUs like Cortex-M, or RTOS like Zephyr, does not track NPU backend like Arm Ethos. labels Mar 5, 2026
@rascani
Copy link
Copy Markdown
Contributor Author

rascani commented Mar 5, 2026

Failures unrelated.

@rascani rascani merged commit 584ef68 into pytorch:main Mar 5, 2026
311 of 317 checks passed
jpiat pushed a commit to jpiat/executorch that referenced this pull request Mar 17, 2026
…pytorch#17543)

### Summary
Since pytorch#16322 changed all Scalar parameters to int64_t, the
extractScalarToInt32 and extractScalarToInt helpers in
cortex_m_ops_common.h are unnecessary indirection — they called
Scalar::to<int64_t>() then cast, but the values are already int64_t.

Replace all call sites with direct static_cast and remove the helpers,
the unused Scalar type alias, and the scalar_utils.h include. Also
update the quantized_mul Python schema in operators.py to use int
instead of Scalar, matching the C++ kernel and operators.yaml.

Additionally remove a duplicate kernel_includes.h include from
cortex_m_ops_common.h.

### Test plan
```
pytest backends/cortex_m/test/
```

cc @digantdesai @SS-JIA @freddan80 @per @zingo @oscarandersson8218
@mansnils @Sebastian-Larsson @robell @psiddh @AdrianLundell

Co-authored-by: Claude <noreply@anthropic.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. module: microcontrollers For embedded MCUs like Cortex-M, or RTOS like Zephyr, does not track NPU backend like Arm Ethos. 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.

4 participants