-
Notifications
You must be signed in to change notification settings - Fork 704
[Codegen][Tuner] merge the default td specs #20127
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
Conversation
5e55989
to
30e7c43
Compare
eeaefb0
to
668fad2
Compare
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 thoroughly test this code, we can start by assuming that tuning specs with default entypoints should always link, and then emitting warning whenever we notice they can't be linked. This is something we can test with verify-diagnostics
.
The way we usually do this in compilers is that we try to have two phases:
- Analysis that determines transformation legality
- Transformation that cannot bail out
compiler/plugins/target/ROCM/test/default_tuning_specs_amdgpu.mlir
Outdated
Show resolved
Hide resolved
compiler/plugins/target/ROCM/test/default_tuning_specs_amdgpu.mlir
Outdated
Show resolved
Hide resolved
compiler/plugins/target/ROCM/test/tuning_spec_mmt_tile_and_fuse.mlir
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
665cf37
to
0004cc1
Compare
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.
Leaving initial comments. Coming back to look at the big emitLinkedDefaultTuningSpec
later this morning.
compiler/plugins/target/ROCM/test/default_tuning_specs_amdgpu.mlir
Outdated
Show resolved
Hide resolved
compiler/plugins/target/ROCM/test/tuning_spec_mmt_tile_and_fuse.mlir
Outdated
Show resolved
Hide resolved
compiler/plugins/target/ROCM/test/default_tuning_specs_amdgpu.mlir
Outdated
Show resolved
Hide resolved
compiler/plugins/target/ROCM/test/default_tuning_specs_amdgpu.mlir
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
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.
High level question: Do we need to be checking for the default tuning spec attr before merging? This seems useful for non-default specs too, and it is already matching for an expected format of the nested modules.
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
Yes, I think it could be another todo item if we could use the attribute as a hint to simplify some implementations. CC @kuhar. |
@Max191 note that this checks for attributes that say that the tuning spec has a default entry point, not that it's a default spec in the compiler. A default spec is a spec with a default entrypoint that we decide to ship with the compiler. So to directly answer your question: yes, I think it makes sense to restrict this to a subset of transform scripts and also switch the tuner to use that format. |
I see, thanks for the clarification! |
Actually, followup question: Do we need the extra attribute on the module? We could just check that there is a named_sequence with Seems like it's just an extra hint for the linking pass that isn't really necessary to me. Am I missing something? |
We use it to trigger the attribute verifier over the whole module |
There's more than that: we also verify the entry point function signature (name and types) and expect a single foreach_match op in the body. And that there's exactly one entry point like that. |
I see, this is what I was missing, thanks!
Sorry, this is what I had meant (i.e., run the verification of the full module), but I see now that we have this attribute plumbed through in |
I've just submitted a commit addressing all of Max's comments. I'll follow up with another PR to add verification for |
ab6039e
to
f97aeda
Compare
I will further simplify this PR after #20173 is landed. |
You can rebase this PR on top of 20173 before it lands. This will make code review easier. |
f97aeda
to
a25cafd
Compare
e9351ef
to
8c50308
Compare
llvm::DenseMap<NamedSequenceOp, ForeachMatchOp> | ||
&namedSequenceToForeachMatch) { | ||
StringRef specName = op.getSymName(); | ||
std::string newSpecName = getUniqueSpecName(specName, specNameCounts); |
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'd like to avoid setting the suffix in one place just to forget it and try to recover this information in getBaseName
and update again in getUniqueSpecName
. This is bad design.
I'd rather do one of:
- only set it under a flag in
emitLinkedTuningSpec
and decide it in the code that does merging if it has different naming requirements - add a different name uniqing mode to
emitLinkedTuningSpec
to do the right thing for merging - update all names as a pre-processing steps that's common across both code paths (linking and merging)
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
Overall looks good, the only remaining issue I see is the way we handle names. |
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
…e and add test Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
8c50308
to
4aa2fff
Compare
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/test/link_tuning_specs.mlir
Outdated
Show resolved
Hide resolved
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
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.
Overall LGTM, please address the comments before landing, though.
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/LinkTuningSpecsPass.cpp
Outdated
Show resolved
Hide resolved
(Also wait for Jakub's review before landing) |
Signed-off-by: Bangtian Liu <liubangtian@gmail.com>
c3c599c
to
bb276c2
Compare
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.
LGTM
Please update the PR description before merging, this PR does not fix the issue:
You can replace this with |
This PR adds the implementation of merging all the default td specs (if all inner modules are) in the LinkTuningSpecsPass. It mainly merges multiple transform.foreach_match operations found across different inner modules into a single consolidated operation inside a newly created top-level
__kernel_config
NamedSequenceOp.Issue: nod-ai/shark-ai#810