[PATCH] D76338: [mlir][Linalg] Use boolAttr in conditions instead of 1-bit integer.

Han-Chung Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 17 18:56:12 PDT 2020


hanchung created this revision.
hanchung added reviewers: mravishankar, nicolasvasilache.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a project: LLVM.

Although bool and int1 are the same sometimes, using bool constant matches the
semantic better.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76338

Files:
  mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp


Index: mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
===================================================================
--- mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
+++ mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
@@ -185,9 +185,10 @@
     if (!convOp.padding())
       return im(imIdx);
 
+    auto *context = ScopedContext::getContext();
     ValueHandle zeroIndex = std_constant_index(0);
     SmallVector<ValueHandle, 8> conds = {
-        std_constant_int(/*value=*/1, /*width=*/1)};
+        std_constant(BoolAttr::get(true, context))};
     SmallVector<ValueHandle, 8> clampedImIdx;
     for (auto iter : llvm::enumerate(imIdx)) {
       int idx = iter.index();
@@ -207,7 +208,6 @@
 
       // When padding is involed, the indices will only be shifted to negative,
       // so having a max op is enough.
-      auto *context = ScopedContext::getContext();
       auto maxMap = AffineMap::get(/*dimCount=*/1, 0,
                                    {getAffineDimExpr(/*position=*/0, context),
                                     getAffineConstantExpr(0, context)});


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76338.250958.patch
Type: text/x-patch
Size: 1101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200318/6de3ea53/attachment.bin>


More information about the llvm-commits mailing list