MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / sparseConvertStorageToStorage

Function sparseConvertStorageToStorage

src/backend/cpu/sparse.cpp:101–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99
100template<typename T, af_storage dest, af_storage src>
101SparseArray<T> sparseConvertStorageToStorage(const SparseArray<T> &in) {
102 in.eval();
103
104 auto converted = createEmptySparseArray<T>(
105 in.dims(), static_cast<int>(in.getNNZ()), dest);
106 converted.eval();
107
108 function<void(Param<T>, Param<int>, Param<int>, CParam<T>, CParam<int>,
109 CParam<int>)>
110 converter;
111
112 if (src == AF_STORAGE_CSR && dest == AF_STORAGE_COO) {
113 converter = kernel::csr2coo<T>;
114 } else if (src == AF_STORAGE_COO && dest == AF_STORAGE_CSR) {
115 converter = kernel::coo2csr<T>;
116 } else {
117 // Should never come here
118 AF_ERROR("CPU Backend invalid conversion combination",
119 AF_ERR_NOT_SUPPORTED);
120 }
121 getQueue().enqueue(converter, converted.getValues(), converted.getRowIdx(),
122 converted.getColIdx(), in.getValues(), in.getRowIdx(),
123 in.getColIdx());
124 return converted;
125}
126
127#define INSTANTIATE_TO_STORAGE(T, S) \
128 template SparseArray<T> \

Callers

nothing calls this directly

Calls 5

getNNZMethod · 0.80
getQueueFunction · 0.50
evalMethod · 0.45
dimsMethod · 0.45
enqueueMethod · 0.45

Tested by

no test coverage detected