[Mlir-commits] [mlir] 221fa96 - Fix linalg.generic access of hoisted constants
Ahmed Taei
llvmlistbot at llvm.org
Mon Mar 30 21:16:40 PDT 2020
Author: Ahmed Taei
Date: 2020-03-30T21:15:41-07:00
New Revision: 221fa96cd43cdcb3af5b03d814f38643874bd794
URL: https://github.com/llvm/llvm-project/commit/221fa96cd43cdcb3af5b03d814f38643874bd794
DIFF: https://github.com/llvm/llvm-project/commit/221fa96cd43cdcb3af5b03d814f38643874bd794.diff
LOG: Fix linalg.generic access of hoisted constants
Summary: Otherwise the added @generic_const_int will fail
Reviewers: nicolasvasilache, rriddle, mravishankar
Subscribers: mehdi_amini, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, grosul1, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77109
Added:
Modified:
mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
mlir/test/Dialect/Linalg/loops.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
index 971f1b0ca863..eb2a881308c4 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
@@ -101,7 +101,7 @@ static void inlineRegionAndEmitStdStore(OpType op,
assert(isa<YieldOp>(terminator) &&
"expected an yield op in the end of the region");
for (unsigned i = 0, e = terminator.getNumOperands(); i < e; ++i) {
- std_store(map.lookup(terminator.getOperand(i)), outputBuffers[i],
+ std_store(map.lookupOrDefault(terminator.getOperand(i)), outputBuffers[i],
indexing[i]);
}
}
diff --git a/mlir/test/Dialect/Linalg/loops.mlir b/mlir/test/Dialect/Linalg/loops.mlir
index b2cd61791d66..c8d114bee6ae 100644
--- a/mlir/test/Dialect/Linalg/loops.mlir
+++ b/mlir/test/Dialect/Linalg/loops.mlir
@@ -522,3 +522,24 @@ func @indexed_generic_op_1D_reduce(%arg0: memref<?xf32>,
// CHECK: %[[d:.*]] = select %{{.*}}, %[[b]], %[[c]]
// CHECK: %[[e:.*]] = addf %[[a]], %[[d]]
// CHECK: store %[[e]], %[[ARG2]][]
+
+#trait_const_fill = {
+ args_in = 0,
+ args_out = 1,
+ indexing_maps = [affine_map<(i) -> (i)>],
+ iterator_types = ["parallel"],
+ library_call = "some_external_fn"
+}
+func @generic_const_init(%arg0: memref<?xf32>) {
+ %cst = constant 1.0 : f32
+ linalg.generic #trait_const_fill %arg0 {
+ ^bb0(%arg1: f32): // no predecessors
+ linalg.yield %cst : f32
+ }: memref<?xf32>
+ return
+}
+// CHECK-LABEL: @generic_const_init
+// CHECK-SAME: %[[ARG0:.*]]: memref<?xf32>
+// CHECK: %[[CONST:.*]] = constant 1.000000e+00 : f32
+// CHECK: loop.for %[[i:.*]] = {{.*}}
+// CHECK: store %[[CONST]], %[[ARG0]]
More information about the Mlir-commits
mailing list