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

Function scanTest

test/scan.cpp:45–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44template<typename Ti, typename To, scanFunc af_scan>
45void scanTest(string pTestFile, int off = 0, bool isSubRef = false,
46 const vector<af_seq> seqv = vector<af_seq>()) {
47 SUPPORTED_TYPE_CHECK(Ti);
48
49 vector<dim4> numDims;
50
51 vector<vector<int>> data;
52 vector<vector<int>> tests;
53 readTests<int, int, int>(pTestFile, numDims, data, tests);
54 dim4 dims = numDims[0];
55
56 vector<Ti> in(data[0].size());
57 transform(data[0].begin(), data[0].end(), in.begin(), convert_to<Ti, int>);
58
59 af_array inArray = 0;
60 af_array outArray = 0;
61 af_array tempArray = 0;
62
63 // Get input array
64 if (isSubRef) {
65 ASSERT_SUCCESS(af_create_array(&tempArray, &in.front(), dims.ndims(),
66 dims.get(),
67 (af_dtype)dtype_traits<Ti>::af_type));
68 ASSERT_SUCCESS(
69 af_index(&inArray, tempArray, seqv.size(), &seqv.front()));
70 ASSERT_SUCCESS(af_release_array(tempArray));
71 } else {
72 ASSERT_SUCCESS(af_create_array(&inArray, &in.front(), dims.ndims(),
73 dims.get(),
74 (af_dtype)dtype_traits<Ti>::af_type));
75 }
76
77 // Compare result
78 for (int d = 0; d < (int)tests.size(); ++d) {
79 vector<To> currGoldBar(tests[d].begin(), tests[d].end());
80
81 // Run sum
82 ASSERT_SUCCESS(af_scan(&outArray, inArray, d + off));
83
84 // Get result
85 To *outData;
86 outData = new To[dims.elements()];
87 ASSERT_SUCCESS(af_get_data_ptr((void *)outData, outArray));
88
89 size_t nElems = currGoldBar.size();
90 for (size_t elIter = 0; elIter < nElems; ++elIter) {
91 ASSERT_EQ(currGoldBar[elIter], outData[elIter])
92 << "at: " << elIter << " for dim " << d + off << endl;
93 }
94
95 // Delete
96 delete[] outData;
97 ASSERT_SUCCESS(af_release_array(outArray));
98 }
99
100 ASSERT_SUCCESS(af_release_array(inArray));
101}
102

Callers

nothing calls this directly

Calls 9

transformFunction · 0.50
af_create_arrayFunction · 0.50
af_indexFunction · 0.50
af_release_arrayFunction · 0.50
af_scanFunction · 0.50
af_get_data_ptrFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45
elementsMethod · 0.45

Tested by

no test coverage detected