Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Strange error doing 2-d convolution

greg_knoke
Beginner
314 Views

Hi, I'm attempting to do a 2-d convolution of a 1024x1024 array with a 3x3 kernel with 1024x1024 output. The vslsConvNewTask returns a status of 0, indicating the task was created successfully. However, vslsConvExec returns a status of 1048576, which isn't even a valid error code as far as I can find. I have tried running the convolution under the direct, fft, and auto modes and they all return the same result. Here's what the code itself looks like:

dims = 2;
xstride=1;
mode = VSL_CONV_MODE_AUTO
status = vslsConvNewTask(&task, mode, dims, xShape, yShape, zShape);
status2 = vslsConvExec(&task, input, xstride, kernel, xstride, output, xstride);

The code executes, but my output is an array of all 0s and I get the strange status code from vslsConvExec. I'm really at a loss to understand what's happening

0 Kudos
1 Reply
Yevgeny_Latkin__Inte
314 Views

Greg,

Please excuse me for the long delay; Ive overlooked your request.

About that piece of code you provide, I see two points which must cause C/C++ compiler to raise warnings.

First, the function vslsConvExec() expects the 1st parameter to be VSLConvTaskPtr, not the reference to VSLConvTaskPtr. That is, you need to replace the call:

status2 = vslsConvExec(&task, );

with:

status2 = vslsConvExec(task, );

Second, the functions vslsConvNewTask() and vslsConvExec() expect the shape and stride parameters to be integer arrays of the type int[], not scalars. In your example, the code might look like following:

int xShape[] = {1024,1024};

int yShape[] = {3,3};

int zShape[] = {1026,1026}; // 1026 = 1024 + 3 - 1

int mode = VSL_CONV_MODE_AUTO;

int dims = 2;

VSLConvTaskPtr task;

int status = vslsConvNewTask(&task, mode, dims, xShape, yShape, zShape);

int staus2 = vslsConvExec(task, input, NULL, kernel, NULL, output, NULL);

The NULL arrays instead of stride parameters cause MKL to process the da ta arrays with trivial strides. If you prefer assigning the strides explicitly, the code modification might look like following:

int xStride[] = {1,1024};

int yStride[] = {1,3};

int zStride[] = {1,1026};

int staus2 = vslsConvExec(task, input, zStride, kernel, yStride, output, zStride);

I hope these hints must help. Anyway, please let me know (via this Forum thread) if you have more questions about the MKL convolution and correlation software.

Thanks,

Yevgeny Latkin

0 Kudos
Reply