Skip to content

[LinalgExt] Add decomposition for vector map_scatter - #21116

Merged
Max191 merged 6 commits into
iree-org:mainfrom
Max191-agents:map-scatter-vector-decomposition
Jul 14, 2025
Merged

Max191 merged 6 commits into
iree-org:mainfrom
Max191-agents:map-scatter-vector-decomposition

Conversation

@Max191

@Max191 Max191 commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

Adds a decomposition pass for iree_linalg_ext.map_scatter with a vector input and a memref output. The decomposition lowers the op into a series of vector ops to compute the index vector, and a vector.scatter op. This transformation completes the lowering of a vectorized map_scatter op.

The map_scatter op does not implement the AggregatedOpInterface, because the interface uses an OpBuilder to decompose operations, but the decomposition for map_scatter needs a RewriterBase, so it does not work with the current interface.

@Max191
Max191 requested a review from hanhanW June 23, 2025 14:26
@Max191
Max191 force-pushed the map-scatter-vector-decomposition branch from f700c8d to 2fe5b75 Compare July 8, 2025 20:50
@Max191
Max191 marked this pull request as ready for review July 8, 2025 20:50
@Max191
Max191 requested a review from MaheshRavishankar as a code owner July 8, 2025 20:50
Comment on lines +30 to +34
auto inputType = cast<VectorType>(mapScatterOp.getInputType());
if (!inputType.hasStaticShape()) {
return rewriter.notifyMatchFailure(mapScatterOp,
"expected static input shape");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doesn't VectorType always have static shape?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought it did, but I wasn't 100% sure if it's not legal to have dynamic shape, so I added the check to be safe. Maybe it is better as an assert instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can add an assertion, but it should always be static shape IIRC. The scalable flag is the other array of boolean.

@Max191 Max191 Jul 11, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, I removed the assert, because I found that dynamic shapes do not pass the verifier.

@Max191
Max191 force-pushed the map-scatter-vector-decomposition branch from 2fe5b75 to 42b5e2a Compare July 11, 2025 19:22
@Max191
Max191 enabled auto-merge (squash) July 11, 2025 19:27
@Max191
Max191 disabled auto-merge July 11, 2025 23:15
Max191 added 6 commits July 14, 2025 13:36
Signed-off-by: Max Dawkins <[email protected]>
Signed-off-by: Max Dawkins <[email protected]>
Signed-off-by: Max Dawkins <[email protected]>
Signed-off-by: Max Dawkins <[email protected]>
Signed-off-by: Max Dawkins <[email protected]>
@Max191
Max191 force-pushed the map-scatter-vector-decomposition branch from 99d3c13 to 758cbcb Compare July 14, 2025 13:36
@Max191
Max191 merged commit d58643d into iree-org:main Jul 14, 2025
@Max191
Max191 deleted the map-scatter-vector-decomposition branch July 14, 2025 14:42
AWoloszyn pushed a commit that referenced this pull request Dec 1, 2025
Adds a decomposition pass for `iree_linalg_ext.map_scatter` with a
vector input and a memref output. The decomposition lowers the op into a
series of vector ops to compute the index vector, and a vector.scatter
op. This transformation completes the lowering of a vectorized
map_scatter op.

The map_scatter op does not implement the `AggregatedOpInterface`,
because the interface uses an `OpBuilder` to decompose operations, but
the decomposition for map_scatter needs a `RewriterBase`, so it does not
work with the current interface.

---------

Signed-off-by: Max Dawkins <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants