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

Function testGeneralIndexOneArray

test/gen_index.cpp:139–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139void testGeneralIndexOneArray(string pTestFile, const dim_t ndims,
140 af_index_t *indexs, int arrayDim) {
141 vector<dim4> numDims;
142 vector<vector<float>> in;
143 vector<vector<float>> tests;
144
145 readTestsFromFile<float, float>(pTestFile, numDims, in, tests);
146
147 dim4 dims0 = numDims[0];
148 dim4 dims1 = numDims[1];
149 af_array outArray = 0;
150 af_array inArray = 0;
151 af_array idxArray = 0;
152
153 ASSERT_SUCCESS(af_create_array(&inArray, &(in[0].front()), dims0.ndims(),
154 dims0.get(),
155 (af_dtype)dtype_traits<float>::af_type));
156
157 ASSERT_SUCCESS(af_create_array(&idxArray, &(in[1].front()), dims1.ndims(),
158 dims1.get(),
159 (af_dtype)dtype_traits<float>::af_type));
160 indexs[arrayDim].idx.arr = idxArray;
161
162 ASSERT_SUCCESS(af_index_gen(&outArray, inArray, ndims, indexs));
163
164 vector<float> currGoldBar = tests[0];
165 size_t nElems = currGoldBar.size();
166 vector<float> outData(nElems);
167
168 ASSERT_SUCCESS(af_get_data_ptr((void *)outData.data(), outArray));
169
170 for (size_t elIter = 0; elIter < nElems; ++elIter) {
171 ASSERT_EQ(currGoldBar[elIter], outData[elIter])
172 << "at: " << elIter << endl;
173 }
174
175 ASSERT_SUCCESS(af_release_array(inArray));
176 ASSERT_SUCCESS(af_release_array(idxArray));
177 ASSERT_SUCCESS(af_release_array(outArray));
178}
179
180TEST(GeneralIndex, ASSS) {
181 af_index_t indexs[4];

Callers 1

TESTFunction · 0.85

Calls 6

af_create_arrayFunction · 0.50
af_index_genFunction · 0.50
af_get_data_ptrFunction · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected