Skip to content

Conversation

@Erik-Lundell
Copy link
Collaborator

Add UnsquezeScalarPlaceholders pass to make scalars rank 1 Add MatchShapesPass to guarantee same rank for all inputs for ops that require it.
Additional fixes to make Scalar tests pass

Map which cases work and which don't.

Signed-off-by: Erik Lundell erik.lundell@arm.com
Change-Id: I4ea5e189e26cf7aff391ec153d525b2fb61aa16f

Fix shape issues

Change-Id: I0b8588cd5f8b284c25e806bb83bc788067d5b649

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 15, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 55fd7ab with merge base 8673567 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot facebook-github-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 Oct 15, 2024
@Erik-Lundell Erik-Lundell added partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk labels Oct 15, 2024

# If the argument is call_function, match shape by inserting view node.
if arg.op == "call_function":
self._match_op_shape(graph_module, node, arg, rank, max_rank, shape)
Copy link
Contributor

Choose a reason for hiding this comment

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

can't add/sub handle broadcasting in TOSA? This view will become a copy and I am not sure if we can do faster broadcasting than this. scalr to 1D makes sense I am talking about matching shape. Ok with following up on this later if you want to change that is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TOSA handles broadcasting but still requires that the input tensors share the same rank (see https://www.mlplatform.org/tosa/tosa_spec.html#_add). So the pass is actually badly named, should be match_rank. will update.

super().__init__()
self.exported_program = exported_program

targeted_ops = [
Copy link
Contributor

@digantdesai digantdesai Oct 15, 2024

Choose a reason for hiding this comment

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

other ops can't take scalar? curious why only these?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The pass might be relevant for other ops but the reasoning is to only target what we know we need and what we test. I.e. to limit the scope of the change.

@facebook-github-bot
Copy link
Contributor

@digantdesai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@digantdesai
Copy link
Contributor

Internal errors

executorch/backends/arm/_passes/match_shapes_pass.py:80:4 Inconsistent override [15]: executorch.backends.arm._passes.match_shapes_pass.MatchShapesPass.call overrides method defined in executorch.exir.pass_base._ExportPassBase inconsistently. Returned type torch.fx.graph_module.GraphModule is not a subtype of the overridden return torch.fx.passes.infra.pass_base.PassResult.

executorch/backends/arm/_passes/match_shapes_pass.py:113:8 Incompatible return type [7]: Expected GraphModule but got PassResult.

Add UnsquezeScalarPlaceholders pass to make scalars rank 1
Add MatchArgRanksPass to guarantee same rank for all inputs
for ops that require it.
Additional fixes to make Scalar tests pass

Map which cases work and which don't.

Signed-off-by: Erik Lundell <erik.lundell@arm.com>
Change-Id: I4ea5e189e26cf7aff391ec153d525b2fb61aa16f

Fix shape issues

Change-Id: I0b8588cd5f8b284c25e806bb83bc788067d5b649
@facebook-github-bot
Copy link
Contributor

@digantdesai has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@digantdesai merged this pull request in 6669e18.

@Erik-Lundell Erik-Lundell deleted the scalar_ops branch July 31, 2025 07:50
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. Merged 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.

3 participants