[PATCH] D77964: [mlir][Linalg] NFC : Fix check for scalar case handling in LinalgToLoops
Mahesh Ravishankar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 11 23:25:44 PDT 2020
mravishankar updated this revision to Diff 256830.
mravishankar added a comment.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77964/new/
https://reviews.llvm.org/D77964
Files:
mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
mlir/test/Dialect/Linalg/loops.mlir
Index: mlir/test/Dialect/Linalg/loops.mlir
===================================================================
--- mlir/test/Dialect/Linalg/loops.mlir
+++ mlir/test/Dialect/Linalg/loops.mlir
@@ -913,3 +913,46 @@
// CHECKPARALLEL: %[[CONST:.*]] = constant 1.000000e+00 : f32
// CHECKPARALLEL: loop.parallel (%[[i:.*]])
// CHECKPARALLEL: store %[[CONST]], %[[ARG0]]
+
+#scalar_access = [
+ affine_map<() -> ()>,
+ affine_map<() -> ()>,
+ affine_map<() -> ()>
+]
+#scalar_trait = {
+ args_in = 2,
+ args_out = 1,
+ iterator_types = [],
+ indexing_maps = #scalar_access,
+ library_call = "some_external_fn"
+}
+func @scalar_code(%arg0: memref<f32>, %arg1 : memref<f32>, %arg2 : memref<f32>)
+{
+ linalg.generic #scalar_trait %arg0, %arg1, %arg2 {
+ ^bb(%a : f32, %b : f32, %c : f32) :
+ %0 = addf %a, %b : f32
+ linalg.yield %0 : f32
+ } : memref<f32>, memref<f32>, memref<f32>
+ return
+}
+// CHECKLOOP-LABEL: @scalar_code
+// CHECKLOOP-SAME: %[[ARG0]]: memref<f32>
+// CHECKLOOP-SAME: %[[ARG1]]: memref<f32>
+// CHECKLOOP-SAME: %[[ARG2]]: memref<f32>
+// CHECKLOOP-NOT: loop.for
+// CHECKLOOP-DAG: load %[[ARG0]][]
+// CHECKLOOP-DAG: load %[[ARG1]][]
+// CHECKLOOP-DAG: load %[[ARG2]][]
+// CHECKLOOP: addf
+// CHECKLOOP: store %{{.*}}, %[[ARG2]][]
+
+// CHECKPARALLEL-LABEL: @scalar_code
+// CHECKPARALLEL-SAME: %[[ARG0]]: memref<f32>
+// CHECKPARALLEL-SAME: %[[ARG1]]: memref<f32>
+// CHECKPARALLEL-SAME: %[[ARG2]]: memref<f32>
+// CHECKPARALLEL-NOT: loop.for
+// CHECKPARALLEL-DAG: load %[[ARG0]][]
+// CHECKPARALLEL-DAG: load %[[ARG1]][]
+// CHECKPARALLEL-DAG: load %[[ARG2]][]
+// CHECKPARALLEL: addf
+// CHECKPARALLEL: store %{{.*}}, %[[ARG2]][]
Index: mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
===================================================================
--- mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
+++ mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
@@ -652,8 +652,8 @@
linalgOp.indexing_maps().template getAsRange<AffineMapAttr>();
auto maps =
functional::map([](AffineMapAttr a) { return a.getValue(); }, mapsRange);
- auto invertedMap = inversePermutation(concatAffineMaps(maps));
- if (!invertedMap) {
+ AffineMap invertedMap = inversePermutation(concatAffineMaps(maps));
+ if (invertedMap.isEmpty()) {
LinalgScopedEmitter<IndexedValueTy, ConcreteOpTy>::emitScalarImplementation(
{}, linalgOp);
return LinalgLoops();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77964.256830.patch
Type: text/x-patch
Size: 2490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200412/87949688/attachment.bin>
More information about the llvm-commits
mailing list