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

Function fftconvolveTest

test/fftconvolve.cpp:52–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51template<typename T, int baseDim>
52void fftconvolveTest(string pTestFile, bool expand) {
53 SUPPORTED_TYPE_CHECK(T);
54
55 vector<dim4> numDims;
56 vector<vector<T>> in;
57 vector<vector<T>> tests;
58
59 readTests<T, T, int>(pTestFile, numDims, in, tests);
60
61 dim4 sDims = numDims[0];
62 dim4 fDims = numDims[1];
63 af_array signal = 0;
64 af_array filter = 0;
65 af_array outArray = 0;
66 af_dtype in_type = (af_dtype)dtype_traits<T>::af_type;
67
68 ASSERT_SUCCESS(af_create_array(&signal, &(in[0].front()), sDims.ndims(),
69 sDims.get(), in_type));
70 ASSERT_SUCCESS(af_create_array(&filter, &(in[1].front()), fDims.ndims(),
71 fDims.get(), in_type));
72
73 af_conv_mode mode = expand ? AF_CONV_EXPAND : AF_CONV_DEFAULT;
74 switch (baseDim) {
75 case 1:
76 ASSERT_SUCCESS(af_fft_convolve1(&outArray, signal, filter, mode));
77 break;
78 case 2:
79 ASSERT_SUCCESS(af_fft_convolve2(&outArray, signal, filter, mode));
80 break;
81 case 3:
82 ASSERT_SUCCESS(af_fft_convolve3(&outArray, signal, filter, mode));
83 break;
84 }
85
86 vector<T> currGoldBar = tests[0];
87 size_t nElems = currGoldBar.size();
88
89 dim_t out_elems = 0;
90 ASSERT_SUCCESS(af_get_elements(&out_elems, outArray));
91 ASSERT_EQ(nElems, (size_t)out_elems);
92
93 vector<T> outData(nElems);
94
95 ASSERT_SUCCESS(af_get_data_ptr((void*)&outData.front(), outArray));
96
97 for (size_t elIter = 0; elIter < nElems; ++elIter) {
98 ASSERT_NEAR(real(currGoldBar[elIter]), real(outData[elIter]), 1e-2)
99 << "at: " << elIter << endl;
100 }
101
102 ASSERT_SUCCESS(af_release_array(outArray));
103 ASSERT_SUCCESS(af_release_array(signal));
104 ASSERT_SUCCESS(af_release_array(filter));
105}
106
107template<typename T, int baseDim>
108void fftconvolveTestLarge(int sDim, int fDim, int sBatch, int fBatch,

Callers

nothing calls this directly

Calls 10

af_fft_convolve1Function · 0.85
af_fft_convolve2Function · 0.85
af_fft_convolve3Function · 0.85
af_get_elementsFunction · 0.85
realFunction · 0.70
af_create_arrayFunction · 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