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

Function joinTest

test/join.cpp:59–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57
58template<typename T>
59void joinTest(string pTestFile, const unsigned dim, const unsigned in0,
60 const unsigned in1, const unsigned resultIdx,
61 bool isSubRef = false, const vector<af_seq>* seqv = NULL) {
62 SUPPORTED_TYPE_CHECK(T);
63
64 vector<dim4> numDims;
65 vector<vector<T>> in;
66 vector<vector<T>> tests;
67 readTests<T, T, int>(pTestFile, numDims, in, tests);
68
69 dim4 i0dims = numDims[in0];
70 dim4 i1dims = numDims[in1];
71
72 af_array in0Array = 0;
73 af_array in1Array = 0;
74 af_array outArray = 0;
75 af_array tempArray = 0;
76
77 if (isSubRef) {
78 ASSERT_SUCCESS(af_create_array(&tempArray, &(in[in0].front()),
79 i0dims.ndims(), i0dims.get(),
80 (af_dtype)dtype_traits<T>::af_type));
81
82 ASSERT_SUCCESS(
83 af_index(&in0Array, tempArray, seqv->size(), &seqv->front()));
84 } else {
85 ASSERT_SUCCESS(af_create_array(&in0Array, &(in[in0].front()),
86 i0dims.ndims(), i0dims.get(),
87 (af_dtype)dtype_traits<T>::af_type));
88 }
89
90 if (isSubRef) {
91 ASSERT_SUCCESS(af_create_array(&tempArray, &(in[in1].front()),
92 i1dims.ndims(), i1dims.get(),
93 (af_dtype)dtype_traits<T>::af_type));
94
95 ASSERT_SUCCESS(
96 af_index(&in1Array, tempArray, seqv->size(), &seqv->front()));
97 } else {
98 ASSERT_SUCCESS(af_create_array(&in1Array, &(in[in1].front()),
99 i1dims.ndims(), i1dims.get(),
100 (af_dtype)dtype_traits<T>::af_type));
101 }
102
103 ASSERT_SUCCESS(af_join(&outArray, dim, in0Array, in1Array));
104
105 dim4 goldDims = i0dims;
106 goldDims[dim] = i0dims[dim] + i1dims[dim];
107
108 ASSERT_VEC_ARRAY_EQ(tests[resultIdx], goldDims, outArray);
109
110 if (in0Array != 0) af_release_array(in0Array);
111 if (in1Array != 0) af_release_array(in1Array);
112 if (outArray != 0) af_release_array(outArray);
113 if (tempArray != 0) af_release_array(tempArray);
114}
115
116#define JOIN_INIT(desc, file, dim, in0, in1, resultIdx) \

Callers

nothing calls this directly

Calls 6

af_create_arrayFunction · 0.50
af_indexFunction · 0.50
af_joinFunction · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected