[Mlir-commits] [mlir] 4687822 - [mlir][Linalg] Add a roundtrip test for indexed_generic op with tensors.

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Feb 10 12:52:31 PST 2020


Author: Hanhan Wang
Date: 2020-02-10T15:51:59-05:00
New Revision: 4687822b9e8e25cac8e345d4a6b99f4e44324f76

URL: https://github.com/llvm/llvm-project/commit/4687822b9e8e25cac8e345d4a6b99f4e44324f76
DIFF: https://github.com/llvm/llvm-project/commit/4687822b9e8e25cac8e345d4a6b99f4e44324f76.diff

LOG: [mlir][Linalg] Add a roundtrip test for indexed_generic op with tensors.

Summary:
After D72555 has been landed, `linalg.indexed_generic` also accepts ranked
tensor as input and output. Add a test for it.

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

Added: 
    

Modified: 
    mlir/test/Dialect/Linalg/roundtrip.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/test/Dialect/Linalg/roundtrip.mlir b/mlir/test/Dialect/Linalg/roundtrip.mlir
index 1055e5fc151f..4b81dce48c8e 100644
--- a/mlir/test/Dialect/Linalg/roundtrip.mlir
+++ b/mlir/test/Dialect/Linalg/roundtrip.mlir
@@ -310,6 +310,41 @@ func @generic_with_tensor_input_and_output(
 
 // -----
 
+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)>
 


        


More information about the Mlir-commits mailing list