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

Function fftconvolveTestLarge

test/fftconvolve.cpp:108–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106
107template<typename T, int baseDim>
108void fftconvolveTestLarge(int sDim, int fDim, int sBatch, int fBatch,
109 bool expand) {
110 SUPPORTED_TYPE_CHECK(T);
111
112 using af::seq;
113
114 int outDim = sDim + fDim - 1;
115 int fftDim = (int)pow(2, ceil(log2(outDim)));
116
117 int sd[4], fd[4];
118 for (int k = 0; k < 4; k++) {
119 if (k < baseDim) {
120 sd[k] = sDim;
121 fd[k] = fDim;
122 } else if (k == baseDim) {
123 sd[k] = sBatch;
124 fd[k] = fBatch;
125 } else {
126 sd[k] = 1;
127 fd[k] = 1;
128 }
129 }
130
131 const dim4 signalDims(sd[0], sd[1], sd[2], sd[3]);
132 const dim4 filterDims(fd[0], fd[1], fd[2], fd[3]);
133
134 array signal = randu(signalDims, (af_dtype)dtype_traits<T>::af_type);
135 array filter = randu(filterDims, (af_dtype)dtype_traits<T>::af_type);
136
137 array out =
138 fftConvolve(signal, filter, expand ? AF_CONV_EXPAND : AF_CONV_DEFAULT);
139
140 array gold;
141 switch (baseDim) {
142 case 1:
143 gold = real(ifft(fft(signal, fftDim) * fft(filter, fftDim)));
144 break;
145 case 2:
146 gold = real(ifft2(fft2(signal, fftDim, fftDim) *
147 fft2(filter, fftDim, fftDim)));
148 break;
149 case 3:
150 gold = real(ifft3(fft3(signal, fftDim, fftDim, fftDim) *
151 fft3(filter, fftDim, fftDim, fftDim)));
152 break;
153 default: ASSERT_LT(baseDim, 4);
154 }
155
156 int cropMin = 0, cropMax = 0;
157 if (expand) {
158 cropMin = 0;
159 cropMax = outDim - 1;
160 } else {
161 cropMin = fDim / 2;
162 cropMax = outDim - fDim / 2 - 1;
163 }
164
165 switch (baseDim) {

Callers

nothing calls this directly

Calls 13

powFunction · 0.85
ceilFunction · 0.85
log2Function · 0.85
randuFunction · 0.85
fftConvolveFunction · 0.85
ifftFunction · 0.85
ifft2Function · 0.85
fft2Function · 0.85
ifft3Function · 0.85
fft3Function · 0.85
seqClass · 0.85
realFunction · 0.70

Tested by

no test coverage detected