Skip to content

Commit 2c7dfb7

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 2c7dfb7

File tree

2 files changed

+54
-16
lines changed

2 files changed

+54
-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,54 @@
1+
// RUN: mlir-opt %s --lower-sparse-ops-to-foreach --split-input-file | FileCheck %s
2+
3+
// Ensure that we exit gracefully rather than crashing.
4+
5+
// CHECK-LABEL: func.func @test_tensor_dim_unranked
6+
// CHECK: tensor.dim
7+
func.func @test_tensor_dim_unranked(%arg0: tensor<*xf32>) -> index {
8+
%c = arith.constant 0 : index
9+
%0 = tensor.dim %arg0, %c : tensor<*xf32>
10+
return %0 : index
11+
}
12+
13+
// -----
14+
15+
#SparseVector = #sparse_tensor.encoding<{
16+
map = (d0) -> (d0 : compressed)
17+
}>
18+
19+
// CHECK-LABEL: func.func @test_no_constant_dim
20+
// CHECK: tensor.dim
21+
func.func @test_no_constant_dim(%arg0: tensor<?xf64, #SparseVector>, %arg1: index) -> index {
22+
%0 = tensor.dim %arg0, %arg1 : tensor<?xf64, #SparseVector>
23+
return %0 : index
24+
}
25+
26+
// -----
27+
28+
// CHECK-LABEL: func.func @test_tensor_dim_no_encoding
29+
// CHECK: tensor.dim
30+
func.func @test_tensor_dim_no_encoding(%arg0: tensor<?xf32>) -> index {
31+
%c = arith.constant 0 : index
32+
%0 = tensor.dim %arg0, %c : tensor<?xf32>
33+
return %0 : index
34+
}
35+
36+
// -----
37+
38+
// CHECK-LABEL: func.func @test_tensor_reshape_unranked
39+
// CHECK: tensor.reshape
40+
func.func @test_tensor_reshape_unranked(%src: tensor<*xf32>, %shape: tensor<1xi32>) -> tensor<?xf32> {
41+
%dst = tensor.reshape %src(%shape)
42+
: (tensor<*xf32>, tensor<1xi32>) -> tensor<?xf32>
43+
return %dst : tensor<?xf32>
44+
}
45+
46+
// -----
47+
48+
// CHECK-LABEL: func.func @test_tensor_reshape_no_encoding
49+
// CHECK: tensor.reshape
50+
func.func @test_tensor_reshape_no_encoding(%src: tensor<?x?xf32>, %shape: tensor<1xi32>) -> tensor<?xf32> {
51+
%dst = tensor.reshape %src(%shape)
52+
: (tensor<?x?xf32>, tensor<1xi32>) -> tensor<?xf32>
53+
return %dst : tensor<?xf32>
54+
}

0 commit comments

Comments
 (0)