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

Function sepConvolveTest

test/convolve.cpp:217–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215
216template<typename T>
217void sepConvolveTest(string pTestFile, bool expand) {
218 SUPPORTED_TYPE_CHECK(T);
219
220 vector<dim4> numDims;
221 vector<vector<T>> in;
222 vector<vector<T>> tests;
223
224 readTests<T, T, int>(pTestFile, numDims, in, tests);
225
226 dim4 sDims = numDims[0];
227 dim4 cfDims = numDims[1];
228 dim4 rfDims = numDims[2];
229 af_array signal = 0;
230 af_array c_filter = 0;
231 af_array r_filter = 0;
232 af_array outArray = 0;
233
234 ASSERT_SUCCESS(af_create_array(&signal, &(in[0].front()), sDims.ndims(),
235 sDims.get(),
236 (af_dtype)dtype_traits<T>::af_type));
237 ASSERT_SUCCESS(af_create_array(&c_filter, &(in[1].front()), cfDims.ndims(),
238 cfDims.get(),
239 (af_dtype)dtype_traits<T>::af_type));
240 ASSERT_SUCCESS(af_create_array(&r_filter, &(in[2].front()), rfDims.ndims(),
241 rfDims.get(),
242 (af_dtype)dtype_traits<T>::af_type));
243
244 af_conv_mode mode = expand ? AF_CONV_EXPAND : AF_CONV_DEFAULT;
245 ASSERT_SUCCESS(
246 af_convolve2_sep(&outArray, c_filter, r_filter, signal, mode));
247
248 vector<T> currGoldBar = tests[0];
249 size_t nElems = currGoldBar.size();
250 vector<T> outData(nElems);
251
252 ASSERT_SUCCESS(af_get_data_ptr((void *)&outData.front(), outArray));
253
254 for (size_t elIter = 0; elIter < nElems; ++elIter) {
255 ASSERT_EQ(currGoldBar[elIter], outData[elIter])
256 << "at: " << elIter << endl;
257 }
258
259 ASSERT_SUCCESS(af_release_array(outArray));
260 ASSERT_SUCCESS(af_release_array(signal));
261 ASSERT_SUCCESS(af_release_array(c_filter));
262 ASSERT_SUCCESS(af_release_array(r_filter));
263}
264
265TYPED_TEST(Convolve, Separable2D_Full) {
266 sepConvolveTest<TypeParam>(

Callers

nothing calls this directly

Calls 6

af_create_arrayFunction · 0.50
af_convolve2_sepFunction · 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