| 23 | |
| 24 | template<typename T> |
| 25 | cusparseStatus_t createSpMatDescr( |
| 26 | cusparseSpMatDescr_t *out, const arrayfire::common::SparseArray<T> &arr) { |
| 27 | auto &_ = arrayfire::cuda::getCusparsePlugin(); |
| 28 | switch (arr.getStorage()) { |
| 29 | case AF_STORAGE_CSR: { |
| 30 | return _.cusparseCreateCsr( |
| 31 | out, arr.dims()[0], arr.dims()[1], arr.getNNZ(), |
| 32 | (void *)arr.getRowIdx().get(), (void *)arr.getColIdx().get(), |
| 33 | (void *)arr.getValues().get(), CUSPARSE_INDEX_32I, |
| 34 | CUSPARSE_INDEX_32I, CUSPARSE_INDEX_BASE_ZERO, getType<T>()); |
| 35 | } |
| 36 | #if CUSPARSE_VERSION >= 11300 |
| 37 | case AF_STORAGE_CSC: { |
| 38 | return _.cusparseCreateCsc( |
| 39 | out, arr.dims()[0], arr.dims()[1], arr.getNNZ(), |
| 40 | (void *)arr.getColIdx().get(), (void *)arr.getRowIdx().get(), |
| 41 | (void *)arr.getValues().get(), CUSPARSE_INDEX_32I, |
| 42 | CUSPARSE_INDEX_32I, CUSPARSE_INDEX_BASE_ZERO, getType<T>()); |
| 43 | } |
| 44 | #else |
| 45 | case AF_STORAGE_CSC: |
| 46 | CUDA_NOT_SUPPORTED( |
| 47 | "Sparse not supported for CSC on this version of the CUDA " |
| 48 | "Toolkit"); |
| 49 | #endif |
| 50 | case AF_STORAGE_COO: { |
| 51 | return _.cusparseCreateCoo( |
| 52 | out, arr.dims()[0], arr.dims()[1], arr.getNNZ(), |
| 53 | (void *)arr.getColIdx().get(), (void *)arr.getRowIdx().get(), |
| 54 | (void *)arr.getValues().get(), CUSPARSE_INDEX_32I, |
| 55 | CUSPARSE_INDEX_BASE_ZERO, getType<T>()); |
| 56 | } |
| 57 | } |
| 58 | return CUSPARSE_STATUS_SUCCESS; |
| 59 | } |
| 60 | |
| 61 | } // namespace cuda |
| 62 | } // namespace arrayfire |
nothing calls this directly
no test coverage detected