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

Function readTestsFromFile

test/arrayfire_test.cpp:859–905  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

857
858template<typename inType, typename outType>
859void readTestsFromFile(const std::string &FileName,
860 std::vector<af::dim4> &inputDims,
861 std::vector<std::vector<inType>> &testInputs,
862 std::vector<std::vector<outType>> &testOutputs) {
863 using std::vector;
864
865 std::ifstream testFile(FileName.c_str());
866 if (testFile.good()) {
867 unsigned inputCount;
868 testFile >> inputCount;
869 for (unsigned i = 0; i < inputCount; i++) {
870 af::dim4 temp(1);
871 testFile >> temp;
872 inputDims.push_back(temp);
873 }
874
875 unsigned testCount;
876 testFile >> testCount;
877 testOutputs.resize(testCount);
878
879 vector<unsigned> testSizes(testCount);
880 for (unsigned i = 0; i < testCount; i++) { testFile >> testSizes[i]; }
881
882 testInputs.resize(inputCount, vector<inType>(0));
883 for (unsigned k = 0; k < inputCount; k++) {
884 dim_t nElems = inputDims[k].elements();
885 testInputs[k].resize(nElems);
886 inType tmp;
887 for (unsigned i = 0; i < nElems; i++) {
888 testFile >> tmp;
889 testInputs[k][i] = tmp;
890 }
891 }
892
893 testOutputs.resize(testCount, vector<outType>(0));
894 for (unsigned i = 0; i < testCount; i++) {
895 testOutputs[i].resize(testSizes[i]);
896 outType tmp;
897 for (unsigned j = 0; j < testSizes[i]; j++) {
898 testFile >> tmp;
899 testOutputs[i][j] = tmp;
900 }
901 }
902 } else {
903 FAIL() << "TEST FILE NOT FOUND";
904 }
905}
906
907#define INSTANTIATE(Ti, To) \
908 template void readTestsFromFile<Ti, To>( \

Callers

nothing calls this directly

Calls 1

elementsMethod · 0.45

Tested by

no test coverage detected