Repository navigation
[Codegen] Use GPUPadLayoutAttr to resolve layouts. - #20565
Conversation
Instead of using the nop layout resolver, the revision explicitly uses the GPUPadLayoutAttr to resolve all the layouts. If the resolver is present in an executable target, it is prioritized. It is a step towards to collapsing the MaterializeEncodingIntoPadding pass into the generic pass. The revision exposes a "hidden" dependency between padding layout resolver and nop layout resolver. Because the current type converter is not decoupled enough from data-tiling usage. Signed-off-by: hanhanW <[email protected]>
There was a problem hiding this comment.
Pull Request Overview
This PR updates the code generation flow to use GPUPadLayoutAttr for resolving tensor layouts instead of the nop layout resolver, as part of an effort to better consolidate layout materialization passes.
- Introduces a new GPUPadDeviceEncodingLayoutAttrInterface to handle device-specific encoding layout resolution.
- Refactors functions to accept a layoutAttr parameter to better support target-specific configurations and updates the dependency registry and target configuration retrieval in the padding materialization pass.
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| compiler/src/iree/compiler/Codegen/ExternalInterfaces/GPUEncodingExternalModels.cpp | Added GPUPadDeviceEncodingLayoutAttrInterface and attached it alongside GPUPadEncodingLayoutResolverAttrInterface. |
| compiler/src/iree/compiler/Codegen/Common/MaterializeEncodingIntoPadding.cpp | Modified pad layout retrieval functions, updated conversion routines, and incorporated target configuration handling for GPU targets. |
Files not reviewed (1)
- compiler/src/iree/compiler/Codegen/Common/test/materialize_encoding_into_padding.mlir: Language not supported
Comments suppressed due to low confidence (1)
compiler/src/iree/compiler/Codegen/Common/MaterializeEncodingIntoPadding.cpp:290
- The variable 'targetAttr' is re-declared in the else block, shadowing the outer 'targetAttr'. Consider renaming the inner variable to avoid potential confusion.
IREE::GPU::TargetAttr targetAttr = getCLGPUTarget(context);
Signed-off-by: hanhanW <[email protected]>
I thought that there would be a warning about it from clang/gcc, but the option seems to be off. |
| } | ||
| }; | ||
|
|
||
| struct GPUPadDeviceEncodingLayoutAttrInterface final |
There was a problem hiding this comment.
I am not sure where this is actually being used in this PR?
There was a problem hiding this comment.
They type converter takes LayoutAttrInterface that helps resolves the encoding types. Below is also a use in this PR.
layoutAttr = cast<IREE::Codegen::LayoutAttrInterface>(
resolverAttr.cloneWithSimplifiedConfig(targetConfig));Before the PR, the MaterializePadEncodingTypeConverter uses NOP layout attribute. With the implementation (i.e., lowerOp), we no longer (and we shouldn't) leverage it to NOP layout attribute. (The NOP one could be removed in the future. I created it for supporting other backends that do not use data-tiling/encoding. I need to revisit it.)
- MaterializePadEncodingTypeConverter(MLIRContext *ctx)
- : MaterializeEncodingTypeConverter(
- IREE::Codegen::EncodingNopLayoutAttr::get(ctx)) {
kuhar
left a comment
There was a problem hiding this comment.
LGTM % the unused interface (?)
…oding dialect) Signed-off-by: hanhanW <[email protected]>
Signed-off-by: hanhanW <[email protected]>
Instead of using the nop layout resolver, the revision explicitly uses the GPUPadLayoutAttr to resolve all the layouts. If the resolver is present in an executable target, it is prioritized. The revision exposes a "hidden" dependency between padding layout resolver and nop layout resolver. Because the current type converter is not decoupled enough from data-tiling usage. It is a step towards iree-org#20160 --------- Signed-off-by: hanhanW <[email protected]>
Instead of using the nop layout resolver, the revision explicitly uses the GPUPadLayoutAttr to resolve all the layouts. If the resolver is present in an executable target, it is prioritized. The revision exposes a "hidden" dependency between padding layout resolver and nop layout resolver. Because the current type converter is not decoupled enough from data-tiling usage. It is a step towards #20160 --------- Signed-off-by: hanhanW <[email protected]>
Instead of using the nop layout resolver, the revision explicitly uses the GPUPadLayoutAttr to resolve all the layouts. If the resolver is present in an executable target, it is prioritized.
The revision exposes a "hidden" dependency between padding layout resolver and nop layout resolver. Because the current type converter is not decoupled enough from data-tiling usage.
It is a step towards #20160