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

Function DimCheck2D

test/index.cpp:328–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326
327template<typename T>
328void DimCheck2D(const vector<vector<af_seq>> &seqs, string TestFile,
329 size_t NDims) {
330 SUPPORTED_TYPE_CHECK(T);
331
332 vector<dim4> numDims;
333
334 vector<vector<T>> hData;
335 vector<vector<T>> tests;
336 readTests<T, T, int>(TestFile, numDims, hData, tests);
337 dim4 dimensions = numDims[0];
338
339 af_array a = 0;
340 ASSERT_SUCCESS(af_create_array(&a, &(hData[0].front()), NDims,
341 dimensions.get(),
342 (af_dtype)dtype_traits<T>::af_type));
343
344 vector<af_array> indexed_arrays(seqs.size(), 0);
345 for (size_t i = 0; i < seqs.size(); i++) {
346 ASSERT_SUCCESS(
347 af_index(&(indexed_arrays[i]), a, NDims, seqs[i].data()));
348 }
349
350 vector<T *> h_indexed(seqs.size(), NULL);
351 for (size_t i = 0; i < seqs.size(); i++) {
352 dim_t elems;
353 ASSERT_SUCCESS(af_get_elements(&elems, indexed_arrays[i]));
354 h_indexed[i] = new T[elems];
355 ASSERT_SUCCESS(
356 af_get_data_ptr((void *)h_indexed[i], indexed_arrays[i]));
357
358 T *ptr = h_indexed[i];
359 if (false == equal(ptr, ptr + tests[i].size(), tests[i].begin())) {
360 cout << "index data: ";
361 copy(ptr, ptr + tests[i].size(), ostream_iterator<T>(cout, ", "));
362 cout << endl << "file data: ";
363 copy(tests[i].begin(), tests[i].end(),
364 ostream_iterator<T>(cout, ", "));
365 FAIL() << "indexed_array[" << i << "] FAILED" << endl;
366 }
367 delete[] h_indexed[i];
368 }
369
370 ASSERT_SUCCESS(af_release_array(a));
371 for (size_t i = 0; i < indexed_arrays.size(); i++) {
372 ASSERT_SUCCESS(af_release_array(indexed_arrays[i]));
373 }
374}
375
376TYPED_TEST_SUITE(Indexing2D, AllTypes);
377

Callers

nothing calls this directly

Calls 7

af_get_elementsFunction · 0.85
af_create_arrayFunction · 0.50
af_indexFunction · 0.50
af_get_data_ptrFunction · 0.50
copyFunction · 0.50
af_release_arrayFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected