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

2D Convolution return wrong result

Emad_B_
Beginner
285 Views

I am new to MKL, so this might be a stupid mistake. I am trying to convolve 2D 1024x1024 array with its elements set to 5 with 3x3 kernel with its element set to 1. The expected result is 45 everywhere except the boundary, however, I am getting positive and negative very small fraction close to zero, and all returned status code are ok.

Here a simple repro:

    int status = VSL_STATUS_OK;
    int mode = VSL_CONV_MODE_FFT; //VSL_CONV_MODE_AUTO; // VSL_CONV_MODE_DIRECT;
    int xstride[] = {1, 1024};
    int ystride[] = {1, 3};
    int zstride[] = {1, 1026};
    int xshape[] = {1024, 1024};
    int yshape[] = {3, 3};
    int zshape[] = {1026, 1026};
    int offset[] = {0, 0};

    double* x = new double[1024*1024];
    for (int i = 0; i < (1024*1024); i++) {
        x = 5.0;
    }

    double* y = new double[3*3];
    for (int i = 0; i < (3*3); i++) {
        y = 1.0;
    }

    double* z = new double[1026*1026];
    memset((void*)z, 0, 1026*1026*sizeof(double));

    VSLConvTaskPtr task;
    status = vslsConvNewTask(&task, mode, 2, xshape, yshape, zshape);
    assert(status == VSL_STATUS_OK);

    status = vslConvSetStart(task, offset);
    assert(status == VSL_STATUS_OK);

    status = vsldConvExec(task, x, xstride, y, ystride, z, zstride);
    assert(status == VSL_STATUS_OK);

    vslConvDeleteTask(&task);

    delete[] x;

   delete[] y;

   delete[] z;

 

0 Kudos
2 Replies
Evgueni_P_Intel
Employee
285 Views

Hi Emad B.,

Since d means double, s means single, please use vsldConvNewTask.

Evgueni

0 Kudos
Emad_B_
Beginner
285 Views

Thanks Evgueni, that's did it.

0 Kudos
Reply