| 96 | |
| 97 | template<typename T, af_storage stype> |
| 98 | Array<T> sparseConvertStorageToDense(const SparseArray<T> &in_) { |
| 99 | if (stype != AF_STORAGE_CSR) { |
| 100 | AF_ERROR("OpenCL Backend only supports CSR or COO to Dense", |
| 101 | AF_ERR_NOT_SUPPORTED); |
| 102 | } |
| 103 | |
| 104 | in_.eval(); |
| 105 | |
| 106 | Array<T> dense_ = createValueArray<T>(in_.dims(), scalar<T>(0)); |
| 107 | dense_.eval(); |
| 108 | |
| 109 | const Array<T> &values = in_.getValues(); |
| 110 | const Array<int> &rowIdx = in_.getRowIdx(); |
| 111 | const Array<int> &colIdx = in_.getColIdx(); |
| 112 | |
| 113 | if (stype == AF_STORAGE_CSR) { |
| 114 | kernel::csr2dense<T>(dense_, values, rowIdx, colIdx); |
| 115 | } else { |
| 116 | AF_ERROR("OpenCL Backend only supports CSR or COO to Dense", |
| 117 | AF_ERR_NOT_SUPPORTED); |
| 118 | } |
| 119 | |
| 120 | return dense_; |
| 121 | } |
| 122 | |
| 123 | template<typename T, af_storage dest, af_storage src> |
| 124 | SparseArray<T> sparseConvertStorageToStorage(const SparseArray<T> &in) { |