-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][XeGPU] Add sg_map attribute to support Work Item level semantics #108864
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3e6301f
[MLIR][XeGPU] Add sg_map attribute
kurapov-peter 09376fc
fixup! [MLIR][XeGPU] Add sg_map attribute
kurapov-peter d11e4e4
Add create_tdesc with sg_map test
kurapov-peter 4ebec7a
Fix conflicts
kurapov-peter a35fdf2
Fix renaming
kurapov-peter 073bf67
Add fixes for desc type getters
kurapov-peter 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
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 |
---|---|---|
|
@@ -63,7 +63,7 @@ def XeGPU_TensorDesc: XeGPUTypeDef<"TensorDesc", "tensor_desc", | |
element-type ::= float-type | integer-type | index-type | ||
dim-list := (static-dim-list `x`)? | ||
static-dim-list ::= decimal-literal `x` decimal-literal | ||
attr-list = (, memory_space = value)? (, arr_len = value)? (, boundary_check = value)? (, scattered = value)? | ||
attr-list = (, memory_space = value)? (, arr_len = value)? (, boundary_check = value)? (, scattered = value)? (, sg_map `<` wi_layout = value, wi_data = value `>`)? | ||
``` | ||
|
||
Examples: | ||
|
@@ -77,25 +77,31 @@ def XeGPU_TensorDesc: XeGPUTypeDef<"TensorDesc", "tensor_desc", | |
|
||
// A TensorDesc with 8x16 f32 elements for a memory region in shared memory space. | ||
xegpu.tensor_desc<8x16xf32, #xegpu.tdesc_attr<memory_space = slm>> | ||
|
||
// A TensorDesc with a sg_map | ||
xegpu.tensor_desc<8x16xf32, #xegpu.sg_map<wi_layout = [1, 16], wi_data = [1, 1]>> | ||
``` | ||
}]; | ||
|
||
let parameters = (ins ArrayRefParameter<"int64_t">: $shape, | ||
"mlir::Type": $elementType, | ||
OptionalParameter<"mlir::Attribute">: $encoding); | ||
OptionalParameter<"mlir::Attribute">: $encoding, | ||
OptionalParameter<"mlir::Attribute">: $sg_map); | ||
|
||
let builders = [ | ||
TypeBuilderWithInferredContext<(ins | ||
"llvm::ArrayRef<int64_t>": $shape, | ||
"mlir::Type": $elementType, | ||
CArg<"int", "1">: $array_length, | ||
CArg<"bool", "true">: $boundary_check, | ||
CArg<"xegpu::MemorySpace", "xegpu::MemorySpace::Global">:$memory_space)>, | ||
CArg<"xegpu::MemorySpace", "xegpu::MemorySpace::Global">:$memory_space, | ||
CArg<"mlir::Attribute", "mlir::Attribute()">:$sg_map)>, | ||
Comment on lines
-93
to
+98
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. I had to slightly modify the signature since the new two conflict with default parameters (boundary check gets implicitly casted to memory space). I think it's better anyway. |
||
TypeBuilderWithInferredContext<(ins | ||
"llvm::ArrayRef<int64_t>": $shape, | ||
"mlir::Type": $elementType, | ||
CArg<"int", "1">: $chunk_size, | ||
CArg<"xegpu::MemorySpace", "xegpu::MemorySpace::Global">:$memory_space)> | ||
CArg<"xegpu::MemorySpace", "xegpu::MemorySpace::Global">:$memory_space, | ||
CArg<"mlir::Attribute", "mlir::Attribute()">:$sg_map)> | ||
]; | ||
|
||
let extraClassDeclaration = [{ | ||
|
@@ -121,6 +127,10 @@ def XeGPU_TensorDesc: XeGPUTypeDef<"TensorDesc", "tensor_desc", | |
return llvm::dyn_cast_if_present<ScatterTensorDescAttr>(getEncoding()); | ||
} | ||
|
||
SGMapAttr getSGMapAttr() const { | ||
return llvm::dyn_cast_if_present<SGMapAttr>(getSgMap()); | ||
} | ||
|
||
xegpu::MemorySpace getMemorySpace() const { | ||
auto block_attr = getEncodingAsBlockTensorDescAttr(); | ||
if (block_attr && block_attr.getMemorySpace()) | ||
|
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
Oops, something went wrong.
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.
Is it also available to scattered TensorDesc (created by create_tdesc), which has slightly different semantics to Blocked TensorDesc, the one created by create_nd_tdesc? If so, is there any restrictions on it?
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.
Yes, it produces the same type, so the map can (and should) be attached to the scattered variation. It works now but I'll add a test to cover it.
There are no additional restrictions on the layout; it only has to match the sub-group size. The data WI field represents the minimum requirement for the distribution (e.g., to cover packing). We may want to bind it to the chunk size somehow but I don't think it is necessary at the moment.