diff --git a/mlir/include/mlir/Interfaces/VectorInterfaces.td b/mlir/include/mlir/Interfaces/VectorInterfaces.td --- a/mlir/include/mlir/Interfaces/VectorInterfaces.td +++ b/mlir/include/mlir/Interfaces/VectorInterfaces.td @@ -107,7 +107,7 @@ InterfaceMethod< /*desc=*/"Return the permutation map.", /*retTy=*/"::mlir::AffineMap", - /*methodName=*/"permutation_map", + /*methodName=*/"getPermutationMap", /*args=*/(ins), /*methodBody=*/"return $_op.getPermutationMap();" /*defaultImplementation=*/ @@ -140,12 +140,17 @@ }] >, InterfaceMethod< - /*desc=*/"Return the `in_bounds` boolean ArrayAttr.", - /*retTy=*/"::std::optional<::mlir::ArrayAttr>", - /*methodName=*/"in_bounds", + /*desc=*/"Return a vector of all in_bounds values as booleans.", + /*retTy=*/"::llvm::SmallVector", + /*methodName=*/"getInBoundsValues", /*args=*/(ins), - /*methodBody=*/"return $_op.getInBounds();" - /*defaultImplementation=*/ + /*methodBody=*/"", + /*defaultImplementation=*/[{ + ::llvm::SmallVector inBounds; + for (int64_t i = 0, e = $_op.getTransferRank(); i < e; ++i) + inBounds.push_back($_op.isDimInBounds(i)); + return inBounds; + }] >, InterfaceMethod< /*desc=*/"Return the ShapedType.", diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp --- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp @@ -3481,18 +3481,10 @@ static void printTransferAttrs(OpAsmPrinter &p, VectorTransferOpInterface op) { SmallVector elidedAttrs; elidedAttrs.push_back(TransferReadOp::getOperandSegmentSizeAttr()); - if (op.permutation_map().isMinorIdentity()) + if (op.getPermutationMap().isMinorIdentity()) elidedAttrs.push_back(op.getPermutationMapAttrStrName()); - bool elideInBounds = true; - if (auto inBounds = op.in_bounds()) { - for (auto attr : *inBounds) { - if (llvm::cast(attr).getValue()) { - elideInBounds = false; - break; - } - } - } - if (elideInBounds) + // Elide in_bounds attribute if all dims are out-of-bounds. + if (llvm::none_of(op.getInBoundsValues(), [](bool b) { return b; })) elidedAttrs.push_back(op.getInBoundsAttrStrName()); p.printOptionalAttrDict(op->getAttrs(), elidedAttrs); } diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorTransferSplitRewritePatterns.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorTransferSplitRewritePatterns.cpp --- a/mlir/lib/Dialect/Vector/Transforms/VectorTransferSplitRewritePatterns.cpp +++ b/mlir/lib/Dialect/Vector/Transforms/VectorTransferSplitRewritePatterns.cpp @@ -42,7 +42,7 @@ /// is in-bounds. static Value createInBoundsCond(RewriterBase &b, VectorTransferOpInterface xferOp) { - assert(xferOp.permutation_map().isMinorIdentity() && + assert(xferOp.getPermutationMap().isMinorIdentity() && "Expected minor identity map"); Value inBoundsCond; xferOp.zipResultAndIndexing([&](int64_t resultIdx, int64_t indicesIdx) { @@ -105,7 +105,7 @@ /// where `alloc` is a top of the function alloca'ed buffer of one vector. /// /// Preconditions: -/// 1. `xferOp.permutation_map()` must be a minor identity map +/// 1. `xferOp.getPermutationMap()` must be a minor identity map /// 2. the rank of the `xferOp.memref()` and the rank of the `xferOp.vector()` /// must be equal. This will be relaxed in the future but requires /// rank-reducing subviews. @@ -116,7 +116,7 @@ return failure(); // TODO: expand support to these 2 cases. - if (!xferOp.permutation_map().isMinorIdentity()) + if (!xferOp.getPermutationMap().isMinorIdentity()) return failure(); // Must have some out-of-bounds dimension to be a candidate for splitting. if (!xferOp.hasOutOfBoundsDim()) @@ -512,7 +512,7 @@ /// where `alloc` is a top of the function alloca'ed buffer of one vector. /// /// Preconditions: -/// 1. `xferOp.permutation_map()` must be a minor identity map +/// 1. `xferOp.getPermutationMap()` must be a minor identity map /// 2. the rank of the `xferOp.source()` and the rank of the `xferOp.vector()` /// must be equal. This will be relaxed in the future but requires /// rank-reducing subviews.