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

Function af_convolve2_nn

src/api/c/convolve.cpp:344–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342}
343
344af_err af_convolve2_nn(af_array *out, const af_array signal,
345 const af_array filter, const unsigned stride_dims,
346 const dim_t *strides, const unsigned padding_dims,
347 const dim_t *paddings, const unsigned dilation_dims,
348 const dim_t *dilations) {
349 try {
350 const ArrayInfo &sInfo = getInfo(signal);
351 const ArrayInfo &fInfo = getInfo(filter);
352
353 af::dim4 sDims = sInfo.dims();
354 af::dim4 fDims = fInfo.dims();
355
356 const af_dtype signalType = sInfo.getType();
357
358 dim4 stride(stride_dims, strides);
359 dim4 padding(padding_dims, paddings);
360 dim4 dilation(dilation_dims, dilations);
361
362 size_t stride_ndims = stride.ndims();
363 size_t padding_ndims = padding.ndims();
364 size_t dilation_ndims = dilation.ndims();
365 ARG_ASSERT(3, stride_ndims > 0 && stride_ndims <= 2);
366 ARG_ASSERT(5, padding_ndims >= 0 && padding_ndims <= 2);
367 ARG_ASSERT(7, dilation_ndims > 0 && dilation_ndims <= 2);
368
369 // assert number of features matches between signal and filter
370 DIM_ASSERT(1, sDims[2] == fDims[2]);
371
372 af_array output;
373 switch (signalType) {
374 case f32:
375 output = convolve2Strided<float>(signal, filter, stride,
376 padding, dilation);
377 break;
378 case f64:
379 output = convolve2Strided<double>(signal, filter, stride,
380 padding, dilation);
381 break;
382 case f16:
383 output = convolve2Strided<half>(signal, filter, stride, padding,
384 dilation);
385 break;
386 default: TYPE_ERROR(1, signalType);
387 }
388 std::swap(*out, output);
389 }
390 CATCHALL;
391 return AF_SUCCESS;
392}
393
394template<typename T>
395af_array conv2GradCall(const af_array incoming_gradient,

Callers 2

convolve2stridedTestFunction · 0.50
convolve2NNFunction · 0.50

Calls 4

swapFunction · 0.85
dimsMethod · 0.45
getTypeMethod · 0.45
ndimsMethod · 0.45

Tested by

no test coverage detected