-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[mlir][xegpu] Add utilities for xegpu::sliceAttr
#157970
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
|
@@ -231,7 +231,55 @@ def DistributeLayoutAttr: AttrInterface<"DistributeLayoutAttr"> { | |
multiple blocks according to round-robin distribution rules.}], | ||
"FailureOr<SmallVector<SmallVector<Value>>>", | ||
"getOffsets", | ||
(ins "OpBuilder &": $builder, "Location":$loc, "Value":$linearId, "ArrayRef<int64_t>":$shape)> | ||
(ins "OpBuilder &": $builder, "Location":$loc, "Value":$linearId, "ArrayRef<int64_t>":$shape)>, | ||
InterfaceMethod</*desc=*/[{Check if this layout can be achieved by applying a transpose | ||
to some other layout according to given permutation of (0...n-1).}], | ||
/*retTy=*/"bool", | ||
/*methodName=*/"isTransposeOf", | ||
/*args=*/(ins "const xegpu::DistributeLayoutAttr&": $other, "ArrayRef<int64_t>": $perm), | ||
/*methodBody=*/[{ | ||
if (!other) | ||
return false; | ||
if ($_self.getRank() != other.getRank() || perm.size() != static_cast<size_t>($_self.getRank())) | ||
return false; | ||
// check if the permutation is valid | ||
int64_t rank = $_self.getRank(); | ||
SmallVector<bool, 8> seen(rank, false); | ||
for (const auto &ta : llvm::enumerate(perm)) { | ||
if (ta.value() < 0 || ta.value() >= rank) | ||
return false; | ||
if (seen[ta.value()]) | ||
return false; | ||
seen[ta.value()] = true; | ||
} | ||
auto checkTranspose = [](ArrayRef<int64_t> dst, ArrayRef<int64_t> src, ArrayRef<int64_t> perm) { | ||
for (const auto &ta : llvm::enumerate(perm)) { | ||
if (src[ta.index()] != dst[ta.value()]) | ||
return false; | ||
} | ||
return true; | ||
}; | ||
// check sgLayout | ||
if (!checkTranspose($_self.getSgLayoutAsInt(), other.getSgLayoutAsInt(), perm)) | ||
return false; | ||
// check sgData | ||
if (!checkTranspose($_self.getSgDataAsInt(), other.getSgDataAsInt(), perm)) | ||
return false; | ||
// check instData | ||
if (!checkTranspose($_self.getInstDataAsInt(), other.getInstDataAsInt(), perm)) | ||
return false; | ||
// check laneLayout | ||
if (!checkTranspose($_self.getLaneLayoutAsInt(), other.getLaneLayoutAsInt(), perm)) | ||
return false; | ||
// check laneData | ||
if (!checkTranspose($_self.getLaneDataAsInt(), other.getLaneDataAsInt(), perm)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. order attribute needs to be transposed. |
||
return false; | ||
return true; | ||
}]>, | ||
InterfaceMethod</*desc=*/[{Check if this layout is a slice of some other layout.}], | ||
/*retTy=*/"bool", | ||
/*methodName=*/"isSliceOf", | ||
/*args=*/(ins "const xegpu::DistributeLayoutAttr&": $other)> | ||
]; | ||
} | ||
|
||
|
@@ -433,6 +481,9 @@ def XeGPU_LayoutAttr : XeGPUAttr<"Layout", "layout", [DistributeLayoutAttr]> { | |
FailureOr<SmallVector<SmallVector<Value>>> | ||
getOffsets(OpBuilder &builder, Location loc, Value linearId, ArrayRef<int64_t> shape); | ||
|
||
/// Check if this is slice of some other layout. | ||
bool isSliceOf(const xegpu::DistributeLayoutAttr &other) { return false; } | ||
|
||
}]; | ||
|
||
let assemblyFormat = "`<` struct(params) `>`"; | ||
|
@@ -594,6 +645,9 @@ def XeGPU_SliceAttr : XeGPUAttr<"Slice", "slice", [DistributeLayoutAttr]> { | |
FailureOr<SmallVector<SmallVector<Value>>> | ||
getOffsets(OpBuilder &builder, Location loc, Value linearId, ArrayRef<int64_t> shape); | ||
|
||
/// Check if this is slice of some other layout. | ||
bool isSliceOf(const xegpu::DistributeLayoutAttr &other); | ||
|
||
}]; | ||
|
||
let assemblyFormat = "`<` qualified($parent) `,` `dims` `=` $dims `>`"; | ||
|
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.
As in the other PR - nit: could you move it to the source file too?
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.
Hi @adam-smnk , please ignore this PR. changes are already there with #155517