Skip to content

Commit ead6574

Browse files
committed
[mlir][linalg] Create a dedicated target for LinalgRelayoutInterface
For context and rationale, see: * llvm#127533
1 parent 0d2722c commit ead6574

File tree

6 files changed

+36
-11
lines changed

6 files changed

+36
-11
lines changed

mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ add_public_tablegen_target(MLIRLinalgRelayoutOpsIncGen)
7272
add_dependencies(MLIRLinalgRelayoutOpsIncGen LinalgOdsGen)
7373
add_dependencies(mlir-headers MLIRLinalgRelayoutOpsIncGen)
7474

75+
set(LLVM_TARGET_DEFINITIONS LinalgRelayoutInterface.td)
76+
mlir_tablegen(LinalgRelayoutInterface.h.inc -gen-op-interface-decls)
77+
mlir_tablegen(LinalgRelayoutInterface.cpp.inc -gen-op-interface-defs)
78+
add_public_tablegen_target(MLIRLinalgRelayoutInterfaceIncGen)
79+
add_dependencies(mlir-headers MLIRLinalgRelayoutInterfaceIncGen)
80+
7581
set(LLVM_TARGET_DEFINITIONS LinalgInterfaces.td)
7682
mlir_tablegen(LinalgInterfaces.h.inc -gen-op-interface-decls)
7783
mlir_tablegen(LinalgInterfaces.cpp.inc -gen-op-interface-defs)

mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,7 @@ LogicalResult verifyStructuredOpInterface(Operation *op);
221221
/// Include the generated interface declarations.
222222
#include "mlir/Dialect/Linalg/IR/LinalgInterfaces.h.inc"
223223

224+
/// Include the generated relayout interface declarations.
225+
#include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.h.inc"
226+
224227
#endif // MLIR_DIALECT_LINALG_IR_LINALGINTERFACES_H_

mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,6 @@ def LinalgConvolutionOpInterface : OpInterface<"ConvolutionOpInterface"> {
178178
];
179179
}
180180

181-
def LinalgRelayoutOpInterface : OpInterface<"RelayoutOpInterface"> {
182-
let description = [{
183-
A Linalg relayout-op is either linalg.pack or linalg.unpack.
184-
185-
While we could extend this interface with methods from Linalg_RelayoutOp,
186-
this is currently not needed and left as a TODO.
187-
}];
188-
let cppNamespace = "::mlir::linalg";
189-
}
190-
191181
def LinalgFillOpInterface : OpInterface<"FillOpInterface"> {
192182
let description = [{
193183
A fill operation is defined in general terms:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===- LinalgInterfaces.td - Linalg Interfaces Declaration -*- tablegen -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LINALG_IR_LINALGRELAYOUTINTERFACE
10+
#define LINALG_IR_LINALGRELAYOUTINTERFACE
11+
12+
include "mlir/Interfaces/DestinationStyleOpInterface.td"
13+
include "mlir/IR/OpBase.td"
14+
15+
def LinalgRelayoutOpInterface : OpInterface<"RelayoutOpInterface"> {
16+
let description = [{
17+
A Linalg relayout-op is either linalg.pack or linalg.unpack.
18+
19+
While we could extend this interface with methods from Linalg_RelayoutOp,
20+
this is currently not needed and left as a TODO.
21+
}];
22+
let cppNamespace = "::mlir::linalg";
23+
}
24+
25+
#endif // LINALG_IR_LINALGRELAYOUTINTERFACE

mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ include "mlir/Interfaces/DestinationStyleOpInterface.td"
2323
include "mlir/Interfaces/SideEffectInterfaces.td"
2424
include "mlir/Interfaces/InferTypeOpInterface.td"
2525
include "mlir/Dialect/Linalg/IR/LinalgInterfaces.td"
26+
include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.td"
2627
include "mlir/IR/OpAsmInterface.td"
2728

2829
//===----------------------------------------------------------------------===//

mlir/lib/Dialect/Tensor/IR/TensorOps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "mlir/Dialect/Arith/IR/Arith.h"
1111
#include "mlir/Dialect/Arith/Utils/Utils.h"
1212
#include "mlir/Dialect/Complex/IR/Complex.h"
13-
#include "mlir/Dialect/Linalg/IR/Linalg.h"
13+
#include "mlir/Dialect/Linalg/IR/LinalgRelayoutInterface.h.inc"
1414
#include "mlir/Dialect/Tensor/IR/Tensor.h"
1515
#include "mlir/Dialect/Tensor/Utils/Utils.h"
1616
#include "mlir/Dialect/Utils/IndexingUtils.h"

0 commit comments

Comments
 (0)