gfor with convolve gives error

[Old posts from the commercial version of ArrayFire] Discussion of ArrayFire using CUDA or OpenCL.

Moderator: pavanky

gfor with convolve gives error

Postby rm9 » Fri May 16, 2014 2:29 am

Hi,

I have a loop of convolve and I'm trying to replace it with gfor with the latest ArrayFire 2.1 release.
I get the following error with gfor:
"src/gena/conv.cpp:47: error: Inputs must be of same dimension"

The dimensions of the matrices are:
a dims=[64 10 64]
flipped_delta(span, span, j) dims=[59 10]

This is my code:
Code: Select all
   for (int j = 0; j < W.dims(2); ++j) {
   //gfor(array j, W.dims(2)) {
      array c_result =
         ConvolveValid3d2d(a, flipped_delta(span, span, j));
      c_result = reorder(c_result, 0, 2, 1);
      (*dW)(span, span, j) = flip(flip(c_result, 0), 1) / delta.dims(2);
   }


this is my ConvolveValid3d2d function:
Code: Select all
array ConvLayer::ConvolveValid3d2d(const array& a, const array& b) {
   array c = convolve(a, b, true);
   int output_size0 = a.dims(0) - b.dims(0) + 1;
   int output_size1 = a.dims(1) - b.dims(1) + 1;
   int full_size0 = a.dims(0) + b.dims(0) - 1;
   int full_size1 = a.dims(1) + b.dims(1) - 1;
   int start0 = floor(float(full_size0 - output_size0) / 2);
   int start1 = floor(float(full_size1 - output_size1) / 2);
   c = c(seq(start0, start0 + output_size0 - 1), seq(start1, start1 + output_size1 - 1), span);
   return c;
}


The for-loop works fine, but with gfor it gives the error.
Thanks.
rm9
 
Posts: 54
Joined: Thu Jan 30, 2014 5:44 am

Re: gfor with convolve gives error

Postby rm9 » Sun May 25, 2014 12:05 pm

I added the dimensions of the matrices.
Any help? Thanks.
rm9
 
Posts: 54
Joined: Thu Jan 30, 2014 5:44 am

Re: gfor with convolve gives error

Postby rm9 » Sat May 31, 2014 4:18 am

Am I the only one having this error?
rm9
 
Posts: 54
Joined: Thu Jan 30, 2014 5:44 am

Re: gfor with convolve gives error

Postby rm9 » Sat Jun 21, 2014 4:18 am

I tried to debug the code some more and I saw that gfor doesn't work if one matrix is 3d and the other is 2d.
rm9
 
Posts: 54
Joined: Thu Jan 30, 2014 5:44 am

Re: gfor with convolve gives error

Postby pavanky » Mon Jun 23, 2014 1:01 pm

Hi,

Since convolve is used for both 2d and 3d convolution, it is hard for us to figure out what is the intended convolution you are looking for in this particular case. We've tried to handle as many cases as we can, but this does not seem feasible right now.
Pavan Yalamanchili,
ArrayFire
--
~ If it is not broken, you have not tried hard enough ~
User avatar
pavanky
Site Admin
 
Posts: 1123
Joined: Mon Mar 15, 2010 7:39 pm
Location: Atlanta, GA

Re: gfor with convolve gives error

Postby rm9 » Mon Jun 23, 2014 1:47 pm

You're right.
Is it possible to add a flag to tell which convolution to perform?
It's a waste that I can't use gfor. My convolutions are relatively small and I assume most of my gpu cores are idle.
rm9
 
Posts: 54
Joined: Thu Jan 30, 2014 5:44 am


Return to [archive-commercial] Programming & Development with ArrayFire

cron