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

Function sparseTester

test/sparse_common.hpp:69–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68template<typename T>
69static void sparseTester(const int m, const int n, const int k, int factor,
70 double eps, int targetDevice = -1) {
71 if (targetDevice >= 0) af::setDevice(targetDevice);
72
73 af::deviceGC();
74
75 SUPPORTED_TYPE_CHECK(T);
76
77#if 1
78 af::array A = cpu_randu<T>(af::dim4(m, n));
79 af::array B = cpu_randu<T>(af::dim4(n, k));
80#else
81 af::array A = af::randu(m, n, (af::dtype)af::dtype_traits<T>::af_type);
82 af::array B = af::randu(n, k, (af::dtype)af::dtype_traits<T>::af_type);
83#endif
84
85 A = makeSparse<T>(A, factor);
86
87 // Result of GEMM
88 af::array dRes1 = matmul(A, B);
89
90 // Create Sparse Array From Dense
91 af::array sA = af::sparse(A, AF_STORAGE_CSR);
92
93 // Sparse Matmul
94 af::array sRes1 = matmul(sA, B);
95
96 // Verify Results
97 ASSERT_NEAR(0, calc_norm(real(dRes1), real(sRes1)), eps);
98 ASSERT_NEAR(0, calc_norm(imag(dRes1), imag(sRes1)), eps);
99}
100
101template<typename T>
102static void sparseTransposeTester(const int m, const int n, const int k,

Callers

nothing calls this directly

Calls 9

deviceGCFunction · 0.85
randuFunction · 0.85
sparseFunction · 0.85
calc_normFunction · 0.85
realFunction · 0.70
imagFunction · 0.70
setDeviceFunction · 0.50
dim4Class · 0.50
matmulFunction · 0.50

Tested by

no test coverage detected