Skip to content

Commit 88328d7

Browse files
committed
Implemnet ValueBound interface for the op
Signed-off-by: hanhanW <hanhan0912@gmail.com>
1 parent ec60229 commit 88328d7

5 files changed

Lines changed: 14 additions & 1 deletion

File tree

compiler/src/iree/compiler/Codegen/Dialect/VectorExt/IR/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ iree_td_library(
3838
"@llvm-project//mlir:InferTypeOpInterfaceTdFiles",
3939
"@llvm-project//mlir:OpBaseTdFiles",
4040
"@llvm-project//mlir:SideEffectInterfacesTdFiles",
41+
"@llvm-project//mlir:ValueBoundsOpInterfaceTdFiles",
4142
"@llvm-project//mlir:VectorInterfacesTdFiles",
4243
],
4344
)
@@ -82,6 +83,7 @@ iree_compiler_cc_library(
8283
"@llvm-project//mlir:SideEffectInterfaces",
8384
"@llvm-project//mlir:Support",
8485
"@llvm-project//mlir:TensorDialect",
86+
"@llvm-project//mlir:ValueBoundsOpInterface",
8587
"@llvm-project//mlir:VectorDialect",
8688
"@llvm-project//mlir:VectorInterfaces",
8789
],

compiler/src/iree/compiler/Codegen/Dialect/VectorExt/IR/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ iree_cc_library(
4545
MLIRSideEffectInterfaces
4646
MLIRSupport
4747
MLIRTensorDialect
48+
MLIRValueBoundsOpInterface
4849
MLIRVectorDialect
4950
MLIRVectorInterfaces
5051
iree::compiler::Codegen::Utils::VectorOpUtils

compiler/src/iree/compiler/Codegen/Dialect/VectorExt/IR/VectorExtDialect.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "mlir/IR/OpDefinition.h"
1515
#include "mlir/Interfaces/ControlFlowInterfaces.h"
1616
#include "mlir/Interfaces/SideEffectInterfaces.h"
17+
#include "mlir/Interfaces/ValueBoundsOpInterface.h"
1718
#include "mlir/Interfaces/VectorInterfaces.h"
1819

1920
// clang-format off: must be included after all LLVM/MLIR headers

compiler/src/iree/compiler/Codegen/Dialect/VectorExt/IR/VectorExtOps.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "mlir/Dialect/Vector/IR/VectorOps.h"
1212
#include "mlir/IR/Matchers.h"
1313
#include "mlir/IR/TypeUtilities.h"
14+
#include "mlir/Interfaces/ValueBoundsOpInterface.h"
1415

1516
using namespace mlir;
1617
using namespace mlir::iree_compiler::IREE::VectorExt;
@@ -26,6 +27,11 @@ LogicalResult ToLayoutOp::verify() {
2627
return getLayout().isValidLayout(getInput().getType(), getLoc());
2728
}
2829

30+
void ToLayoutOp::populateBoundsForShapedValueDim(
31+
Value value, int64_t dim, ValueBoundsConstraintSet &cstr) {
32+
cstr.bound(value)[dim] == cstr.getExpr(getInput(), dim);
33+
}
34+
2935
// to_simd -> to_simt
3036
OpFoldResult ToSIMDOp::fold(FoldAdaptor) {
3137
if (auto simtOp = getOperand().getDefiningOp<ToSIMTOp>()) {

compiler/src/iree/compiler/Codegen/Dialect/VectorExt/IR/VectorExtOps.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ include "iree/compiler/Codegen/Dialect/VectorExt/IR/VectorExtInterfaces.td"
1414
include "mlir/IR/OpBase.td"
1515
include "mlir/Interfaces/ControlFlowInterfaces.td"
1616
include "mlir/Interfaces/SideEffectInterfaces.td"
17+
include "mlir/Interfaces/ValueBoundsOpInterface.td"
1718

1819
//===----------------------------------------------------------------------===//
1920
// Base class.
@@ -29,7 +30,9 @@ class IREEVectorExt_PureOp<string mnemonic, list<Trait> traits = []> :
2930

3031
def IREEVectorExt_ToLayoutOp : IREEVectorExt_PureOp<"to_layout", [
3132
Pure,
32-
AllTypesMatch<["input", "output"]>
33+
AllTypesMatch<["input", "output"]>,
34+
DeclareOpInterfaceMethods<ValueBoundsOpInterface,
35+
["populateBoundsForShapedValueDim"]>
3336
]> {
3437
let summary = [{Layout conversion operator.}];
3538
let description = [{

0 commit comments

Comments
 (0)