| 166 | |
| 167 | template<typename T> |
| 168 | static void convertCSC(const int M, const int N, const double ratio, |
| 169 | int targetDevice = -1) { |
| 170 | if (targetDevice >= 0) af::setDevice(targetDevice); |
| 171 | |
| 172 | SUPPORTED_TYPE_CHECK(T); |
| 173 | #if 1 |
| 174 | af::array a = cpu_randu<T>(af::dim4(M, N)); |
| 175 | #else |
| 176 | af::array a = af::randu(M, N); |
| 177 | #endif |
| 178 | a = a * (a > ratio); |
| 179 | |
| 180 | af::array s = af::sparse(a, AF_STORAGE_CSC); |
| 181 | af::array aa = af::dense(s); |
| 182 | |
| 183 | ASSERT_ARRAYS_EQ(a, aa); |
| 184 | } |
| 185 | |
| 186 | // This test essentially verifies that the sparse structures have the correct |
| 187 | // dimensions and indices using a very basic test |