arrayfire-python icon indicating copy to clipboard operation
arrayfire-python copied to clipboard

Adding squeeze

Open georgh opened this issue 6 years ago • 4 comments

Would be nice to have a wrapper for squeeze.

Without squeeze, matmul usage is quite limited because if will fail for all slices of bigger matrices. Example:

import arrayfire as af
x = af.constant(0, 10, 5, 5, dtype=af.Dtype.f64)
af.matmul(x[0,:,:],x[1,:,:]) # will fail because only matrices with two dimensions are allowed

georgh avatar Nov 27 '17 14:11 georgh

At least until https://github.com/arrayfire/arrayfire/pull/1898 is merged and released

georgh avatar Nov 27 '17 14:11 georgh

And I found out that you can reduce the dimension if you order your data the right way:

x = af.constant(0, 5, 5, 10, dtype=af.Dtype.f64)
af.matmul(x[:,:,0],x[:,:,0]) #works

georgh avatar Nov 27 '17 16:11 georgh

@georgh arrayfire is column major. The code that works for you is more efficient than the code you show in the issue description.

Nevertheless squeeze may be something that could be implemented.

pavanky avatar Nov 27 '17 18:11 pavanky

Yeah reordering my code is probably the better idea :)

georgh avatar Nov 27 '17 23:11 georgh