arrayfire-python
arrayfire-python copied to clipboard
Adding squeeze
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
At least until https://github.com/arrayfire/arrayfire/pull/1898 is merged and released
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 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.
Yeah reordering my code is probably the better idea :)