arrayfire / arrayfire-dotnet

.NET wrapper for ArrayFire
BSD 3-Clause "New" or "Revised" License
78 stars 21 forks source link

Feature Request #10

Open gualandri43 opened 8 years ago

gualandri43 commented 8 years ago

Are there plans to implement ArrayFire's GFOR capability in this wrapper? I noticed a "broadcast" function in the python wrapper that looks similar.

shehzan10 commented 8 years ago

Most of the functions that are supported in GFor also normally support batching. For example, if you wanted to do a convolve on a 2D image, you can have multiple 2D images batching into a 3D array and run the convolve on that. Is there any specific function that you would like supported?

gualandri43 commented 8 years ago

Essentially what I am looking to do is pretty simple, add different size arrays together(i.e. a 3 row x 1 col array + 3 row by 5 col array, add the 3x1 to each column of the 3x5) or perform a custom function on all rows of an array. I.e., apply function f(x1,x2,x3,x4,x5) to n times to rows of array y[n row x 5 cols]. I apologize if this functionality can be accomplished with functions already implemented, I am a newbie in regards to ArrayFire, but looking to learn!

pavanky commented 8 years ago

@gualandri43 In these cases tile should do it. It does not actually replicate the arrays but just changes the metdata.

I am giving the example in C++, you can probably figure it for C#.

array a = randu(3,1);
array b = randu(3, 5);
array c = tile(a, 1, 5) + b;

This works.

Alternatively, there is a function called batchFunc in arrayfire that can be used if ported.

array a = randu(3, 1);
array b = randu(3, 5);
array c = batchFunc(a, b, [](const array &aa, const array &bb){ return aa + bb;});
gualandri43 commented 8 years ago

@pavanky Thank you for the suggestion about tiling, that should take care of the first part quite nicely.

batchFunc looks exactly like what I was thinking for the second part (apply custom function across rows of array). Is that able to be ported over?

pavanky commented 8 years ago

@gualandri43 you shouldn't need either GFOR or batchfunc for the second part. All our functions work on all the vectors in parallel.

If you have a specific code that you are having a problem with, drop by on our chat room and we'll see if we can help you out: https://gitter.im/arrayfire/arrayfire

gualandri43 commented 8 years ago

Alright, I will experiment further and see what I can figure out. Thanks again!