Skip to content

Commit 9d301ee

Browse files
committed
[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.
1 parent 6c331e5 commit 9d301ee

File tree

2 files changed

+52
-16
lines changed

2 files changed

+52
-16
lines changed

mlir/test/Dialect/SparseTensor/codegen.mlir

-16
Original file line numberDiff line numberDiff line change
@@ -826,19 +826,3 @@ func.func @sparse_new_coo_permute_no(%arg0: !llvm.ptr) -> tensor<?x?xf32, #CooPN
826826
%0 = sparse_tensor.new %arg0 : !llvm.ptr to tensor<?x?xf32, #CooPNo>
827827
return %0 : tensor<?x?xf32, #CooPNo>
828828
}
829-
830-
// CHECK-LABEL: func.func @test_tensor_dim_unranked
831-
// CHECK: tensor.dim
832-
func.func @test_tensor_dim_unranked(%arg0: tensor<*xf32>) -> index {
833-
%c = arith.constant 0 : index
834-
%0 = tensor.dim %arg0, %c : tensor<*xf32>
835-
return %0 : index
836-
}
837-
838-
// CHECK-LABEL: func.func @test_tensor_reshape_unranked
839-
// CHECK: tensor.reshape
840-
func.func @test_tensor_reshape_unranked(%src: tensor<*xf32>, %shape: tensor<1xi32>) -> tensor<?xf32> {
841-
%dst = tensor.reshape %src(%shape)
842-
: (tensor<*xf32>, tensor<1xi32>) -> tensor<?xf32>
843-
return %dst : tensor<?xf32>
844-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// RUN: mlir-opt %s --lower-sparse-ops-to-foreach --split-input-file | FileCheck %s
2+
3+
// CHECK-LABEL: func.func @test_tensor_dim_unranked
4+
// CHECK: tensor.dim
5+
func.func @test_tensor_dim_unranked(%arg0: tensor<*xf32>) -> index {
6+
%c = arith.constant 0 : index
7+
%0 = tensor.dim %arg0, %c : tensor<*xf32>
8+
return %0 : index
9+
}
10+
11+
// -----
12+
13+
#SparseVector = #sparse_tensor.encoding<{
14+
map = (d0) -> (d0 : compressed)
15+
}>
16+
17+
// CHECK-LABEL: func.func @test_no_constant_dim
18+
// CHECK: tensor.dim
19+
func.func @test_no_constant_dim(%arg0: tensor<?xf64, #SparseVector>, %arg1: index) -> index {
20+
%0 = tensor.dim %arg0, %arg1 : tensor<?xf64, #SparseVector>
21+
return %0 : index
22+
}
23+
24+
// -----
25+
26+
// CHECK-LABEL: func.func @test_tensor_dim_no_encoding
27+
// CHECK: tensor.dim
28+
func.func @test_tensor_dim_no_encoding(%arg0: tensor<?xf32>) -> index {
29+
%c = arith.constant 0 : index
30+
%0 = tensor.dim %arg0, %c : tensor<?xf32>
31+
return %0 : index
32+
}
33+
34+
// -----
35+
36+
// CHECK-LABEL: func.func @test_tensor_reshape_unranked
37+
// CHECK: tensor.reshape
38+
func.func @test_tensor_reshape_unranked(%src: tensor<*xf32>, %shape: tensor<1xi32>) -> tensor<?xf32> {
39+
%dst = tensor.reshape %src(%shape)
40+
: (tensor<*xf32>, tensor<1xi32>) -> tensor<?xf32>
41+
return %dst : tensor<?xf32>
42+
}
43+
44+
// -----
45+
46+
// CHECK-LABEL: func.func @test_tensor_reshape_no_encoding
47+
// CHECK: tensor.reshape
48+
func.func @test_tensor_reshape_no_encoding(%src: tensor<?x?xf32>, %shape: tensor<1xi32>) -> tensor<?xf32> {
49+
%dst = tensor.reshape %src(%shape)
50+
: (tensor<?x?xf32>, tensor<1xi32>) -> tensor<?xf32>
51+
return %dst : tensor<?xf32>
52+
}

0 commit comments

Comments
 (0)