Skip to content

[Codegen] Add matmul and batched matmul to list of ops to generalize#21720

Merged
newling merged 9 commits into
iree-org:mainfrom
newling:generalize_matmul
Aug 21, 2025
Merged

[Codegen] Add matmul and batched matmul to list of ops to generalize#21720
newling merged 9 commits into
iree-org:mainfrom
newling:generalize_matmul

Conversation

@newling

@newling newling commented Aug 16, 2025

Copy link
Copy Markdown
Contributor

Changes in this PR are

  1. carry 'compilation info' across from linalg.matmul (or other named op) to linalg.generic when running the generalize pass. See for example the test lowering_matmul_promotion.mlir

  2. Refactoring the SPIRV configuration selection. This now fails if a matmul/batch_matmul appears in specialized form.

  3. One nvidia test now uses a different pipeline. It matches earlier in the selection process for something more specialized. Looking at the history of the config selected, it looks like it used to choose a more specialised config anyway: https://github.com/iree-org/iree/blame/80af7ac6546a9d6975f2c5dbbb1d68e3c640565a/compiler/src/iree/compiler/Codegen/SPIRV/test/config_nvidia_matmul.mlir#L61

@kuhar kuhar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR includes a workaround option for SPIRV which still matches on MatMulOp

Could you open an issue for this and add it as a TODO in a code comment in this PR?

@newling

newling commented Aug 18, 2025

Copy link
Copy Markdown
Contributor Author

In light of #21344 it makes sense to do this properly (i.e. get rid of the flag for SPIRV to optionally not generalize matmul)... coming soon

@newling newling requested a review from ScottTodd as a code owner August 18, 2025 16:39
@newling newling force-pushed the generalize_matmul branch from 78d5278 to eb1aa2b Compare August 18, 2025 16:42
@ScottTodd ScottTodd removed their request for review August 18, 2025 16:47
Signed-off-by: James Newling <james.newling@gmail.com>
Signed-off-by: James Newling <james.newling@gmail.com>
@newling newling force-pushed the generalize_matmul branch from eb1aa2b to 21ee0d4 Compare August 18, 2025 16:59
Signed-off-by: James Newling <james.newling@gmail.com>
Signed-off-by: James Newling <james.newling@gmail.com>
Signed-off-by: James Newling <james.newling@gmail.com>
Signed-off-by: James Newling <james.newling@gmail.com>
Signed-off-by: James Newling <james.newling@gmail.com>
Comment thread compiler/src/iree/compiler/Codegen/Common/GPU/GPUGeneralizeNamedOps.cpp Outdated
Comment thread compiler/src/iree/compiler/Codegen/SPIRV/KernelConfig.cpp Outdated
Comment thread samples/transform_dialect/transform_library.mlir Outdated
Signed-off-by: James Newling <james.newling@gmail.com>
@newling newling force-pushed the generalize_matmul branch from 5764481 to 7e0daa7 Compare August 18, 2025 20:34
Signed-off-by: James Newling <james.newling@gmail.com>
@newling

newling commented Aug 19, 2025

Copy link
Copy Markdown
Contributor Author

@kuhar I think I've addressed your comments

@newling

newling commented Aug 21, 2025

Copy link
Copy Markdown
Contributor Author

ping

@newling newling merged commit 2c378d0 into iree-org:main Aug 21, 2025
44 checks passed
AWoloszyn pushed a commit that referenced this pull request Dec 1, 2025
…21720)

Changes in this PR are 

1) carry 'compilation info' across from linalg.matmul (or other named
op) to linalg.generic when running the generalize pass. See for example
the test `lowering_matmul_promotion.mlir`

2) Refactoring the SPIRV configuration selection. This now fails if a
matmul/batch_matmul appears in specialized form.

3) One nvidia test now uses a different pipeline. It matches earlier in
the selection process for something more specialized. Looking at the
history of the config selected, it looks like it used to choose a more
specialised config anyway:
https://github.com/iree-org/iree/blame/80af7ac6546a9d6975f2c5dbbb1d68e3c640565a/compiler/src/iree/compiler/Codegen/SPIRV/test/config_nvidia_matmul.mlir#L61

---------

Signed-off-by: James Newling <james.newling@gmail.com>
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