Skip to content

Conversation

oscarandersson8218
Copy link
Collaborator

@oscarandersson8218 oscarandersson8218 commented Sep 30, 2025

Adds TOSA backend dialect op for MATMUL and associating pass to rewrite edge.aten.bmm to tosa.MATMUL.

cc @digantdesai @freddan80 @per @zingo

Copy link

pytorch-bot bot commented Sep 30, 2025

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 2 New Failures, 1 Cancelled Job, 1 Unrelated Failure

As of commit b52fed9 with merge base 400b2a5 (image):

NEW FAILURES - The following jobs have failed:

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

BROKEN TRUNK - The following job 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 Sep 30, 2025
@oscarandersson8218 oscarandersson8218 added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk release notes: none Do not include this in the release notes labels Sep 30, 2025
output_qparams.get_zp_per_tensor(),
)

def call(self, graph_module):
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 not do this in the aten.bmm node visitor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

aten.bmm is not a one-to-one mapping to TOSA.MATMUL due to TOSA outputting an INT32 for INT8 inputs while aten.bmm would output an INT8. So a rescale needs to be inserted and we're trying to avoid inserting rescales in multiple node visitors.

Copy link
Contributor

Choose a reason for hiding this comment

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

we're trying to avoid inserting rescales in multiple node visitor

Yeah I saw #14584

I called this out is because this pass feels a lot like bmm lowering which we have been doing through the node visitors.

"""

target = "aten.bmm.default"
target = "tosa.MATMUL.default"
Copy link
Contributor

@digantdesai digantdesai Oct 6, 2025

Choose a reason for hiding this comment

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

nit: perhaps we should rename this file a bit further to op_tosa_matmul.py and others, if any, just to distinguish from aten op target lowering?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good to me!

Adds TOSA backend dialect op for MATMUL and associating pass to rewrite
edge.aten.bmm to tosa.MATMUL. Also renames the files of node_visttor
that lowers a TOSA backend dialect op to op_tosa_*.py, e.g.
op_tosa_matmul.py.

Signed-off-by: Oscar Andersson <oscar.andersson@arm.com>
Change-Id: I578e5f7333922e02402dabc24ef1b12adf383b18
Signed-off-by: Oscar Andersson <oscar.andersson@arm.com>
Change-Id: Iaa2c17c2f2a984970a91022cad2c49fbb7f3202e
@zingo zingo merged commit 5a6113f into pytorch:main Oct 8, 2025
283 of 287 checks passed
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: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants