ArrayFire.jl icon indicating copy to clipboard operation
ArrayFire.jl copied to clipboard

Feature request: slice/slices, mapslices

Open ngphuoc opened this issue 8 years ago • 8 comments

Could we have this feature in julia: http://arrayfire.org/docs/group__array__mem__slice.htm? And does it allow mapslices into AFArray?

ngphuoc avatar Dec 06 '17 23:12 ngphuoc

That's just an alias to indexing, so slice(a, i) = a[:, :, i]

ghost avatar Dec 07 '17 00:12 ghost

Thanks. In that case, could you support create_seq(::Base.Slice{Base.OneTo{Int64}})? Then mapslices should work!

ngphuoc avatar Dec 07 '17 00:12 ngphuoc

I don't think that's enough to support mapslices :(

ghost avatar Dec 07 '17 00:12 ghost

Thanks, I've added mapslices to the title. Is it likely to be supported in the near future? It seems useful.

ngphuoc avatar Dec 07 '17 00:12 ngphuoc

Can current ArrayFire.jl do similarly to the following C++ code snippet?

int n = 8, int m = 8;   // dimensions
int t = 10;             // number of different matricies
array A = randu(m,n,t); // many matricies
array B = randu(m,n);   // one matrix
array C = zeros(m,n,t); // destination

// multiply C=A*B for all A, at the same time
gfor (array i, A.dims(2)) {
   C(span,span,i) = matmul(A(span,span,i), B);
}

print( A );
print( B );
print( C );

ref: https://stackoverflow.com/questions/13051326/multiplying-hundreds-of-matrices-using-cuda

ngphuoc avatar Apr 04 '18 01:04 ngphuoc

a = rand(AFArray, 3, 3, 9)
b = rand(AFArray, 3, 3, 9)
a * b

Would do 9 matrix multiplies of 3x3 slices

ghost avatar Apr 04 '18 02:04 ghost

Many thanks!

ngphuoc avatar Apr 04 '18 02:04 ngphuoc

You might need the latest version of ArrayFire for this to work, was only added recently https://github.com/arrayfire/arrayfire/pull/1898

ghost avatar Apr 04 '18 02:04 ghost