[Mlir-commits] [mlir] [mlir][linalg] Create a dedicated target for LinalgRelayoutInterface (PR #127541)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Feb 17 12:19:40 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Andrzej WarzyĆski (banach-space)
<details>
<summary>Changes</summary>
For context and rationale, see:
* https://github.com/llvm/llvm-project/pull/127533
---
Full diff: https://github.com/llvm/llvm-project/pull/127541.diff
6 Files Affected:
- (modified) mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt (+6)
- (modified) mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h (+3)
- (modified) mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td (-10)
- (added) mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td (+25)
- (modified) mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td (+1)
- (modified) mlir/lib/Dialect/Tensor/IR/TensorOps.cpp (+1-1)
``````````diff
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"
``````````
</details>
https://github.com/llvm/llvm-project/pull/127541
More information about the Mlir-commits
mailing list