[Mlir-commits] [mlir] [mlir][sparse][test] Adjust tests for `LowerSparseOpsToForeach` (PR #110976)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Oct 3 02:46:12 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-sparse
Author: Longsheng Mou (CoTinker)
<details>
<summary>Changes</summary>
This PR relocates the tests added in #<!-- -->109435 to a new file named `no_lowering.mlir`.
---
Full diff: https://github.com/llvm/llvm-project/pull/110976.diff
2 Files Affected:
- (modified) mlir/test/Dialect/SparseTensor/codegen.mlir (-16)
- (added) mlir/test/Dialect/SparseTensor/no_lowering.mlir (+52)
``````````diff
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>
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/110976
More information about the Mlir-commits
mailing list