// DEFINE: %{option} = enable-runtime-library=true // DEFINE: %{compile} = mlir-opt %s --sparse-compiler=%{option} // DEFINE: %{run} = mlir-cpu-runner \ // DEFINE: -e entry -entry-point-result=void \ // DEFINE: -shared-libs=%mlir_c_runner_utils,%mlir_runner_utils | \ // DEFINE: FileCheck %s // // RUN: %{compile} | %{run} // // Do the same run, but now with direct IR generation. // REDEFINE: %{option} = "enable-runtime-library=false enable-buffer-initialization=true" // RUN: %{compile} | %{run} // // Do the same run, but now with direct IR generation and vectorization. // REDEFINE: %{option} = "enable-runtime-library=false enable-buffer-initialization=true vl=2 reassociate-fp-reductions=true enable-index-optimizations=true" // RUN: %{compile} | %{run} // Do the same run, but now with direct IR generation and, if available, VLA // vectorization. // REDEFINE: %{option} = "enable-runtime-library=false enable-buffer-initialization=true vl=4 reassociate-fp-reductions=true enable-index-optimizations=true enable-arm-sve=%ENABLE_VLA" // REDEFINE: %{run} = %lli_host_or_aarch64_cmd \ // REDEFINE: --entry-function=entry_lli \ // REDEFINE: --extra-module=%S/Inputs/main_for_lli.ll \ // REDEFINE: %VLA_ARCH_ATTR_OPTIONS \ // REDEFINE: --dlopen=%mlir_native_utils_lib_dir/libmlir_c_runner_utils%shlibext --dlopen=%mlir_runner_utils | \ // REDEFINE: FileCheck %s // RUN: %{compile} | mlir-translate -mlir-to-llvmir | %{run} #DCSR = #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ] }> #DCSC = #sparse_tensor.encoding<{ dimLevelType = [ "compressed", "compressed" ], dimOrdering = affine_map<(i,j) -> (j,i)> }> // // Integration test that tests conversions between sparse tensors, // where the dynamic sizes of the shape of the enveloping tensor // may change (the actual underlying sizes obviously never change). // module { func.func private @printMemref1dF64(%ptr : memref) attributes { llvm.emit_c_interface } // // Helper method to print values array. The transfer actually // reads more than required to verify size of buffer as well. // func.func @dump(%arg0: memref) { call @printMemref1dF64(%arg0) : (memref) -> () return } func.func @entry() { %t1 = arith.constant sparse< [ [0,0], [0,1], [0,63], [1,0], [1,1], [31,0], [31,63] ], [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ]> : tensor<32x64xf64> %t2 = tensor.cast %t1 : tensor<32x64xf64> to tensor // Four dense to sparse conversions. %1 = sparse_tensor.convert %t1 : tensor<32x64xf64> to tensor %2 = sparse_tensor.convert %t1 : tensor<32x64xf64> to tensor %3 = sparse_tensor.convert %t2 : tensor to tensor %4 = sparse_tensor.convert %t2 : tensor to tensor // Two cross conversions. %5 = sparse_tensor.convert %3 : tensor to tensor %6 = sparse_tensor.convert %4 : tensor to tensor // // Check number_of_entries. // // CHECK-COUNT-6: 7 %n1 = sparse_tensor.number_of_entries %1 : tensor %n2 = sparse_tensor.number_of_entries %2 : tensor %n3 = sparse_tensor.number_of_entries %3 : tensor %n4 = sparse_tensor.number_of_entries %4 : tensor %n5 = sparse_tensor.number_of_entries %5 : tensor %n6 = sparse_tensor.number_of_entries %6 : tensor vector.print %n1 : index vector.print %n2 : index vector.print %n3 : index vector.print %n4 : index vector.print %n5 : index vector.print %n6 : index // // All proper row-/column-wise? // // CHECK: [1, 2, 3, 4, 5, 6, 7 // CHECK: [1, 4, 6, 2, 5, 3, 7 // CHECK: [1, 2, 3, 4, 5, 6, 7 // CHECK: [1, 4, 6, 2, 5, 3, 7 // CHECK: [1, 4, 6, 2, 5, 3, 7 // CHECK: [1, 2, 3, 4, 5, 6, 7 // %m1 = sparse_tensor.values %1 : tensor to memref %m2 = sparse_tensor.values %2 : tensor to memref %m3 = sparse_tensor.values %3 : tensor to memref %m4 = sparse_tensor.values %4 : tensor to memref %m5 = sparse_tensor.values %5 : tensor to memref %m6 = sparse_tensor.values %6 : tensor to memref call @dump(%m1) : (memref) -> () call @dump(%m2) : (memref) -> () call @dump(%m3) : (memref) -> () call @dump(%m4) : (memref) -> () call @dump(%m5) : (memref) -> () call @dump(%m6) : (memref) -> () // Release the resources. bufferization.dealloc_tensor %1 : tensor bufferization.dealloc_tensor %2 : tensor bufferization.dealloc_tensor %3 : tensor bufferization.dealloc_tensor %4 : tensor bufferization.dealloc_tensor %5 : tensor bufferization.dealloc_tensor %6 : tensor return } }