-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[MLIR] Vector to XeGPU conversion: Use proper source variant for create_nd_tdesc op creation. #171216
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
silee2
wants to merge
8
commits into
llvm:main
Choose a base branch
from
silee2:updateVectorToXeGPU
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
[MLIR] Vector to XeGPU conversion: Use proper source variant for create_nd_tdesc op creation. #171216
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8b7161b
[MLIR] Vector to XeGPU conversion: Use proper source variant for
silee2 bc2f04a
Remove dead code.
silee2 50d9b9a
Merge remote-tracking branch 'origin/main' into updateVectorToXeGPU
silee2 cfd5087
Combine base addr and byte offset as adjusted base addr.
silee2 6837ee4
Address reviewer comments.
silee2 1047b52
Merge remote-tracking branch 'origin/main' into updateVectorToXeGPU
silee2 f43d5c8
[MLIR] Fix broken GPU integration tests targetting SYCL and LevelZero…
silee2 1f55241
Revert "[MLIR] Fix broken GPU integration tests targetting SYCL and L…
silee2 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,18 +102,47 @@ static xegpu::CreateNdDescOp createNdDescriptor(PatternRewriter &rewriter, | |
| xegpu::TensorDescType descType, | ||
| TypedValue<MemRefType> src) { | ||
| MemRefType srcTy = src.getType(); | ||
| assert(srcTy.isStrided() && "Expected strided memref type"); | ||
| auto [strides, offset] = srcTy.getStridesAndOffset(); | ||
| bool isStatic = true; | ||
|
|
||
| // Memref is dynamic if any of its shape, offset or strides is dynamic. | ||
| if (!srcTy.hasStaticShape()) { | ||
| isStatic = false; | ||
| } | ||
|
|
||
| if (offset == ShapedType::kDynamic) | ||
| isStatic = false; | ||
|
|
||
| for (auto stride : strides) { | ||
silee2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (stride == ShapedType::kDynamic) { | ||
| isStatic = false; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| xegpu::CreateNdDescOp ndDesc; | ||
| if (srcTy.hasStaticShape()) { | ||
| if (isStatic) { | ||
| ndDesc = xegpu::CreateNdDescOp::create(rewriter, loc, descType, src); | ||
| } else { | ||
| // In case of any dynamic shapes, source's shape and strides have to be | ||
| // In case of ranked dynamic memref, instead of passing on the memref, | ||
| // i64 base address, source's offset, shape and strides have to be | ||
| // explicitly provided. | ||
| auto meta = memref::ExtractStridedMetadataOp::create(rewriter, loc, src); | ||
| ndDesc = xegpu::CreateNdDescOp::create(rewriter, loc, descType, src, | ||
| meta.getConstifiedMixedSizes(), | ||
| meta.getConstifiedMixedStrides()); | ||
| auto baseAddrIndex = memref::ExtractAlignedPointerAsIndexOp::create( | ||
| rewriter, loc, meta.getBaseBuffer()); | ||
| auto baseAddrI64 = arith::IndexCastOp::create( | ||
| rewriter, loc, rewriter.getI64Type(), baseAddrIndex.getResult()); | ||
| // Strided metadata only provides 1D offset but create_nd_desc op expect | ||
| // offset match the rank of source memref. Add leading zeros if rank > 1. | ||
|
||
| SmallVector<OpFoldResult> fullOffsets; | ||
| for (unsigned i = 0; i < srcTy.getRank() - 1; ++i) { | ||
| fullOffsets.push_back(rewriter.getI64IntegerAttr(0)); | ||
| } | ||
| fullOffsets.push_back(meta.getConstifiedMixedOffset()); | ||
| ndDesc = xegpu::CreateNdDescOp::create( | ||
| rewriter, loc, descType, baseAddrI64, fullOffsets, | ||
| meta.getConstifiedMixedSizes(), meta.getConstifiedMixedStrides()); | ||
| } | ||
|
|
||
| return ndDesc; | ||
|
|
||
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
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
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.
nit: braces can be skipped
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.
Removed braces.