-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[mlir][linalg][nfc] Fix linalg.matmul_transpose_a
def.
#97690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JerryShih
wants to merge
1
commit into
llvm:main
Choose a base branch
from
JerryShih:dev/jerrys/matmul_transpose_a-def
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep the spec of
linalg.matmul_transpose_a
consistent with the other variants, this should be(s0, s2)
:llvm-project/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
Line 1412 in e975ff0
llvm-project/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
Line 1094 in e975ff0
Now, on line 1329, you'd want to change:
to:
As in, IIUC:
s0
-> M dims1
-> K dims2
-> N dimThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would
K
be in the middle?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm realising that
shape_map
!=indexing_maps
and that all my thinking was wrong. Sorry about the confusion.What's the intended use of
shape_map
? Is that required specifically for https://mlir.llvm.org/docs/Dialects/Linalg/OpDSL/?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The YAML is generated from OpDSL and then processed by tablegen to generate op definitions. We don't go from YAML to OpDSL so nothing there is required for that. Not clear about tablegen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
So this PR doesn't change the
indexing_maps
- these seem to be actually correct. Andshape_map
seem to be dropped when converting to tablegen. I guess this is only fixing OpDSL?@JerryShih How can we test/check/verify this change?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the input/output's affine_map doesn't used in mlir-linalg-ods-gen tool now. I just try to fix the weird declarion in
core_named_ops.py
.Sorry, I don't know how to test/verify this update. It's just try to fix the matrix dim name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be tested by manually writing an instance of
linalg.matmul_tranpose_a
taking tensors of certain fixed size (says M=10,N=20,K=30) and making sure it passes the verifier. Without this change, it wouldn't because the dimension sizes wouldn't match.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ftynse
There is already a
linalg.matmul_tranpose_a
test inside.llvm-project/mlir/test/Dialect/Linalg/named-ops.mlir
Lines 1193 to 1200 in ed4e75d
And this pr is "nfc" patch. It doesn't change the correctness of
linalg.matmul_tranpose_a
op.Here is the affine_map used in yaml op generator.
llvm-project/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
Line 834 in ed4e75d
It looks like only uses the affine_map in
indexing_maps
llvm-project/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
Lines 1099 to 1103 in 5fc7342
Use linalg.matmul as the example:
I don't see the op def which is related the affine_map in
args
parts.This pr only update the
args
parts which is not used in yaml generator.llvm-project/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
Lines 1079 to 1098 in 5fc7342
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is it used then? We need to find that place and add a test there. If there is no such place, we should drop this altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, we (Intel Labs) are working on a rewrite of matmul in table-gen, so that these variants are not relevant any more. They should continue here in case there's usage downstream, but hopefully they'll become unused soon, so we can remove them.
The new matmul will have the proposed optional affine map to encode transpose and broadcast on the
matmul
operations themselves. Anyone using them as before will not be impacted, anyone using*_matmul_transposed_*
can start using the new*_matmul { #transpose_map }
variants.@shahidact