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

vsldConvExecX in 2D/3D

csnatarajan
Beginner
168 Views
Hello all,
Is there an example code for 2D or 3D convolution using vsldConvExecX? I am not sure I understand the documentation (Ch. 10 in MKL doc.). It seems like I cannot pass a dynamically allocated 2D array to vsldConvExecX. Is this correct? If so do I just pass a 1D array (with the usual pointer arithmetic to access elements in i,j fashion?)? If so what do the strides and shapes look like?

I have something like this
.........

VSLConvTaskPtr task;
MKL_INT rank,mode,xshape[2],yshape[2],zshape[2];
static double x[sx*sx],y[sy*sy],z[sz*sz];
MKL_INT xstride[2],ystride[2],zstride[2];
int status,i;

xshape[0] = xshape[1] = sx; yshape[0] = yshape[1] = sy; zshape[0] = zshape[1] = sz;

xstride[0] = 1; xstride[1] = sx; ystride[0] = 1; ystride[1] = sy; zstride[0] = 1; zstride[1] = ??

for (i=0; i<(sx*sx); i++)
x=i*i;
for (i=0; i<(sy*sy); i++)
y = 1;

rank = 1;
mode = VSL_CONV_MODE_AUTO;

status = vsldConvNewTask(&task,mode,rank,xshape,yshape,zshape);
...
status = vsldConvExecX(task,y,ystride,z,zstride);

........

I am unsure what zstride[1] will be. Also, I am thinking that sz would be the same size as the input signal, is this ok?

Please let me know if I am messing up the code real bad and what is the correct way to proceed.

Thanks in advance,

C.S.N

0 Kudos
1 Solution
Victor_Gladkikh
New Contributor I
168 Views

Hi C.S.N.

// First of allI recommend set
rank=2; //It's 2D problem

// Also
sz = sx + sy - 1; //sznot equal to sx or sy; szequal or more then sx + sy - 1
zstride[1] = sz;

Best regards
Victor

View solution in original post

3 Replies
VipinKumar_E_Intel
168 Views

Pleaserefer the VSL convolution examples provided in the /examples/vslc/source folder.

--Vipin

Victor_Gladkikh
New Contributor I
169 Views

Hi C.S.N.

// First of allI recommend set
rank=2; //It's 2D problem

// Also
sz = sx + sy - 1; //sznot equal to sx or sy; szequal or more then sx + sy - 1
zstride[1] = sz;

Best regards
Victor

csnatarajan
Beginner
168 Views
Hello Victor and vipin,
thanks for the response.

Vipin, there are no multidimensional example provided! In fact vslConvExecX is used on a 1d array!

Victor, sorry for the spasm! Of course it should be (sx-1) + (sy-1) + 1 and yes thanks for pointing out the rank = 2 and zstride. I changed them as suggested. The last few pages on the doc I didn't read too thoroughly were very useful! Also had to change to vsldConvNewTaskX from vsldConvNewTask!!

Best,

C.S.N


Reply