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

Function unwrapTest

test/unwrap.cpp:48–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47template<typename T>
48void unwrapTest(string pTestFile, const unsigned resultIdx, const dim_t wx,
49 const dim_t wy, const dim_t sx, const dim_t sy, const dim_t px,
50 const dim_t py) {
51 SUPPORTED_TYPE_CHECK(T);
52
53 vector<dim4> numDims;
54 vector<vector<T>> in;
55 vector<vector<T>> tests;
56 readTests<T, T, int>(pTestFile, numDims, in, tests);
57
58 dim4 idims = numDims[0];
59
60 af_array inArray = 0;
61 af_array outArray = 0;
62 af_array outArrayT = 0;
63 af_array outArray2 = 0;
64
65 ASSERT_SUCCESS(af_create_array(&inArray, &(in[0].front()), idims.ndims(),
66 idims.get(),
67 (af_dtype)dtype_traits<T>::af_type));
68
69 ASSERT_SUCCESS(af_unwrap(&outArray, inArray, wx, wy, sx, sy, px, py, true));
70 ASSERT_SUCCESS(
71 af_unwrap(&outArrayT, inArray, wx, wy, sx, sy, px, py, false));
72 ASSERT_SUCCESS(af_transpose(&outArray2, outArrayT, false));
73
74 size_t nElems = tests[resultIdx].size();
75 vector<T> outData(nElems);
76
77 // TODO: Change to ASSERT_VEC_ARRAY_EQ
78 // Compare is_column == true results
79 ASSERT_SUCCESS(af_get_data_ptr((void*)&outData[0], outArray));
80 for (size_t elIter = 0; elIter < nElems; ++elIter) {
81 ASSERT_EQ(tests[resultIdx][elIter], outData[elIter])
82 << "at: " << elIter << endl;
83 }
84
85 // Compare is_column == false results
86 ASSERT_SUCCESS(af_get_data_ptr((void*)&outData[0], outArray2));
87 for (size_t elIter = 0; elIter < nElems; ++elIter) {
88 ASSERT_EQ(tests[resultIdx][elIter], outData[elIter])
89 << "at: " << elIter << endl;
90 }
91
92 if (inArray != 0) af_release_array(inArray);
93 if (outArray != 0) af_release_array(outArray);
94 if (outArrayT != 0) af_release_array(outArrayT);
95 if (outArray2 != 0) af_release_array(outArray2);
96}
97
98#define UNWRAP_INIT(desc, file, resultIdx, wx, wy, sx, sy, px, py) \
99 TYPED_TEST(Unwrap, desc) { \

Callers

nothing calls this directly

Calls 7

af_create_arrayFunction · 0.50
af_unwrapFunction · 0.50
af_transposeFunction · 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