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

Function cppReduceTest

test/reduce.cpp:236–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234
235template<typename Ti, typename To, ReductionOp reduce>
236void cppReduceTest(string pTestFile) {
237 SUPPORTED_TYPE_CHECK(Ti);
238 SUPPORTED_TYPE_CHECK(To);
239
240 vector<dim4> numDims;
241
242 vector<vector<int>> data;
243 vector<vector<int>> tests;
244 readTests<int, int, int>(pTestFile, numDims, data, tests);
245 dim4 dims = numDims[0];
246
247 vector<Ti> in(data[0].size());
248 transform(data[0].begin(), data[0].end(), in.begin(), convert_to<Ti, int>);
249
250 array input(dims, &in.front());
251
252 // Compare result
253 for (int d = 0; d < (int)tests.size(); ++d) {
254 vector<To> currGoldBar(tests[d].begin(), tests[d].end());
255
256 // Run sum
257 array output = reduce(input, d);
258
259 // Get result
260 vector<To> outData(dims.elements());
261 output.host((void *)&outData.front());
262
263 size_t nElems = currGoldBar.size();
264 for (size_t elIter = 0; elIter < nElems; ++elIter) {
265 ASSERT_EQ(currGoldBar[elIter], outData[elIter])
266 << "at: " << elIter << " for dim " << d << endl;
267 }
268 }
269}
270
271TEST(Reduce, Test_Sum_Scalar_MaxDim) {
272 const size_t largeDim = 65535 * 32 * 8 + 1;

Callers

nothing calls this directly

Calls 4

hostMethod · 0.80
transformFunction · 0.50
reduceFunction · 0.50
elementsMethod · 0.45

Tested by

no test coverage detected