Skip to content

[LinalgExt] Add simple vectorization for map_scatter - #21090

Merged
Max191 merged 3 commits into
iree-org:mainfrom
Max191-agents:map-scatter-simple-vectorization
Jun 23, 2025
Merged

Max191 merged 3 commits into
iree-org:mainfrom
Max191-agents:map-scatter-simple-vectorization

Conversation

@Max191

@Max191 Max191 commented Jun 12, 2025

Copy link
Copy Markdown
Contributor

Allows vector types for the map_scatter input operand, and adds a trivial vectorization pass, which converts the input of map_scatter ops to vector operands with a vector.transfer_read.

This vectorization lowering is not complete, because the map_scatter op in this form will not be able to lower into other operations. The final lowering will happen as a decomposition after the map_scatter op has been both vectorized and bufferized, and the map_scatter op will be decomposed into a vector.scatter op. The reason this decomposition will need to happen after bufferization, is that the vector.scatter op requires a memref base. The decomposition pattern of the vectorized map_scatter will come as a follow-up PR.

Eventually, the vectorized map_scatter op could instead be decomposed into an iree_vector_ext.transfer_scatter op, but since the op does not exist yet, the current plan is to use vector.scatter first.

@Max191
Max191 force-pushed the map-scatter-simple-vectorization branch from ae583d0 to 7e69c57 Compare June 16, 2025 15:54
@Max191

Max191 commented Jun 17, 2025 •

Copy link
Copy Markdown
Contributor Author

Additional context for reviewers: #21116 has the remainder of the vector lowering for map_scatter. It is waiting on some upstream MLIR changes, so it is a draft for now.


def VectorizeIREELinalgExtOpsPass :
InterfacePass<"iree-linalg-ext-vectorize-ops", "mlir::FunctionOpInterface"> {
let summary = "Decompose and lower linalg_ext ops into vector operations.";

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.

The pass does not decompose LinalgExt ops, right? Is it more like turning LinalgExt ops to have vector semantics?

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.

Yes, good catch, thanks!

Comment on lines +27 to +29
if (isa<VectorType>(inputType)) {
return rewriter.notifyMatchFailure(mapScatterOp,
"map_scatter is already vectorized");
}

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.

Maybe we want a isVectorized() method in MapScatter op?

@Max191
Max191 force-pushed the map-scatter-simple-vectorization branch from 7e69c57 to e7cb8a0 Compare June 19, 2025 14:22
@Max191
Max191 requested a review from hanhanW June 19, 2025 14:22
Max191 added 3 commits June 23, 2025 14:35
Signed-off-by: Max Dawkins <[email protected]>
Signed-off-by: Max Dawkins <[email protected]>
@Max191
Max191 force-pushed the map-scatter-simple-vectorization branch from e7cb8a0 to 3c06001 Compare June 23, 2025 14:36
@Max191
Max191 merged commit 1d2db1a into iree-org:main Jun 23, 2025
@Max191
Max191 deleted the map-scatter-simple-vectorization branch June 23, 2025 18:09
AWoloszyn pushed a commit that referenced this pull request Dec 1, 2025
Allows vector types for the map_scatter input operand, and adds a
trivial vectorization pass, which converts the input of map_scatter ops
to vector operands with a vector.transfer_read.

This vectorization lowering is not complete, because the map_scatter op
in this form will not be able to lower into other operations. The final
lowering will happen as a decomposition after the map_scatter op has
been both vectorized and bufferized, and the map_scatter op will be
decomposed into a vector.scatter op. The reason this decomposition will
need to happen after bufferization, is that the vector.scatter op
requires a memref base. The decomposition pattern of the vectorized
map_scatter will come as a follow-up PR.

Eventually, the vectorized map_scatter op could instead be decomposed
into an `iree_vector_ext.transfer_scatter` op, but since the op does not
exist yet, the current plan is to use `vector.scatter` first.

---------

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