// RUN: mlir-opt --sparse-tensor-conversion %s | FileCheck %s !SparseTensor = type !llvm.ptr // CHECK-LABEL: func @sparse_pointers( // CHECK-SAME: %[[A:.*]]: !llvm.ptr) // CHECK: %[[C:.*]] = constant 1 : index // CHECK: %[[T:.*]] = call @sparsePointers64(%[[A]], %[[C]]) : (!llvm.ptr, index) -> memref // CHECK: return %[[T]] : memref func @sparse_pointers(%arg0: !SparseTensor) -> memref { %a = sparse_tensor.fromPtr %arg0 : !SparseTensor to tensor<128xf64> %c = constant 1 : index %0 = sparse_tensor.pointers %a, %c : tensor<128xf64> to memref return %0 : memref } // CHECK-LABEL: func @sparse_pointers32( // CHECK-SAME: %[[A:.*]]: !llvm.ptr) // CHECK: %[[C:.*]] = constant 1 : index // CHECK: %[[T:.*]] = call @sparsePointers32(%[[A]], %[[C]]) : (!llvm.ptr, index) -> memref // CHECK: return %[[T]] : memref func @sparse_pointers32(%arg0: !SparseTensor) -> memref { %a = sparse_tensor.fromPtr %arg0 : !SparseTensor to tensor<128xf64> %c = constant 1 : index %0 = sparse_tensor.pointers %a, %c : tensor<128xf64> to memref return %0 : memref } // CHECK-LABEL: func @sparse_indices( // CHECK-SAME: %[[A:.*]]: !llvm.ptr) // CHECK: %[[C:.*]] = constant 1 : index // CHECK: %[[T:.*]] = call @sparseIndices64(%[[A]], %[[C]]) : (!llvm.ptr, index) -> memref // CHECK: return %[[T]] : memref func @sparse_indices(%arg0: !SparseTensor) -> memref { %a = sparse_tensor.fromPtr %arg0 : !SparseTensor to tensor<128xf64> %c = constant 1 : index %0 = sparse_tensor.indices %a, %c : tensor<128xf64> to memref return %0 : memref } // CHECK-LABEL: func @sparse_indices32( // CHECK-SAME: %[[A:.*]]: !llvm.ptr) // CHECK: %[[C:.*]] = constant 1 : index // CHECK: %[[T:.*]] = call @sparseIndices32(%[[A]], %[[C]]) : (!llvm.ptr, index) -> memref // CHECK: return %[[T]] : memref func @sparse_indices32(%arg0: !SparseTensor) -> memref { %a = sparse_tensor.fromPtr %arg0 : !SparseTensor to tensor<128xf64> %c = constant 1 : index %0 = sparse_tensor.indices %a, %c : tensor<128xf64> to memref return %0 : memref } // CHECK-LABEL: func @sparse_valuesf64( // CHECK-SAME: %[[A:.*]]: !llvm.ptr) // CHECK: %[[T:.*]] = call @sparseValuesF64(%[[A]]) : (!llvm.ptr) -> memref // CHECK: return %[[T]] : memref func @sparse_valuesf64(%arg0: !SparseTensor) -> memref { %a = sparse_tensor.fromPtr %arg0 : !SparseTensor to tensor<128xf64> %0 = sparse_tensor.values %a : tensor<128xf64> to memref return %0 : memref } // CHECK-LABEL: func @sparse_valuesf32( // CHECK-SAME: %[[A:.*]]: !llvm.ptr) // CHECK: %[[T:.*]] = call @sparseValuesF32(%[[A]]) : (!llvm.ptr) -> memref // CHECK: return %[[T]] : memref func @sparse_valuesf32(%arg0: !SparseTensor) -> memref { %a = sparse_tensor.fromPtr %arg0 : !SparseTensor to tensor<128xf32> %0 = sparse_tensor.values %a : tensor<128xf32> to memref return %0 : memref }