-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][DataLayout] Add IsolatedFromAbove
to DataLayoutOpInterface
#132742
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
Conversation
IsolatedFromAvobe
to the DataLayoutOpInterface
op.IsolatedFromAvobe
to DataLayoutOpInterface
|
IsolatedFromAvobe
to DataLayoutOpInterface
IsolatedFromAbove
to DataLayoutOpInterface
@llvm/pr-subscribers-mlir-gpu @llvm/pr-subscribers-mlir Author: Fabian Mora (fabianmcg) ChangesThis patch adds the The motivation behind this change comes from the implementation of the %f32_off = ptr.type_offset f32 : index
%addr = ptr.ptradd %ptr, %f32_off : !ptr, index
%x = ptr.load %addr : !ptr -> f32 // Read ptr[1] Without the op {DL1} {
%f32_off0 = ptr.type_offset f32 : index
op {DL2} {
%f32_off1 = ptr.type_offset f32 : index
}
} If The best solution to the above problem is to make Full diff: https://github.com/llvm/llvm-project/pull/132742.diff 3 Files Affected:
diff --git a/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td b/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
index 2b1ce573effd0..3241aff4b683c 100644
--- a/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
+++ b/mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
@@ -1388,7 +1388,7 @@ def GPU_BarrierOp : GPU_Op<"barrier"> {
}
def GPU_GPUModuleOp : GPU_Op<"module", [
- DataLayoutOpInterface, HasDefaultDLTIDataLayout, IsolatedFromAbove,
+ IsolatedFromAbove, DataLayoutOpInterface, HasDefaultDLTIDataLayout,
NoRegionArguments, SymbolTable, Symbol] # GraphRegionNoTerminator.traits> {
let summary = "A top level compilation unit containing code to be run on a GPU.";
let description = [{
diff --git a/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td b/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td
index 818b441b9a770..fc701b20cb007 100644
--- a/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td
+++ b/mlir/include/mlir/Interfaces/DataLayoutInterfaces.td
@@ -565,7 +565,7 @@ def DataLayoutOpInterface : OpInterface<"DataLayoutOpInterface"> {
}]
>
];
-
+ let dependentTraits = [IsolatedFromAbove];
let verify = [{ return ::mlir::detail::verifyDataLayoutOp($_op); }];
}
diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td
index 94c722038f1cc..f653e4465cfef 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -2555,7 +2555,7 @@ def MakeTupleOp: TEST_Op<"make_tuple"> {
//===----------------------------------------------------------------------===//
def OpWithDataLayoutOp : TEST_Op<"op_with_data_layout",
- [HasDefaultDLTIDataLayout, DataLayoutOpInterface]> {
+ [IsolatedFromAbove, HasDefaultDLTIDataLayout, DataLayoutOpInterface]> {
let summary =
"An op that uses DataLayout implementation from the Target dialect";
let regions = (region VariadicRegion<AnyRegion>:$regions);
|
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.
Having an SSA value crossing a boundary with a different data layout seems iffy indeed, but that brings the question of things like gpu.launch
right?
Indeed. IMO, I think it also exposes the need to have a clear documented divide between target dependent an independent ops. This divide would ideally also mean tighter verification constraints and the idea of target aware and independent passes. Where for example Under such system I would classify |
This makes sense to me. However, currently the DLTI attributes can occur on any op, also those not implementing @fabianmcg, if this is the case it might be worth opening an issue for it. |
This patch adds the
IsolatedFromAbove
trait as a dependent trait to theDataLayoutOpInterface
op interface.The motivation behind this change comes from the implementation of the
ptr
dialect, specifically theptr.type_offset
op. This op produces an int-like value that equates to the size of a memory element. This is useful for ptr arithmetic and indexing arrays. For example:Without the
IsolatedFromAvobe
trait in the DL interface, theptr.type_offset
cannot beConstantLike
. Why?Take the example:
If
ptr.type_offset
were to beConstantLike
thencanonicalize
would hoist and unique the value. However, that could be wrong as DL2 could have an entry to specify the size that's different from the size in DL1.The best solution to the above problem is to make
DataLayoutOpInterface
require theIsolatedFromAbove
trait, as it preserves the constness of values in the DL with respect to the canonicalizer.