-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[mlir][linalg] Create a dedicated target for LinalgRelayoutInterface #127541
[mlir][linalg] Create a dedicated target for LinalgRelayoutInterface #127541
Conversation
For context and rationale, see: * llvm#127533
@llvm/pr-subscribers-mlir Author: Andrzej Warzyński (banach-space) ChangesFor context and rationale, see: Full diff: https://github.com/llvm/llvm-project/pull/127541.diff 6 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
index efd708c5e5a11..103d9dee43df5 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
@@ -72,6 +72,12 @@ add_public_tablegen_target(MLIRLinalgRelayoutOpsIncGen)
add_dependencies(MLIRLinalgRelayoutOpsIncGen LinalgOdsGen)
add_dependencies(mlir-headers MLIRLinalgRelayoutOpsIncGen)
+set(LLVM_TARGET_DEFINITIONS LinalgRelayoutInterface.td)
+mlir_tablegen(LinalgRelayoutInterface.h.inc -gen-op-interface-decls)
+mlir_tablegen(LinalgRelayoutInterface.cpp.inc -gen-op-interface-defs)
+add_public_tablegen_target(MLIRLinalgRelayoutInterfaceIncGen)
+add_dependencies(mlir-headers MLIRLinalgRelayoutInterfaceIncGen)
+
set(LLVM_TARGET_DEFINITIONS LinalgInterfaces.td)
mlir_tablegen(LinalgInterfaces.h.inc -gen-op-interface-decls)
mlir_tablegen(LinalgInterfaces.cpp.inc -gen-op-interface-defs)
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
index 6f1c243cc4396..530d6451b0a1e 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
@@ -221,4 +221,7 @@ LogicalResult verifyStructuredOpInterface(Operation *op);
/// Include the generated interface declarations.
#include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h.inc"
+/// Include the generated relayout interface declarations.
+#include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.h.inc"
+
#endif // MLIR_DIALECT_LINALG_IR_LINALGINTERFACES_H_
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
index 247afc141c180..dbc1ac60e0973 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
@@ -178,16 +178,6 @@ def LinalgConvolutionOpInterface : OpInterface<"ConvolutionOpInterface"> {
];
}
-def LinalgRelayoutOpInterface : OpInterface<"RelayoutOpInterface"> {
- let description = [{
- A Linalg relayout-op is either linalg.pack or linalg.unpack.
-
- While we could extend this interface with methods from Linalg_RelayoutOp,
- this is currently not needed and left as a TODO.
- }];
- let cppNamespace = "::mlir::linalg";
-}
-
def LinalgFillOpInterface : OpInterface<"FillOpInterface"> {
let description = [{
A fill operation is defined in general terms:
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td
new file mode 100644
index 0000000000000..0e925a6a832e0
--- /dev/null
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td
@@ -0,0 +1,25 @@
+//===- LinalgInterfaces.td - Linalg Interfaces Declaration -*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LINALG_IR_LINALGRELAYOUTINTERFACE
+#define LINALG_IR_LINALGRELAYOUTINTERFACE
+
+include "mlir/Interfaces/DestinationStyleOpInterface.td"
+include "mlir/IR/OpBase.td"
+
+def LinalgRelayoutOpInterface : OpInterface<"RelayoutOpInterface"> {
+ let description = [{
+ A Linalg relayout-op is either linalg.pack or linalg.unpack.
+
+ While we could extend this interface with methods from Linalg_RelayoutOp,
+ this is currently not needed and left as a TODO.
+ }];
+ let cppNamespace = "::mlir::linalg";
+}
+
+#endif // LINALG_IR_LINALGRELAYOUTINTERFACE
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td
index a08a778fc25e1..7743b8c00886f 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td
@@ -23,6 +23,7 @@ include "mlir/Interfaces/DestinationStyleOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Dialect/Linalg/IR/LinalgInterfaces.td"
+include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td"
include "mlir/IR/OpAsmInterface.td"
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
index e741144647043..7aad4611fbfaf 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
@@ -10,7 +10,7 @@
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
-#include "mlir/Dialect/Linalg/IR/Linalg.h"
+#include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.h.inc"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Tensor/Utils/Utils.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
|
@llvm/pr-subscribers-mlir-linalg Author: Andrzej Warzyński (banach-space) ChangesFor context and rationale, see: Full diff: https://github.com/llvm/llvm-project/pull/127541.diff 6 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
index efd708c5e5a11..103d9dee43df5 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
@@ -72,6 +72,12 @@ add_public_tablegen_target(MLIRLinalgRelayoutOpsIncGen)
add_dependencies(MLIRLinalgRelayoutOpsIncGen LinalgOdsGen)
add_dependencies(mlir-headers MLIRLinalgRelayoutOpsIncGen)
+set(LLVM_TARGET_DEFINITIONS LinalgRelayoutInterface.td)
+mlir_tablegen(LinalgRelayoutInterface.h.inc -gen-op-interface-decls)
+mlir_tablegen(LinalgRelayoutInterface.cpp.inc -gen-op-interface-defs)
+add_public_tablegen_target(MLIRLinalgRelayoutInterfaceIncGen)
+add_dependencies(mlir-headers MLIRLinalgRelayoutInterfaceIncGen)
+
set(LLVM_TARGET_DEFINITIONS LinalgInterfaces.td)
mlir_tablegen(LinalgInterfaces.h.inc -gen-op-interface-decls)
mlir_tablegen(LinalgInterfaces.cpp.inc -gen-op-interface-defs)
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
index 6f1c243cc4396..530d6451b0a1e 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
@@ -221,4 +221,7 @@ LogicalResult verifyStructuredOpInterface(Operation *op);
/// Include the generated interface declarations.
#include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h.inc"
+/// Include the generated relayout interface declarations.
+#include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.h.inc"
+
#endif // MLIR_DIALECT_LINALG_IR_LINALGINTERFACES_H_
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
index 247afc141c180..dbc1ac60e0973 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
@@ -178,16 +178,6 @@ def LinalgConvolutionOpInterface : OpInterface<"ConvolutionOpInterface"> {
];
}
-def LinalgRelayoutOpInterface : OpInterface<"RelayoutOpInterface"> {
- let description = [{
- A Linalg relayout-op is either linalg.pack or linalg.unpack.
-
- While we could extend this interface with methods from Linalg_RelayoutOp,
- this is currently not needed and left as a TODO.
- }];
- let cppNamespace = "::mlir::linalg";
-}
-
def LinalgFillOpInterface : OpInterface<"FillOpInterface"> {
let description = [{
A fill operation is defined in general terms:
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td
new file mode 100644
index 0000000000000..0e925a6a832e0
--- /dev/null
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td
@@ -0,0 +1,25 @@
+//===- LinalgInterfaces.td - Linalg Interfaces Declaration -*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LINALG_IR_LINALGRELAYOUTINTERFACE
+#define LINALG_IR_LINALGRELAYOUTINTERFACE
+
+include "mlir/Interfaces/DestinationStyleOpInterface.td"
+include "mlir/IR/OpBase.td"
+
+def LinalgRelayoutOpInterface : OpInterface<"RelayoutOpInterface"> {
+ let description = [{
+ A Linalg relayout-op is either linalg.pack or linalg.unpack.
+
+ While we could extend this interface with methods from Linalg_RelayoutOp,
+ this is currently not needed and left as a TODO.
+ }];
+ let cppNamespace = "::mlir::linalg";
+}
+
+#endif // LINALG_IR_LINALGRELAYOUTINTERFACE
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td
index a08a778fc25e1..7743b8c00886f 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td
@@ -23,6 +23,7 @@ include "mlir/Interfaces/DestinationStyleOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Dialect/Linalg/IR/LinalgInterfaces.td"
+include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td"
include "mlir/IR/OpAsmInterface.td"
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
index e741144647043..7aad4611fbfaf 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
@@ -10,7 +10,7 @@
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
-#include "mlir/Dialect/Linalg/IR/Linalg.h"
+#include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.h.inc"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Tensor/Utils/Utils.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
|
@llvm/pr-subscribers-mlir-tensor Author: Andrzej Warzyński (banach-space) ChangesFor context and rationale, see: Full diff: https://github.com/llvm/llvm-project/pull/127541.diff 6 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
index efd708c5e5a11..103d9dee43df5 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt
@@ -72,6 +72,12 @@ add_public_tablegen_target(MLIRLinalgRelayoutOpsIncGen)
add_dependencies(MLIRLinalgRelayoutOpsIncGen LinalgOdsGen)
add_dependencies(mlir-headers MLIRLinalgRelayoutOpsIncGen)
+set(LLVM_TARGET_DEFINITIONS LinalgRelayoutInterface.td)
+mlir_tablegen(LinalgRelayoutInterface.h.inc -gen-op-interface-decls)
+mlir_tablegen(LinalgRelayoutInterface.cpp.inc -gen-op-interface-defs)
+add_public_tablegen_target(MLIRLinalgRelayoutInterfaceIncGen)
+add_dependencies(mlir-headers MLIRLinalgRelayoutInterfaceIncGen)
+
set(LLVM_TARGET_DEFINITIONS LinalgInterfaces.td)
mlir_tablegen(LinalgInterfaces.h.inc -gen-op-interface-decls)
mlir_tablegen(LinalgInterfaces.cpp.inc -gen-op-interface-defs)
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
index 6f1c243cc4396..530d6451b0a1e 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
@@ -221,4 +221,7 @@ LogicalResult verifyStructuredOpInterface(Operation *op);
/// Include the generated interface declarations.
#include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h.inc"
+/// Include the generated relayout interface declarations.
+#include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.h.inc"
+
#endif // MLIR_DIALECT_LINALG_IR_LINALGINTERFACES_H_
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
index 247afc141c180..dbc1ac60e0973 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
@@ -178,16 +178,6 @@ def LinalgConvolutionOpInterface : OpInterface<"ConvolutionOpInterface"> {
];
}
-def LinalgRelayoutOpInterface : OpInterface<"RelayoutOpInterface"> {
- let description = [{
- A Linalg relayout-op is either linalg.pack or linalg.unpack.
-
- While we could extend this interface with methods from Linalg_RelayoutOp,
- this is currently not needed and left as a TODO.
- }];
- let cppNamespace = "::mlir::linalg";
-}
-
def LinalgFillOpInterface : OpInterface<"FillOpInterface"> {
let description = [{
A fill operation is defined in general terms:
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td
new file mode 100644
index 0000000000000..0e925a6a832e0
--- /dev/null
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td
@@ -0,0 +1,25 @@
+//===- LinalgInterfaces.td - Linalg Interfaces Declaration -*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LINALG_IR_LINALGRELAYOUTINTERFACE
+#define LINALG_IR_LINALGRELAYOUTINTERFACE
+
+include "mlir/Interfaces/DestinationStyleOpInterface.td"
+include "mlir/IR/OpBase.td"
+
+def LinalgRelayoutOpInterface : OpInterface<"RelayoutOpInterface"> {
+ let description = [{
+ A Linalg relayout-op is either linalg.pack or linalg.unpack.
+
+ While we could extend this interface with methods from Linalg_RelayoutOp,
+ this is currently not needed and left as a TODO.
+ }];
+ let cppNamespace = "::mlir::linalg";
+}
+
+#endif // LINALG_IR_LINALGRELAYOUTINTERFACE
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td
index a08a778fc25e1..7743b8c00886f 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td
@@ -23,6 +23,7 @@ include "mlir/Interfaces/DestinationStyleOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Dialect/Linalg/IR/LinalgInterfaces.td"
+include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td"
include "mlir/IR/OpAsmInterface.td"
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
index e741144647043..7aad4611fbfaf 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
@@ -10,7 +10,7 @@
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
-#include "mlir/Dialect/Linalg/IR/Linalg.h"
+#include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.h.inc"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/Dialect/Tensor/Utils/Utils.h"
#include "mlir/Dialect/Utils/IndexingUtils.h"
|
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.
Thanks! I think that solves @chsigg's problem.
@@ -10,7 +10,7 @@ | |||
#include "mlir/Dialect/Arith/IR/Arith.h" | |||
#include "mlir/Dialect/Arith/Utils/Utils.h" | |||
#include "mlir/Dialect/Complex/IR/Complex.h" | |||
#include "mlir/Dialect/Linalg/IR/Linalg.h" | |||
#include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.h.inc" |
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.
I would prefer not to include .inc
files from other dialects.
Let me try to create a separate bazel target for LinalgInterfaces.h, then we don't need any cmake changes and can include LinalgInterfaces.h instead.
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.
Agree, sorry I missed that.
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.
You shouldn't include a .h.inc, but you can create a include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.h"
that itself encapsulates and include the .h.inc.
See for example include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.h
, include/mlir/Dialect/GPU/IR/CompilationInterfaces.h
, or include/mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h
which implement this pattern.
#127544 works for bazel and only has some |
Let's go with your change, then. @banach-space I think we can close this one without merging, as it already worked with BAZEL for You can also keep this as a clean up, not necessarily related to @chsigg PR, but I agree we shouldn't include |
+1
+1
Yeah, I am a bit concerned about the dependency that we are working around here. I don't have a good solution yet, but this is a bit fragile and I'd like to improve it at some point. |
For context and rationale, see: