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

Function readTests

test/arrayfire_test.cpp:302–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300
301template<typename inType, typename outType, typename FileElementType>
302void readTests(const std::string &FileName, std::vector<af::dim4> &inputDims,
303 std::vector<std::vector<inType>> &testInputs,
304 std::vector<std::vector<outType>> &testOutputs) {
305 using std::vector;
306
307 std::ifstream testFile(FileName.c_str());
308 if (testFile.good()) {
309 unsigned inputCount;
310 testFile >> inputCount;
311 inputDims.resize(inputCount);
312 for (unsigned i = 0; i < inputCount; i++) { testFile >> inputDims[i]; }
313
314 unsigned testCount;
315 testFile >> testCount;
316 testOutputs.resize(testCount);
317
318 vector<unsigned> testSizes(testCount);
319 for (unsigned i = 0; i < testCount; i++) { testFile >> testSizes[i]; }
320
321 testInputs.resize(inputCount, vector<inType>(0));
322 for (unsigned k = 0; k < inputCount; k++) {
323 dim_t nElems = inputDims[k].elements();
324 testInputs[k].resize(nElems);
325 FileElementType tmp;
326 for (unsigned i = 0; i < nElems; i++) {
327 testFile >> tmp;
328 testInputs[k][i] = convert<inType, FileElementType>(tmp);
329 }
330 }
331
332 testOutputs.resize(testCount, vector<outType>(0));
333 for (unsigned i = 0; i < testCount; i++) {
334 testOutputs[i].resize(testSizes[i]);
335 FileElementType tmp;
336 for (unsigned j = 0; j < testSizes[i]; j++) {
337 testFile >> tmp;
338 testOutputs[i][j] = convert<outType, FileElementType>(tmp);
339 }
340 }
341 } else {
342 FAIL() << "TEST FILE NOT FOUND";
343 }
344}
345
346#define INSTANTIATE(Tin, Tout, Tfile) \
347 template void readTests<Tin, Tout, Tfile>( \

Callers

nothing calls this directly

Calls 1

elementsMethod · 0.45

Tested by

no test coverage detected