<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Hi, in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/1D-convolution-of-a-3D-array-using-Intel-MKL/m-p/1021961#M19725</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;When you do a rank=3 convolution on an array, that means all three shapes (x, y, and z) have rank=3. It is a error to give rank=2 kernel_shape to the task constructor, and this error cannot be reported by the constructor.&lt;/P&gt;

&lt;P&gt;The shape of the output for convolution should span range [Rmin...Rmax], or [ 0..nRow-1+n1Ker-1, 0..nCol-1+n2Ker-1, ...], according to the "Mathematical Notation and Definitions" subsection of MKL Reference Manual. The definition of convolved_shape does not conform to this rule.&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
	Dima&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Dec 2014 04:58:17 GMT</pubDate>
    <dc:creator>Dmitry_B_Intel</dc:creator>
    <dc:date>2014-12-16T04:58:17Z</dc:date>
    <item>
      <title>1D convolution of a 3D array using Intel MKL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/1D-convolution-of-a-3D-array-using-Intel-MKL/m-p/1021960#M19724</link>
      <description>&lt;P&gt;I have a 3D array which is stored in a columnwise fashion.&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;for( int k = 0; k &amp;lt; nTop; k++ ) // Loop through the tops. 
    for( int j = 0; j &amp;lt; nCol; j++ ) // Loop through the columns. 
        for( int i = 0; i &amp;lt; nRow; i++ ) // Loop through the rows 
        { 
            ijk = i + nRow * j + nRow * nCol * k; 
            my3Darray[ ijk ] = 1.0; 
        }&lt;/PRE&gt;

&lt;P&gt;I want to apply three different 1D kernels of size 2x1 across all the rows, all the columns, and all the tops of my 3D array separately and one after another.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;To be able to use Intel MKL, I read the MKL documentation which describes creating a new convolution or correlation task descriptor for multidimensional case. I carefully read "Mathematical Notation and Definitions" that talks about the notations used for convolution. I also read the example file named vslsconv_2d_auto.c. I am lost in the implementation of 1D convolution to a 3D array.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;The following code is my understanding from the documentation in a simple C code, which is the modified version of the example file vslsconv_2d_auto.c. In my code, I am trying to apply 1D convolution with kernel = [-1 1] on all the rows of the 3D array and get the convolved result which has the same size as the input. My array has a general size of nRow&lt;SPAN style="line-height: 19.5120010375977px;"&gt;×nCol×nTop. In the example code below, I chose the size to be&lt;/SPAN&gt;&amp;nbsp;3×4×5.&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;int main()
{

    VSLConvTaskPtr task;

    int nRow = 3, nCol = 4, nTop = 5;
    double *x = new double[nRow*nCol*nTop];

    int n1Ker = 2, n2Ker = 1;
    double *kernel = new double[ n1Ker*n2Ker ];

    double *xConvolved = new double[(nRow+n1Ker)*(nCol+n2Ker)*nTop];

    MKL_INT xshape[3]  = {nRow, nCol, nTop};
    MKL_INT convolved_shape[3] = {nRow, nCol, nTop};
    MKL_INT kernel_shape[2]= {2,1};
    
    MKL_INT rank=3;

    int status;

    for( int i = 0; i &amp;lt; nRow*nCol*nTop; i++ )
        x[ i ] = 1;
    
    kernel[ 0 ] = -1; kernel[ 1 ] =  1;

    int mode = VSL_CONV_MODE_AUTO;

    /* Create task descriptor (create descriptor of problem) */
    status = vsldConvNewTask(&amp;amp;task, mode, rank, xshape, kernel_shape, convolved_shape);
    if( status != VSL_STATUS_OK ){
    printf("ERROR: creation of job failed, exit with %d\n", status);
    return 1;}

    /* Execute task (Calculate 2 dimension convolution of two arrays)  */
    status = vsldConvExec(task, x, NULL, kernel, NULL, xConvolved, NULL);
    if( status != VSL_STATUS_OK ){
    printf("ERROR: job status bad, exit with %d\n", status);
    return 1;}
    
    /* Delete task object (delete descriptor of problem) */
    status = vslConvDeleteTask(&amp;amp;task);
    if( status != VSL_STATUS_OK ){
    printf("ERROR: failed to delete task object, exit with %d\n", status);
    return 1;}
    
    for( int i = 0; i &amp;lt; nRow*nCol*nTop; i++)
    printf("%f\n", xConvolved&lt;I&gt;); 
    
    delete[] x;
    delete[] xConvolved;
    delete[] kernel;

    return 0;
}&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;After running the code, I get the following error:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;ERROR: job status bad, exit with -2312&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;I would be thankful if my colleagues in the forum could let me know how I can fix this issue and help me find out how to correctly get 1D convolution of a 3D array on its rows, columns, or tops.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Dec 2014 16:52:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/1D-convolution-of-a-3D-array-using-Intel-MKL/m-p/1021960#M19724</guid>
      <dc:creator>A2009</dc:creator>
      <dc:date>2014-12-12T16:52:22Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/1D-convolution-of-a-3D-array-using-Intel-MKL/m-p/1021961#M19725</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;When you do a rank=3 convolution on an array, that means all three shapes (x, y, and z) have rank=3. It is a error to give rank=2 kernel_shape to the task constructor, and this error cannot be reported by the constructor.&lt;/P&gt;

&lt;P&gt;The shape of the output for convolution should span range [Rmin...Rmax], or [ 0..nRow-1+n1Ker-1, 0..nCol-1+n2Ker-1, ...], according to the "Mathematical Notation and Definitions" subsection of MKL Reference Manual. The definition of convolved_shape does not conform to this rule.&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
	Dima&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Dec 2014 04:58:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/1D-convolution-of-a-3D-array-using-Intel-MKL/m-p/1021961#M19725</guid>
      <dc:creator>Dmitry_B_Intel</dc:creator>
      <dc:date>2014-12-16T04:58:17Z</dc:date>
    </item>
  </channel>
</rss>

