Skip to content

[Codegen] Use GPUPadLayoutAttr to resolve layouts. - #20565

Merged
hanhanW merged 5 commits into
iree-org:mainfrom
hanhanW:use-pad-layout-attr
Apr 21, 2025
Merged

hanhanW merged 5 commits into
iree-org:mainfrom
hanhanW:use-pad-layout-attr

Conversation

@hanhanW

@hanhanW hanhanW commented Apr 16, 2025 •

Copy link
Copy Markdown
Contributor

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

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]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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]>
@hanhanW

hanhanW commented Apr 16, 2025

Copy link
Copy Markdown
Contributor Author

The variable 'targetAttr' is re-declared in the else block, shadowing the outer 'targetAttr'. Consider renaming the inner variable to avoid potential confusion.

I thought that there would be a warning about it from clang/gcc, but the option seems to be off.

}
};

struct GPUPadDeviceEncodingLayoutAttrInterface final

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.

I am not sure where this is actually being used in this PR?

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.

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 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.

LGTM % the unused interface (?)

@hanhanW
hanhanW merged commit e5ca8ae into iree-org:main Apr 21, 2025
@hanhanW
hanhanW deleted the use-pad-layout-attr branch April 21, 2025 23:59
KyleHerndon pushed a commit to KyleHerndon/iree that referenced this pull request May 7, 2025
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]>
AWoloszyn pushed a commit that referenced this pull request Dec 1, 2025
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]>
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.

4 participants