// DEFINE: %{command} = mlir-opt %s --sparse-compiler=%{option} | \
// DEFINE: mlir-cpu-runner \
// DEFINE: -e entry -entry-point-result=void \
-// DEFINE: -shared-libs=%mlir_lib_dir/libmlir_c_runner_utils%shlibext | \
+// DEFINE: -shared-libs=%mlir_lib_dir/libmlir_c_runner_utils%shlibext,%mlir_lib_dir/libmlir_runner_utils%shlibext | \
// DEFINE: FileCheck %s
//
// RUN: %{command}
//
// Do the same run, but now with direct IR generation.
-// REDEFINE: %{option} = enable-runtime-library=false
+// REDEFINE: %{option} = "enable-runtime-library=false enable-buffer-initialization=true"
// RUN: %{command}
#MAT_C_C = #sparse_tensor.encoding<{dimLevelType = ["compressed", "compressed"]}>
}>
module {
+ func.func private @printMemrefF64(%ptr : tensor<*xf64>)
+ func.func private @printMemref1dF64(%ptr : memref<?xf64>) attributes { llvm.emit_c_interface }
+
//
// Tests without permutation.
//
}
func.func @dump_mat_9x4(%A: tensor<9x4xf64, #MAT_C_C>) {
- %c0 = arith.constant 0 : index
- %du = arith.constant -1.0 : f64
-
%c = sparse_tensor.convert %A : tensor<9x4xf64, #MAT_C_C> to tensor<9x4xf64>
- %v = vector.transfer_read %c[%c0, %c0], %du: tensor<9x4xf64>, vector<9x4xf64>
- vector.print %v : vector<9x4xf64>
+ %cu = tensor.cast %c : tensor<9x4xf64> to tensor<*xf64>
+ call @printMemrefF64(%cu) : (tensor<*xf64>) -> ()
%n = sparse_tensor.number_of_entries %A : tensor<9x4xf64, #MAT_C_C>
vector.print %n : index
%1 = sparse_tensor.values %A : tensor<9x4xf64, #MAT_C_C> to memref<?xf64>
- %2 = vector.transfer_read %1[%c0], %du: memref<?xf64>, vector<18xf64>
- vector.print %2 : vector<18xf64>
+ call @printMemref1dF64(%1) : (memref<?xf64>) -> ()
return
}
func.func @dump_mat_perm_9x4(%A: tensor<9x4xf64, #MAT_C_C_P>) {
- %c0 = arith.constant 0 : index
- %du = arith.constant -1.0 : f64
-
%c = sparse_tensor.convert %A : tensor<9x4xf64, #MAT_C_C_P> to tensor<9x4xf64>
- %v = vector.transfer_read %c[%c0, %c0], %du: tensor<9x4xf64>, vector<9x4xf64>
- vector.print %v : vector<9x4xf64>
+ %cu = tensor.cast %c : tensor<9x4xf64> to tensor<*xf64>
+ call @printMemrefF64(%cu) : (tensor<*xf64>) -> ()
%n = sparse_tensor.number_of_entries %A : tensor<9x4xf64, #MAT_C_C_P>
vector.print %n : index
%1 = sparse_tensor.values %A : tensor<9x4xf64, #MAT_C_C_P> to memref<?xf64>
- %2 = vector.transfer_read %1[%c0], %du: memref<?xf64>, vector<18xf64>
- vector.print %2 : vector<18xf64>
+ call @printMemref1dF64(%1) : (memref<?xf64>) -> ()
return
}
func.func @dump_mat_dense_9x4(%A: tensor<9x4xf64>) {
- %c0 = arith.constant 0 : index
- %du = arith.constant -1.0 : f64
-
- %v = vector.transfer_read %A[%c0, %c0], %du: tensor<9x4xf64>, vector<9x4xf64>
- vector.print %v : vector<9x4xf64>
+ %u = tensor.cast %A : tensor<9x4xf64> to tensor<*xf64>
+ call @printMemrefF64(%u) : (tensor<*xf64>) -> ()
return
}
func.func @dump_mat_annotated_dense_9x4(%A: tensor<9x4xf64, #MAT_D_D>) {
- %c0 = arith.constant 0 : index
- %du = arith.constant -1.0 : f64
-
%n = sparse_tensor.number_of_entries %A : tensor<9x4xf64, #MAT_D_D>
vector.print %n : index
%1 = sparse_tensor.values %A : tensor<9x4xf64, #MAT_D_D> to memref<?xf64>
- %2 = vector.transfer_read %1[%c0], %du: memref<?xf64>, vector<36xf64>
- vector.print %2 : vector<36xf64>
+ call @printMemref1dF64(%1) : (memref<?xf64>) -> ()
return
}
func.func @dump_mat_4x9(%A: tensor<4x9xf64, #MAT_C_C>) {
- %c0 = arith.constant 0 : index
- %du = arith.constant -1.0 : f64
-
%c = sparse_tensor.convert %A : tensor<4x9xf64, #MAT_C_C> to tensor<4x9xf64>
- %v = vector.transfer_read %c[%c0, %c0], %du: tensor<4x9xf64>, vector<4x9xf64>
- vector.print %v : vector<4x9xf64>
+ %cu = tensor.cast %c : tensor<4x9xf64> to tensor<*xf64>
+ call @printMemrefF64(%cu) : (tensor<*xf64>) -> ()
%n = sparse_tensor.number_of_entries %A : tensor<4x9xf64, #MAT_C_C>
vector.print %n : index
%1 = sparse_tensor.values %A : tensor<4x9xf64, #MAT_C_C> to memref<?xf64>
- %2 = vector.transfer_read %1[%c0], %du: memref<?xf64>, vector<18xf64>
- vector.print %2 : vector<18xf64>
+ call @printMemref1dF64(%1) : (memref<?xf64>) -> ()
return
}
func.func @dump_mat_dyn(%A: tensor<?x?xf64, #MAT_C_C>) {
- %c0 = arith.constant 0 : index
- %du = arith.constant -1.0 : f64
-
%c = sparse_tensor.convert %A : tensor<?x?xf64, #MAT_C_C> to tensor<?x?xf64>
- %v = vector.transfer_read %c[%c0, %c0], %du: tensor<?x?xf64>, vector<4x9xf64>
- vector.print %v : vector<4x9xf64>
+ %cu = tensor.cast %c : tensor<?x?xf64> to tensor<*xf64>
+ call @printMemrefF64(%cu) : (tensor<*xf64>) -> ()
%n = sparse_tensor.number_of_entries %A : tensor<?x?xf64, #MAT_C_C>
vector.print %n : index
%1 = sparse_tensor.values %A : tensor<?x?xf64, #MAT_C_C> to memref<?xf64>
- %2 = vector.transfer_read %1[%c0], %du: memref<?xf64>, vector<18xf64>
- vector.print %2 : vector<18xf64>
+ call @printMemref1dF64(%1) : (memref<?xf64>) -> ()
return
}
func.func @dump_mat_perm_4x9(%A: tensor<4x9xf64, #MAT_C_C_P>) {
- %c0 = arith.constant 0 : index
- %du = arith.constant -1.0 : f64
-
%c = sparse_tensor.convert %A : tensor<4x9xf64, #MAT_C_C_P> to tensor<4x9xf64>
- %v = vector.transfer_read %c[%c0, %c0], %du: tensor<4x9xf64>, vector<4x9xf64>
- vector.print %v : vector<4x9xf64>
+ %cu = tensor.cast %c : tensor<4x9xf64> to tensor<*xf64>
+ call @printMemrefF64(%cu) : (tensor<*xf64>) -> ()
%n = sparse_tensor.number_of_entries %A : tensor<4x9xf64, #MAT_C_C_P>
vector.print %n : index
%1 = sparse_tensor.values %A : tensor<4x9xf64, #MAT_C_C_P> to memref<?xf64>
- %2 = vector.transfer_read %1[%c0], %du: memref<?xf64>, vector<18xf64>
- vector.print %2 : vector<18xf64>
+ call @printMemref1dF64(%1) : (memref<?xf64>) -> ()
return
}
func.func @dump_mat_dense_4x9(%A: tensor<4x9xf64>) {
- %c0 = arith.constant 0 : index
- %du = arith.constant -1.0 : f64
-
- %v = vector.transfer_read %A[%c0, %c0], %du: tensor<4x9xf64>, vector<4x9xf64>
- vector.print %v : vector<4x9xf64>
+ %1 = tensor.cast %A : tensor<4x9xf64> to tensor<*xf64>
+ call @printMemrefF64(%1) : (tensor<*xf64>) -> ()
return
}
%sm43cd_dyn = sparse_tensor.convert %m43 : tensor<4x3xf64> to tensor<?x?xf64, #MAT_C_D>
%sm44dc_dyn = sparse_tensor.convert %m44 : tensor<4x4xf64> to tensor<?x?xf64, #MAT_D_C>
- // CHECK: ( ( 1, 0, 3, 0 ), ( 0, 2, 0, 0 ), ( 1, 0, 1, 1 ), ( 0, 0.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 0, 0, 1.5, 1 ), ( 0, 3.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 3, 0],
+ // CHECK-NEXT: [0, 2, 0, 0],
+ // CHECK-NEXT: [1, 0, 1, 1],
+ // CHECK-NEXT: [0, 0.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 1.5, 1],
+ // CHECK-NEXT: [0, 3.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [1, 0.5, 0, 0]]
// CHECK-NEXT: 18
- // CHECK-NEXT: ( 1, 3, 2, 1, 1, 1, 0.5, 1, 5, 2, 1.5, 1, 3.5, 1, 5, 2, 1, 0.5 )
+ // CHECK: [1, 3, 2, 1, 1, 1, 0.5, 1, 5, 2, 1.5, 1, 3.5, 1, 5, 2, 1, 0.5
%0 = call @concat_sparse_sparse(%sm24cc, %sm34cd, %sm44dc)
: (tensor<2x4xf64, #MAT_C_C>, tensor<3x4xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C>) -> tensor<9x4xf64, #MAT_C_C>
call @dump_mat_9x4(%0) : (tensor<9x4xf64, #MAT_C_C>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 3, 0 ), ( 0, 2, 0, 0 ), ( 1, 0, 1, 1 ), ( 0, 0.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 0, 0, 1.5, 1 ), ( 0, 3.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 3, 0],
+ // CHECK-NEXT: [0, 2, 0, 0],
+ // CHECK-NEXT: [1, 0, 1, 1],
+ // CHECK-NEXT: [0, 0.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 1.5, 1],
+ // CHECK-NEXT: [0, 3.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [1, 0.5, 0, 0]]
%1 = call @concat_sparse_dense(%sm24cc, %sm34cd, %sm44dc)
: (tensor<2x4xf64, #MAT_C_C>, tensor<3x4xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C>) -> tensor<9x4xf64>
call @dump_mat_dense_9x4(%1) : (tensor<9x4xf64>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 3, 0 ), ( 0, 2, 0, 0 ), ( 1, 0, 1, 1 ), ( 0, 0.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 0, 0, 1.5, 1 ), ( 0, 3.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 3, 0],
+ // CHECK-NEXT: [0, 2, 0, 0],
+ // CHECK-NEXT: [1, 0, 1, 1],
+ // CHECK-NEXT: [0, 0.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 1.5, 1],
+ // CHECK-NEXT: [0, 3.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [1, 0.5, 0, 0]]
// CHECK-NEXT: 18
- // CHECK-NEXT: ( 1, 3, 2, 1, 1, 1, 0.5, 1, 5, 2, 1.5, 1, 3.5, 1, 5, 2, 1, 0.5 )
+ // CHECK: [1, 3, 2, 1, 1, 1, 0.5, 1, 5, 2, 1.5, 1, 3.5, 1, 5, 2, 1, 0.5
%2 = call @concat_mix_sparse(%m24, %sm34cd, %sm44dc)
: (tensor<2x4xf64>, tensor<3x4xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C>) -> tensor<9x4xf64, #MAT_C_C>
call @dump_mat_9x4(%2) : (tensor<9x4xf64, #MAT_C_C>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 3, 0 ), ( 0, 2, 0, 0 ), ( 1, 0, 1, 1 ), ( 0, 0.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 0, 0, 1.5, 1 ), ( 0, 3.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 3, 0],
+ // CHECK-NEXT: [0, 2, 0, 0],
+ // CHECK-NEXT: [1, 0, 1, 1],
+ // CHECK-NEXT: [0, 0.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 1.5, 1],
+ // CHECK-NEXT: [0, 3.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [1, 0.5, 0, 0]]
%3 = call @concat_mix_dense(%m24, %sm34cd, %sm44dc)
: (tensor<2x4xf64>, tensor<3x4xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C>) -> tensor<9x4xf64>
call @dump_mat_dense_9x4(%3) : (tensor<9x4xf64>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 3, 0 ), ( 0, 2, 0, 0 ), ( 1, 0, 1, 1 ), ( 0, 0.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 0, 0, 1.5, 1 ), ( 0, 3.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 3, 0],
+ // CHECK-NEXT: [0, 2, 0, 0],
+ // CHECK-NEXT: [1, 0, 1, 1],
+ // CHECK-NEXT: [0, 0.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 1.5, 1],
+ // CHECK-NEXT: [0, 3.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [1, 0.5, 0, 0]]
// CHECK-NEXT: 18
- // CHECK-NEXT: ( 1, 1, 1, 1, 1, 2, 0.5, 5, 3.5, 5, 0.5, 3, 1, 2, 1.5, 2, 1, 1 )
+ // CHECK: [1, 1, 1, 1, 1, 2, 0.5, 5, 3.5, 5, 0.5, 3, 1, 2, 1.5, 2, 1, 1
%4 = call @concat_sparse_sparse_perm(%sm24ccp, %sm34cd, %sm44dc)
: (tensor<2x4xf64, #MAT_C_C_P>, tensor<3x4xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C>) -> tensor<9x4xf64, #MAT_C_C_P>
call @dump_mat_perm_9x4(%4) : (tensor<9x4xf64, #MAT_C_C_P>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 3, 0 ), ( 0, 2, 0, 0 ), ( 1, 0, 1, 1 ), ( 0, 0.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 0, 0, 1.5, 1 ), ( 0, 3.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 3, 0],
+ // CHECK-NEXT: [0, 2, 0, 0],
+ // CHECK-NEXT: [1, 0, 1, 1],
+ // CHECK-NEXT: [0, 0.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 1.5, 1],
+ // CHECK-NEXT: [0, 3.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [1, 0.5, 0, 0]]
%5 = call @concat_sparse_dense_perm(%sm24ccp, %sm34cdp, %sm44dc)
: (tensor<2x4xf64, #MAT_C_C_P>, tensor<3x4xf64, #MAT_C_D_P>, tensor<4x4xf64, #MAT_D_C>) -> tensor<9x4xf64>
call @dump_mat_dense_9x4(%5) : (tensor<9x4xf64>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 3, 0 ), ( 0, 2, 0, 0 ), ( 1, 0, 1, 1 ), ( 0, 0.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 0, 0, 1.5, 1 ), ( 0, 3.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 3, 0],
+ // CHECK-NEXT: [0, 2, 0, 0],
+ // CHECK-NEXT: [1, 0, 1, 1],
+ // CHECK-NEXT: [0, 0.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 1.5, 1],
+ // CHECK-NEXT: [0, 3.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [1, 0.5, 0, 0]]
// CHECK-NEXT: 18
- // CHECK-NEXT: ( 1, 3, 2, 1, 1, 1, 0.5, 1, 5, 2, 1.5, 1, 3.5, 1, 5, 2, 1, 0.5 )
+ // CHECK: [1, 3, 2, 1, 1, 1, 0.5, 1, 5, 2, 1.5, 1, 3.5, 1, 5, 2, 1, 0.5
%6 = call @concat_mix_sparse_perm(%m24, %sm34cdp, %sm44dc)
: (tensor<2x4xf64>, tensor<3x4xf64, #MAT_C_D_P>, tensor<4x4xf64, #MAT_D_C>) -> tensor<9x4xf64, #MAT_C_C>
call @dump_mat_9x4(%6) : (tensor<9x4xf64, #MAT_C_C>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 3, 0 ), ( 0, 2, 0, 0 ), ( 1, 0, 1, 1 ), ( 0, 0.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 0, 0, 1.5, 1 ), ( 0, 3.5, 0, 0 ), ( 1, 5, 2, 0 ), ( 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 3, 0],
+ // CHECK-NEXT: [0, 2, 0, 0],
+ // CHECK-NEXT: [1, 0, 1, 1],
+ // CHECK-NEXT: [0, 0.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 1.5, 1],
+ // CHECK-NEXT: [0, 3.5, 0, 0],
+ // CHECK-NEXT: [1, 5, 2, 0],
+ // CHECK-NEXT: [1, 0.5, 0, 0]]
%7 = call @concat_mix_dense_perm(%m24, %sm34cd, %sm44dcp)
: (tensor<2x4xf64>, tensor<3x4xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C_P>) -> tensor<9x4xf64>
call @dump_mat_dense_9x4(%7) : (tensor<9x4xf64>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 1, 0, 1, 0, 0, 1.5, 1 ), ( 3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0 ), ( 0, 2, 0, 0, 1, 1, 5, 2, 0 ), ( 0, 0, 5, 2, 0, 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 1, 0, 1, 0, 0, 1.5, 1],
+ // CHECK-NEXT: [3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0],
+ // CHECK-NEXT: [0, 2, 0, 0, 1, 1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 5, 2, 0, 1, 0.5, 0, 0]]
// CHECK-NEXT: 18
- // CHECK-NEXT: ( 1, 1, 1, 1.5, 1, 3.1, 1, 0.5, 3.5, 2, 1, 1, 5, 2, 5, 2, 1, 0.5 )
+ // CHECK: [1, 1, 1, 1.5, 1, 3.1, 1, 0.5, 3.5, 2, 1, 1, 5, 2, 5, 2, 1, 0.5
%8 = call @concat_sparse_sparse_dim1(%sm42cc, %sm43cd, %sm44dc)
: (tensor<4x2xf64, #MAT_C_C>, tensor<4x3xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C>) -> tensor<4x9xf64, #MAT_C_C>
call @dump_mat_4x9(%8) : (tensor<4x9xf64, #MAT_C_C>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 1, 0, 1, 0, 0, 1.5, 1 ), ( 3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0 ), ( 0, 2, 0, 0, 1, 1, 5, 2, 0 ), ( 0, 0, 5, 2, 0, 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 1, 0, 1, 0, 0, 1.5, 1],
+ // CHECK-NEXT: [3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0],
+ // CHECK-NEXT: [0, 2, 0, 0, 1, 1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 5, 2, 0, 1, 0.5, 0, 0]]
%9 = call @concat_sparse_dense_dim1(%sm42cc, %sm43cd, %sm44dc)
: (tensor<4x2xf64, #MAT_C_C>, tensor<4x3xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C>) -> tensor<4x9xf64>
call @dump_mat_dense_4x9(%9) : (tensor<4x9xf64>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 1, 0, 1, 0, 0, 1.5, 1 ), ( 3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0 ), ( 0, 2, 0, 0, 1, 1, 5, 2, 0 ), ( 0, 0, 5, 2, 0, 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 1, 0, 1, 0, 0, 1.5, 1],
+ // CHECK-NEXT: [3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0],
+ // CHECK-NEXT: [0, 2, 0, 0, 1, 1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 5, 2, 0, 1, 0.5, 0, 0]]
// CHECK-NEXT: 18
- // CHECK-NEXT: ( 1, 1, 1, 1.5, 1, 3.1, 1, 0.5, 3.5, 2, 1, 1, 5, 2, 5, 2, 1, 0.5 )
+ // CHECK: [1, 1, 1, 1.5, 1, 3.1, 1, 0.5, 3.5, 2, 1, 1, 5, 2, 5, 2, 1, 0.5
%10 = call @concat_mix_sparse_dim1(%m42, %sm43cd, %sm44dc)
: (tensor<4x2xf64>, tensor<4x3xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C>) -> tensor<4x9xf64, #MAT_C_C>
call @dump_mat_4x9(%10) : (tensor<4x9xf64, #MAT_C_C>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 1, 0, 1, 0, 0, 1.5, 1 ), ( 3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0 ), ( 0, 2, 0, 0, 1, 1, 5, 2, 0 ), ( 0, 0, 5, 2, 0, 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 1, 0, 1, 0, 0, 1.5, 1],
+ // CHECK-NEXT: [3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0],
+ // CHECK-NEXT: [0, 2, 0, 0, 1, 1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 5, 2, 0, 1, 0.5, 0, 0]]
%11 = call @concat_mix_dense_dim1(%m42, %sm43cd, %sm44dc)
: (tensor<4x2xf64>, tensor<4x3xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C>) -> tensor<4x9xf64>
call @dump_mat_dense_4x9(%11) : (tensor<4x9xf64>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 1, 0, 1, 0, 0, 1.5, 1 ), ( 3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0 ), ( 0, 2, 0, 0, 1, 1, 5, 2, 0 ), ( 0, 0, 5, 2, 0, 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 1, 0, 1, 0, 0, 1.5, 1],
+ // CHECK-NEXT: [3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0],
+ // CHECK-NEXT: [0, 2, 0, 0, 1, 1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 5, 2, 0, 1, 0.5, 0, 0]]
// CHECK-NEXT: 18
- // CHECK-NEXT: ( 1, 3.1, 2, 1, 1, 5, 2, 1, 0.5, 1, 1, 1, 3.5, 5, 0.5, 1.5, 2, 1 )
+ // CHECK: [1, 3.1, 2, 1, 1, 5, 2, 1, 0.5, 1, 1, 1, 3.5, 5, 0.5, 1.5, 2, 1
%12 = call @concat_sparse_sparse_perm_dim1(%sm42ccp, %sm43cd, %sm44dc)
: (tensor<4x2xf64, #MAT_C_C_P>, tensor<4x3xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C>) -> tensor<4x9xf64, #MAT_C_C_P>
call @dump_mat_perm_4x9(%12) : (tensor<4x9xf64, #MAT_C_C_P>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 1, 0, 1, 0, 0, 1.5, 1 ), ( 3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0 ), ( 0, 2, 0, 0, 1, 1, 5, 2, 0 ), ( 0, 0, 5, 2, 0, 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 1, 0, 1, 0, 0, 1.5, 1],
+ // CHECK-NEXT: [3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0],
+ // CHECK-NEXT: [0, 2, 0, 0, 1, 1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 5, 2, 0, 1, 0.5, 0, 0]]
%13 = call @concat_sparse_dense_perm_dim1(%sm42ccp, %sm43cdp, %sm44dc)
: (tensor<4x2xf64, #MAT_C_C_P>, tensor<4x3xf64, #MAT_C_D_P>, tensor<4x4xf64, #MAT_D_C>) -> tensor<4x9xf64>
call @dump_mat_dense_4x9(%13) : (tensor<4x9xf64>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 1, 0, 1, 0, 0, 1.5, 1 ), ( 3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0 ), ( 0, 2, 0, 0, 1, 1, 5, 2, 0 ), ( 0, 0, 5, 2, 0, 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 1, 0, 1, 0, 0, 1.5, 1],
+ // CHECK-NEXT: [3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0],
+ // CHECK-NEXT: [0, 2, 0, 0, 1, 1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 5, 2, 0, 1, 0.5, 0, 0]]
// CHECK-NEXT: 18
- // CHECK-NEXT: ( 1, 1, 1, 1.5, 1, 3.1, 1, 0.5, 3.5, 2, 1, 1, 5, 2, 5, 2, 1, 0.5 )
+ // CHECK: [1, 1, 1, 1.5, 1, 3.1, 1, 0.5, 3.5, 2, 1, 1, 5, 2, 5, 2, 1, 0.5
%14 = call @concat_mix_sparse_perm_dim1(%m42, %sm43cdp, %sm44dc)
: (tensor<4x2xf64>, tensor<4x3xf64, #MAT_C_D_P>, tensor<4x4xf64, #MAT_D_C>) -> tensor<4x9xf64, #MAT_C_C>
call @dump_mat_4x9(%14) : (tensor<4x9xf64, #MAT_C_C>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 1, 0, 1, 0, 0, 1.5, 1 ), ( 3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0 ), ( 0, 2, 0, 0, 1, 1, 5, 2, 0 ), ( 0, 0, 5, 2, 0, 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 1, 0, 1, 0, 0, 1.5, 1],
+ // CHECK-NEXT: [3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0],
+ // CHECK-NEXT: [0, 2, 0, 0, 1, 1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 5, 2, 0, 1, 0.5, 0, 0]]
%15 = call @concat_mix_dense_perm_dim1(%m42, %sm43cd, %sm44dcp)
: (tensor<4x2xf64>, tensor<4x3xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C_P>) -> tensor<4x9xf64>
call @dump_mat_dense_4x9(%15) : (tensor<4x9xf64>) -> ()
- // CHECK-NEXT: ( ( 1, 0, 1, 0, 1, 0, 0, 1.5, 1 ), ( 3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0 ), ( 0, 2, 0, 0, 1, 1, 5, 2, 0 ), ( 0, 0, 5, 2, 0, 1, 0.5, 0, 0 ) )
+ // CHECK: {{\[}}[1, 0, 1, 0, 1, 0, 0, 1.5, 1],
+ // CHECK-NEXT: [3.1, 0, 1, 0, 0.5, 0, 3.5, 0, 0],
+ // CHECK-NEXT: [0, 2, 0, 0, 1, 1, 5, 2, 0],
+ // CHECK-NEXT: [0, 0, 5, 2, 0, 1, 0.5, 0, 0]]
// CHECK-NEXT: 18
- // CHECK-NEXT: ( 1, 1, 1, 1.5, 1, 3.1, 1, 0.5, 3.5, 2, 1, 1, 5, 2, 5, 2, 1, 0.5 )
+ // CHECK: [1, 1, 1, 1.5, 1, 3.1, 1, 0.5, 3.5, 2, 1, 1, 5, 2, 5, 2, 1, 0.5
%16 = call @concat_mix_sparse_dyn(%m42, %sm43cd, %sm44dc)
: (tensor<4x2xf64>, tensor<4x3xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C>) -> tensor<?x?xf64, #MAT_C_C>
call @dump_mat_dyn(%16) : (tensor<?x?xf64, #MAT_C_C>) -> ()
// CHECK-NEXT: 36
- // CHECK-NEXT: ( 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 2, 0, 0.5, 5, 0, 3.5, 5, 0.5, 3, 0, 1, 0, 2, 1.5, 0, 2, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0 )
+ // CHECK: [1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 2, 0, 0.5, 5, 0, 3.5, 5, 0.5, 3, 0, 1, 0, 2, 1.5, 0, 2, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0
%17 = call @concat_sparse_annotated_dense(%sm24cc, %sm34cd, %sm44dc)
: (tensor<2x4xf64, #MAT_C_C>, tensor<3x4xf64, #MAT_C_D>, tensor<4x4xf64, #MAT_D_C>) -> tensor<9x4xf64, #MAT_D_D>
call @dump_mat_annotated_dense_9x4(%17) : (tensor<9x4xf64, #MAT_D_D>) -> ()
// DEFINE: %{command} = mlir-opt %s --sparse-compiler=%{option} | \
// DEFINE: mlir-cpu-runner \
// DEFINE: -e entry -entry-point-result=void \
-// DEFINE: -shared-libs=%mlir_lib_dir/libmlir_c_runner_utils%shlibext | \
+// DEFINE: -shared-libs=%mlir_lib_dir/libmlir_c_runner_utils%shlibext,%mlir_lib_dir/libmlir_runner_utils%shlibext | \
// DEFINE: FileCheck %s
//
// RUN: %{command}
//
// Do the same run, but now with direct IR generation.
-// REDEFINE: %{option} = enable-runtime-library=false
+// REDEFINE: %{option} = "enable-runtime-library=false enable-buffer-initialization=true"
// RUN: %{command}
//
// Do the same run, but now with parallelization strategy.
// RUN: %{command}
//
// Do the same run, but now with direct IR generation and parallelization strategy.
-// REDEFINE: %{option} = "enable-runtime-library=false parallelization-strategy=any-storage-any-loop"
+// REDEFINE: %{option} = "enable-runtime-library=false enable-buffer-initialization=true parallelization-strategy=any-storage-any-loop"
// RUN: %{command}
#CSR = #sparse_tensor.encoding<{
}>
module {
+ func.func private @printMemrefF64(%ptr : tensor<*xf64>)
+ func.func private @printMemref1dF64(%ptr : memref<?xf64>) attributes { llvm.emit_c_interface }
+
//
// Computes C = A x B with all matrices dense.
//
//
func.func @entry() {
%c0 = arith.constant 0 : index
- %d1 = arith.constant -1.0 : f64
// Initialize various matrices, dense for stress testing,
// and sparse to verify correct nonzero structure.
tensor<8x4xf64, #DCSR>) -> tensor<4x4xf64, #DCSR>
//
- // CHECK: ( ( 388.76, 425.56, 462.36, 499.16 ),
- // CHECK-SAME: ( 397.12, 434.72, 472.32, 509.92 ),
- // CHECK-SAME: ( 405.48, 443.88, 482.28, 520.68 ),
- // CHECK-SAME: ( 413.84, 453.04, 492.24, 531.44 ) )
+ // CHECK: {{\[}}[388.76, 425.56, 462.36, 499.16],
+ // CHECK-NEXT: [397.12, 434.72, 472.32, 509.92],
+ // CHECK-NEXT: [405.48, 443.88, 482.28, 520.68],
+ // CHECK-NEXT: [413.84, 453.04, 492.24, 531.44]]
//
- %v0 = vector.transfer_read %0[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64>
- vector.print %v0 : vector<4x4xf64>
+ %u0 = tensor.cast %0 : tensor<4x4xf64> to tensor<*xf64>
+ call @printMemrefF64(%u0) : (tensor<*xf64>) -> ()
//
- // CHECK: ( ( 388.76, 425.56, 462.36, 499.16 ),
- // CHECK-SAME: ( 397.12, 434.72, 472.32, 509.92 ),
- // CHECK-SAME: ( 405.48, 443.88, 482.28, 520.68 ),
- // CHECK-SAME: ( 413.84, 453.04, 492.24, 531.44 ) )
+ // CHECK: {{\[}}[388.76, 425.56, 462.36, 499.16],
+ // CHECK-NEXT: [397.12, 434.72, 472.32, 509.92],
+ // CHECK-NEXT: [405.48, 443.88, 482.28, 520.68],
+ // CHECK-NEXT: [413.84, 453.04, 492.24, 531.44]]
//
%c1 = sparse_tensor.convert %1 : tensor<4x4xf64, #CSR> to tensor<4x4xf64>
- %v1 = vector.transfer_read %c1[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64>
- vector.print %v1 : vector<4x4xf64>
+ %c1u = tensor.cast %c1 : tensor<4x4xf64> to tensor<*xf64>
+ call @printMemrefF64(%c1u) : (tensor<*xf64>) -> ()
//
- // CHECK: ( ( 388.76, 425.56, 462.36, 499.16 ),
- // CHECK-SAME: ( 397.12, 434.72, 472.32, 509.92 ),
- // CHECK-SAME: ( 405.48, 443.88, 482.28, 520.68 ),
- // CHECK-SAME: ( 413.84, 453.04, 492.24, 531.44 ) )
+ // CHECK: {{\[}}[388.76, 425.56, 462.36, 499.16],
+ // CHECK-NEXT: [397.12, 434.72, 472.32, 509.92],
+ // CHECK-NEXT: [405.48, 443.88, 482.28, 520.68],
+ // CHECK-NEXT: [413.84, 453.04, 492.24, 531.44]]
//
%c2 = sparse_tensor.convert %2 : tensor<4x4xf64, #DCSR> to tensor<4x4xf64>
- %v2 = vector.transfer_read %c2[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64>
- vector.print %v2 : vector<4x4xf64>
+ %c2u = tensor.cast %c2 : tensor<4x4xf64> to tensor<*xf64>
+ call @printMemrefF64(%c2u) : (tensor<*xf64>) -> ()
//
- // CHECK: ( ( 86.08, 94.28, 102.48, 110.68 ),
- // CHECK-SAME: ( 0, 0, 0, 0 ),
- // CHECK-SAME: ( 23.46, 25.76, 28.06, 30.36 ),
- // CHECK-SAME: ( 10.8, 11.8, 12.8, 13.8 ) )
+ // CHECK: {{\[}}[86.08, 94.28, 102.48, 110.68],
+ // CHECK-NEXT: [0, 0, 0, 0],
+ // CHECK-NEXT: [23.46, 25.76, 28.06, 30.36],
+ // CHECK-NEXT: [10.8, 11.8, 12.8, 13.8]]
//
- %v3 = vector.transfer_read %3[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64>
- vector.print %v3 : vector<4x4xf64>
+ %u3 = tensor.cast %3 : tensor<4x4xf64> to tensor<*xf64>
+ call @printMemrefF64(%u3) : (tensor<*xf64>) -> ()
//
- // CHECK: ( ( 86.08, 94.28, 102.48, 110.68 ),
- // CHECK-SAME: ( 0, 0, 0, 0 ),
- // CHECK-SAME: ( 23.46, 25.76, 28.06, 30.36 ),
- // CHECK-SAME: ( 10.8, 11.8, 12.8, 13.8 ) )
+ // CHECK: {{\[}}[86.08, 94.28, 102.48, 110.68],
+ // CHECK-NEXT: [0, 0, 0, 0],
+ // CHECK-NEXT: [23.46, 25.76, 28.06, 30.36],
+ // CHECK-NEXT: [10.8, 11.8, 12.8, 13.8]]
//
%c4 = sparse_tensor.convert %4 : tensor<4x4xf64, #CSR> to tensor<4x4xf64>
- %v4 = vector.transfer_read %c4[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64>
- vector.print %v4 : vector<4x4xf64>
+ %c4u = tensor.cast %c4 : tensor<4x4xf64> to tensor<*xf64>
+ call @printMemrefF64(%c4u) : (tensor<*xf64>) -> ()
//
- // CHECK: ( ( 86.08, 94.28, 102.48, 110.68 ),
- // CHECK-SAME: ( 0, 0, 0, 0 ),
- // CHECK-SAME: ( 23.46, 25.76, 28.06, 30.36 ),
- // CHECK-SAME: ( 10.8, 11.8, 12.8, 13.8 ) )
+ // CHECK: {{\[}}[86.08, 94.28, 102.48, 110.68],
+ // CHECK-NEXT: [0, 0, 0, 0],
+ // CHECK-NEXT: [23.46, 25.76, 28.06, 30.36],
+ // CHECK-NEXT: [10.8, 11.8, 12.8, 13.8]]
//
%c5 = sparse_tensor.convert %5 : tensor<4x4xf64, #DCSR> to tensor<4x4xf64>
- %v5 = vector.transfer_read %c5[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64>
- vector.print %v5 : vector<4x4xf64>
+ %c5u = tensor.cast %c5 : tensor<4x4xf64> to tensor<*xf64>
+ call @printMemrefF64(%c5u) : (tensor<*xf64>) -> ()
//
- // CHECK-NEXT: ( ( 0, 30.5, 4.2, 0 ), ( 0, 0, 0, 0 ), ( 0, 0, 4.6, 0 ), ( 0, 0, 7, 8 ) )
+ // CHECK: {{\[}}[0, 30.5, 4.2, 0],
+ // CHECK-NEXT: [0, 0, 0, 0],
+ // CHECK-NEXT: [0, 0, 4.6, 0],
+ // CHECK-NEXT: [0, 0, 7, 8]]
//
- %v6 = vector.transfer_read %6[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64>
- vector.print %v6 : vector<4x4xf64>
+ %u6 = tensor.cast %6 : tensor<4x4xf64> to tensor<*xf64>
+ call @printMemrefF64(%u6) : (tensor<*xf64>) -> ()
//
- // CHECK-NEXT: ( ( 0, 30.5, 4.2, 0 ), ( 0, 0, 0, 0 ), ( 0, 0, 4.6, 0 ), ( 0, 0, 7, 8 ) )
+ // CHECK: {{\[}}[0, 30.5, 4.2, 0],
+ // CHECK-NEXT: [0, 0, 0, 0],
+ // CHECK-NEXT: [0, 0, 4.6, 0],
+ // CHECK-NEXT: [0, 0, 7, 8]]
//
%c7 = sparse_tensor.convert %7 : tensor<4x4xf64, #CSR> to tensor<4x4xf64>
- %v7 = vector.transfer_read %c7[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64>
- vector.print %v7 : vector<4x4xf64>
+ %c7u = tensor.cast %c7 : tensor<4x4xf64> to tensor<*xf64>
+ call @printMemrefF64(%c7u) : (tensor<*xf64>) -> ()
//
- // CHECK-NEXT: ( ( 0, 30.5, 4.2, 0 ), ( 0, 0, 0, 0 ), ( 0, 0, 4.6, 0 ), ( 0, 0, 7, 8 ) )
+ // CHECK: {{\[}}[0, 30.5, 4.2, 0],
+ // CHECK-NEXT: [0, 0, 0, 0],
+ // CHECK-NEXT: [0, 0, 4.6, 0],
+ // CHECK-NEXT: [0, 0, 7, 8]]
//
%c8 = sparse_tensor.convert %8 : tensor<4x4xf64, #DCSR> to tensor<4x4xf64>
- %v8 = vector.transfer_read %c8[%c0, %c0], %d1 : tensor<4x4xf64>, vector<4x4xf64>
- vector.print %v8 : vector<4x4xf64>
+ %c8u = tensor.cast %c8 : tensor<4x4xf64> to tensor<*xf64>
+ call @printMemrefF64(%c8u) : (tensor<*xf64>) -> ()
//
// Sanity check on nonzeros.
//
- // CHECK-NEXT: ( 30.5, 4.2, 4.6, 7, 8 )
- // CHECK-NEXT: ( 30.5, 4.2, 4.6, 7, 8 )
+ // CHECK: [30.5, 4.2, 4.6, 7, 8
+ // CHECK: [30.5, 4.2, 4.6, 7, 8
//
%val7 = sparse_tensor.values %7 : tensor<4x4xf64, #CSR> to memref<?xf64>
%val8 = sparse_tensor.values %8 : tensor<4x4xf64, #DCSR> to memref<?xf64>
- %nz7 = vector.transfer_read %val7[%c0], %d1 : memref<?xf64>, vector<5xf64>
- %nz8 = vector.transfer_read %val8[%c0], %d1 : memref<?xf64>, vector<5xf64>
- vector.print %nz7 : vector<5xf64>
- vector.print %nz8 : vector<5xf64>
+ call @printMemref1dF64(%val7) : (memref<?xf64>) -> ()
+ call @printMemref1dF64(%val8) : (memref<?xf64>) -> ()
//
// Sanity check on stored entries after the computations.