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

Function sparseArithTester

test/sparse_arith.cpp:95–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93
94template<typename T, af_op_t op>
95void sparseArithTester(const int m, const int n, int factor, const double eps) {
96 deviceGC();
97
98 SUPPORTED_TYPE_CHECK(T);
99
100#if 1
101 array A = cpu_randu<T>(dim4(m, n));
102 array B = cpu_randu<T>(dim4(m, n));
103#else
104 array A = randu(m, n, (dtype)dtype_traits<T>::af_type);
105 array B = randu(m, n, (dtype)dtype_traits<T>::af_type);
106#endif
107
108 A = makeSparse<T>(A, factor);
109
110 array RA = sparse(A, AF_STORAGE_CSR);
111 array OA = sparse(A, AF_STORAGE_COO);
112
113 // Arith Op
114 array resR = arith_op<op>()(RA, B);
115 array resO = arith_op<op>()(OA, B);
116 array resD = arith_op<op>()(A, B);
117
118 array revR = arith_op<op>()(B, RA);
119 array revO = arith_op<op>()(B, OA);
120 array revD = arith_op<op>()(B, A);
121
122 ASSERT_ARRAYS_NEAR(resD, resR, eps);
123 ASSERT_ARRAYS_NEAR(resD, resO, eps);
124 ASSERT_ARRAYS_NEAR(revD, revR, eps);
125 ASSERT_ARRAYS_NEAR(revD, revO, eps);
126}
127
128// Mul
129template<typename T>

Callers

nothing calls this directly

Calls 4

deviceGCFunction · 0.85
randuFunction · 0.85
sparseFunction · 0.85
dim4Class · 0.50

Tested by

no test coverage detected