[Mlir-commits] [mlir] 3e12cf2 - [mlir][tensor][NFC] TilingInterface: Use Attribute instead of Value

Matthias Springer llvmlistbot at llvm.org
Tue Jun 20 23:50:51 PDT 2023


Author: Matthias Springer
Date: 2023-06-21T08:47:50+02:00
New Revision: 3e12cf2a9ea8700835e0c6e27a68e37e58b39928

URL: https://github.com/llvm/llvm-project/commit/3e12cf2a9ea8700835e0c6e27a68e37e58b39928
DIFF: https://github.com/llvm/llvm-project/commit/3e12cf2a9ea8700835e0c6e27a68e37e58b39928.diff

LOG: [mlir][tensor][NFC] TilingInterface: Use Attribute instead of Value

Minor cleanup to take full advantage of OpFoldResult.

Differential Revision: https://reviews.llvm.org/D153341

Added: 
    

Modified: 
    mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
index c17afc77ad4cc..52ba083db160f 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
@@ -36,9 +36,8 @@ struct PadOpTiling : public TilingInterface::ExternalModel<PadOpTiling, PadOp> {
   SmallVector<Range> getIterationDomain(Operation *op, OpBuilder &b) const {
     ReifiedRankedShapedTypeDims reifiedShapes;
     (void)reifyResultShapes(b, op, reifiedShapes);
-    Location loc = op->getLoc();
-    Value zero = b.create<arith::ConstantIndexOp>(loc, 0);
-    Value one = b.create<arith::ConstantIndexOp>(loc, 1);
+    OpFoldResult zero = b.getIndexAttr(0);
+    OpFoldResult one = b.getIndexAttr(1);
     // Initialize all the ranges to {zero, one, one}. All the `ub`s are
     // overwritten.
     SmallVector<Range> loopRanges(reifiedShapes[0].size(), {zero, one, one});
@@ -76,11 +75,10 @@ static SmallVector<Range> getPackUnPackIterationDomain(OpTy op,
   static_assert(llvm::is_one_of<OpTy, PackOp, UnPackOp>::value,
                 "applies to only pack or unpack operations");
   OpBuilder::InsertionGuard g(builder);
-  Location loc = op.getLoc();
   int64_t rank = (std::is_same<OpTy, PackOp>::value) ? op.getSourceRank()
                                                      : op.getDestRank();
-  Value zero = builder.create<arith::ConstantIndexOp>(loc, 0);
-  Value one = builder.create<arith::ConstantIndexOp>(loc, 1);
+  OpFoldResult zero = builder.getIndexAttr(0);
+  OpFoldResult one = builder.getIndexAttr(1);
   ReifiedRankedShapedTypeDims resultShape;
   (void)reifyResultShapes(builder, op, resultShape);
   SmallVector<Range> loopBounds(rank);


        


More information about the Mlir-commits mailing list