sparse icon indicating copy to clipboard operation
sparse copied to clipboard

COO.transpose() is not cheap

Open eric-wieser opened this issue 4 years ago • 3 comments

Transposing a COO array results in a reordering of all the data elements.

Would it be possible to avoid doing this?

eric-wieser avatar Mar 03 '20 14:03 eric-wieser

One way would be to make a small "library"/submodule that handled views of COO. But I cannot think of a clean way without breaking the current guarantee that COO will always have ordered elements.

We were evaluating using the TACO compiler, (#326) which would in theory make this O(1), but that's an even larger undertaking, and at least with my current knowledge, beyond my skills.

hameerabbasi avatar Mar 03 '20 14:03 hameerabbasi

without breaking the current guarantee that COO will always have ordered elements

You could relax the guarantee to "Elements of self.transpose(self._axis_order)" are ordered, which would mean storing an extra property.

eric-wieser avatar Mar 03 '20 15:03 eric-wieser

You could define a TransposedCOO wrapper class that re-writes axes before passing through to the underlying COO class. This is essentially the approach we use for CSR/CSC matrices in scipy.sparse.

perimosocordiae avatar Mar 03 '20 15:03 perimosocordiae