[Mlir-commits] [mlir] [mlir][sparse][test] Adjust tests for `LowerSparseOpsToForeach` (PR #110976)

Longsheng Mou llvmlistbot at llvm.org
Thu Oct 3 02:48:05 PDT 2024


https://github.com/CoTinker updated https://github.com/llvm/llvm-project/pull/110976

>From 9d301ee86d9835a22734bbc4765b3153c93b7408 Mon Sep 17 00:00:00 2001
From: Longsheng Mou <longshengmou at gmail.com>
Date: Thu, 3 Oct 2024 17:39:19 +0800
Subject: [PATCH] [mlir][sparse][test] Adjust tests for
 `LowerSparseOpsToForeach`

This PR relocates the tests added in #109435 to a new file named
`no_lowering.mlir` and adds some new tests.
---
 mlir/test/Dialect/SparseTensor/codegen.mlir   | 16 ------
 .../Dialect/SparseTensor/no_lowering.mlir     | 52 +++++++++++++++++++
 2 files changed, 52 insertions(+), 16 deletions(-)
 create mode 100644 mlir/test/Dialect/SparseTensor/no_lowering.mlir

diff --git a/mlir/test/Dialect/SparseTensor/codegen.mlir b/mlir/test/Dialect/SparseTensor/codegen.mlir
index df03d871ba3a3e..af78458f109329 100644
--- a/mlir/test/Dialect/SparseTensor/codegen.mlir
+++ b/mlir/test/Dialect/SparseTensor/codegen.mlir
@@ -826,19 +826,3 @@ func.func @sparse_new_coo_permute_no(%arg0: !llvm.ptr) -> tensor<?x?xf32, #CooPN
   %0 = sparse_tensor.new %arg0 : !llvm.ptr to tensor<?x?xf32, #CooPNo>
   return %0 : tensor<?x?xf32, #CooPNo>
 }
-
-// CHECK-LABEL: func.func @test_tensor_dim_unranked
-//       CHECK: tensor.dim
-func.func @test_tensor_dim_unranked(%arg0: tensor<*xf32>) -> index {
-  %c = arith.constant 0 : index
-  %0 = tensor.dim %arg0, %c : tensor<*xf32>
-  return %0 : index
-}
-
-// CHECK-LABEL: func.func @test_tensor_reshape_unranked
-//       CHECK: tensor.reshape
-func.func @test_tensor_reshape_unranked(%src: tensor<*xf32>, %shape: tensor<1xi32>) -> tensor<?xf32> {
-  %dst = tensor.reshape %src(%shape)
-         : (tensor<*xf32>, tensor<1xi32>) -> tensor<?xf32>
-  return %dst : tensor<?xf32>
-}
diff --git a/mlir/test/Dialect/SparseTensor/no_lowering.mlir b/mlir/test/Dialect/SparseTensor/no_lowering.mlir
new file mode 100644
index 00000000000000..859b3924105dc1
--- /dev/null
+++ b/mlir/test/Dialect/SparseTensor/no_lowering.mlir
@@ -0,0 +1,52 @@
+// RUN: mlir-opt %s --lower-sparse-ops-to-foreach --split-input-file | FileCheck %s
+
+// CHECK-LABEL: func.func @test_tensor_dim_unranked
+//       CHECK: tensor.dim
+func.func @test_tensor_dim_unranked(%arg0: tensor<*xf32>) -> index {
+  %c = arith.constant 0 : index
+  %0 = tensor.dim %arg0, %c : tensor<*xf32>
+  return %0 : index
+}
+
+// -----
+
+#SparseVector = #sparse_tensor.encoding<{
+  map = (d0) -> (d0 : compressed)
+}>
+
+// CHECK-LABEL: func.func @test_no_constant_dim
+//       CHECK: tensor.dim
+func.func @test_no_constant_dim(%arg0: tensor<?xf64, #SparseVector>, %arg1: index) -> index {
+  %0 = tensor.dim %arg0, %arg1 : tensor<?xf64, #SparseVector>
+  return %0 : index
+}
+
+// -----
+
+// CHECK-LABEL: func.func @test_tensor_dim_no_encoding
+//       CHECK: tensor.dim
+func.func @test_tensor_dim_no_encoding(%arg0: tensor<?xf32>) -> index {
+  %c = arith.constant 0 : index
+  %0 = tensor.dim %arg0, %c : tensor<?xf32>
+  return %0 : index
+}
+
+// -----
+
+// CHECK-LABEL: func.func @test_tensor_reshape_unranked
+//       CHECK: tensor.reshape
+func.func @test_tensor_reshape_unranked(%src: tensor<*xf32>, %shape: tensor<1xi32>) -> tensor<?xf32> {
+  %dst = tensor.reshape %src(%shape)
+         : (tensor<*xf32>, tensor<1xi32>) -> tensor<?xf32>
+  return %dst : tensor<?xf32>
+}
+
+// -----
+
+// CHECK-LABEL: func.func @test_tensor_reshape_no_encoding
+//       CHECK: tensor.reshape
+func.func @test_tensor_reshape_no_encoding(%src: tensor<?x?xf32>, %shape: tensor<1xi32>) -> tensor<?xf32> {
+  %dst = tensor.reshape %src(%shape)
+         : (tensor<?x?xf32>, tensor<1xi32>) -> tensor<?xf32>
+  return %dst : tensor<?xf32>
+}



More information about the Mlir-commits mailing list