Skip to content

Qualcomm/op reciprocal#18220

Merged
abhinaykukkadapu merged 7 commits intopytorch:mainfrom
CodeLinaro:qualcomm/op_reciprocal
Mar 18, 2026
Merged

Qualcomm/op reciprocal#18220
abhinaykukkadapu merged 7 commits intopytorch:mainfrom
CodeLinaro:qualcomm/op_reciprocal

Conversation

@quic-boyuc
Copy link
Contributor

Qualcomm AI Engine Direct - Add Reciprocal Operator Support for QNN

Summary:

Add reciprocal operator builder plumbing (op_unary.py) and QNN constants for ElementWiseUnary reciprocal.
Add DecomposeReciprocal pass and wire it into Qualcomm annotation/export pipelines to rewrite aten.reciprocal.default into aten.div.Tensor(1, x) for backend compatibility.
Add reciprocal model coverage in Qualcomm delegate tests (floating-point and quantized) and update the QNN operator
support table in README.

Test plan

python backends/qualcomm/tests/test_qnn_delegate.py -k TestQNNQuantizedOperator.test_qnn_backend_reciprocal -s
$DEVICE_SERIAL -m SM8650 -b build-android/

- Add constant and enums for QNN ElementwiseUnary op
- Add op_builder for reciprocal op
- Add pass decompose reciprocal to div because HTP and GPU backend doesn't support reciprocal operation yet
- Add reciprocal decomposition in export transform
- Remove logic for inserting constant tensor (leverage lift constant pass)
- Rename Reciprocal Builder to Unary
- Remove redundant check for node.op=="call_function"
@pytorch-bot
Copy link

pytorch-bot bot commented Mar 17, 2026

🔗 Helpful Links

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

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

❌ 1 Awaiting Approval, 2 New Failures, 1 Cancelled Job, 2 Pending, 2 Unrelated Failures

As of commit 3af1b5e with merge base a81ef44 (image):

AWAITING APPROVAL - The following workflow needs approval before CI can run:

NEW FAILURES - The following jobs have failed:

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

FLAKY - The following jobs failed but were likely due to flakiness present 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 Mar 17, 2026
@github-actions
Copy link

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.


@register_node_visitor
class Unary(NodeVisitor):
target = ["aten.reciprocal.default"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, why do we have a pass that converts reciprocal to div and yet have a op builder for reciprocal?

Copy link
Contributor Author

@quic-boyuc quic-boyuc Mar 18, 2026

Choose a reason for hiding this comment

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

Hi @abhinaykukkadapu
Thanks for the question.
The op builder is targeting Qualcomm CPU backend (currently not supported)
We will disable the decomposition pass for CPU backend in future.



@register_node_visitor
class Unary(NodeVisitor):
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we intend to move all the unary ops under this class in future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we will move all unary ops into this NodeVisitor in future. (Will also do similar for elemetwise-binary ops)

@abhinaykukkadapu abhinaykukkadapu merged commit eb92cec into pytorch:main Mar 18, 2026
157 of 163 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants