[PATCH] D74267: [mlir][Linalg] Add a roundtrip test for indexed_generic op with tensors.
Han-Chung Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 7 16:41:08 PST 2020
hanchung created this revision.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini, arphaman.
Herald added a reviewer: nicolasvasilache.
Herald added a project: LLVM.
After D72555 <https://reviews.llvm.org/D72555> has been landed, `linalg.indexed_generic` also accepts ranked
tensor as input and output. Add a test for it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74267
Files:
mlir/test/Dialect/Linalg/roundtrip.mlir
Index: mlir/test/Dialect/Linalg/roundtrip.mlir
===================================================================
--- mlir/test/Dialect/Linalg/roundtrip.mlir
+++ mlir/test/Dialect/Linalg/roundtrip.mlir
@@ -310,6 +310,41 @@
// -----
+func @foo(%i: index, %j: index, %k: index, %0: vector<3x4xi4>, %1: f32) -> f32 {
+ %f0 = constant 0.0 : f32
+ return %f0 : f32
+}
+
+#accesses = [
+ affine_map<(i, j, k) -> (j, i)>,
+ affine_map<(i, j, k) -> (i, k, i + j)>
+]
+
+#trait2 = {
+ args_in = 2,
+ args_out = 1,
+ indexing_maps = #accesses,
+ iterator_types = ["parallel", "parallel", "parallel"],
+ fun = @foo,
+ library_call = "some_external_function_name_1"
+}
+
+func @indexed_generic_with_tensor_input_and_output(
+ %arg0: tensor<?x?xvector<3x4xi4>>, %arg1: tensor<?x?x?xf32>)
+ -> (tensor<?x?x?xf32>) {
+ %0 = linalg.indexed_generic #trait2 %arg0, %arg1 {foo = 1} :
+ tensor<?x?xvector<3x4xi4>>, tensor<?x?x?xf32> -> tensor<?x?x?xf32>
+ return %0 : tensor<?x?x?xf32>
+}
+// CHECK-LABEL: func @indexed_generic_with_tensor_input_and_output
+// CHECK: linalg.indexed_generic {args_in = 2 : i64, args_out = 1 : i64, fun = @foo,
+// CHECK-SAME: indexing_maps = [#{{.*}}, #{{.*}}], iterator_types = ["parallel", "parallel", "parallel"],
+// CHECK-SAME: library_call = "some_external_function_name_1"} %{{.*}}, %{{.*}} {foo = 1 : i64}:
+// CHECK-SAME: tensor<?x?xvector<3x4xi4>>, tensor<?x?x?xf32> -> tensor<?x?x?xf32>
+// CHECK: return {{.*}} : tensor<?x?x?xf32>
+
+// -----
+
// CHECK-DAG: #[[strided2D:.*]] = affine_map<(d0, d1)[s0, s1] -> (d0 * s1 + s0 + d1)>
// CHECK-DAG: #[[strided3D:.*]] = affine_map<(d0, d1, d2)[s0, s1, s2] -> (d0 * s1 + s0 + d1 * s2 + d2)>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74267.243318.patch
Type: text/x-patch
Size: 1722 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200208/ecdb0ec3/attachment.bin>
More information about the llvm-commits
mailing list