Description
We have found that many applications want 3d arrays, and some may need arrays of even higher dimensions.
This is typically handled by stacking arrays such that a single dimension of a GraphBLAS Matrix encodes multiple logical dimensions of a tensor. Performing operations between such objects often requires reorganizing the data so the logical axes align. This is awkward to do today. Can we make it easier?
One option is to add something like np.moveaxis
(https://numpy.org/doc/stable/reference/generated/numpy.moveaxis.html). To make this general, I think we would need to include how the dimensinos of the logical tensor are encoded in Vector or Matrix dimensions, and then how to reorganize it. Some operations--particularly in 3D--can probably be optimized pretty well, and we should try to make things fast when possible.
A quarter-baked proposal may look something like this: A.reorganize(src_shape=((2, 3), (4,2)), dst_axes=((0, 1), (3, 2)))
. This effectively does a transpose by swapping the last two axes. It may be more natural at times to think in terms of source shape and source indices, or in terms of destination shape and indices (or some mix of the two). This has the potential of being confusing in general, but should hopefully make sense when you actually have data that you need to manipulate.
How far would such an operation go to making python-graphblas
more usable for tensors? What else do we need for common use cases?