10BC0 Consider linking einsum and move axis · Issue #11658 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Consider linking einsum and move axis #11658
@eric-wieser

Description

@eric-wieser

Brought up by this comment, it turns out that einsum actually is another name for moveaxis, and is 10 times faster

a = np.zeros((10, 20, 30))

%timeit np.einsum('abc->cba', a)
2.24 µs ± 375 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

%timeit np.einsum(a, [0, 1, 2], [2, 1, 0])
2.65 µs ± 132 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

%timeit np.moveaxis(a, [0, 1, 2], [2, 1, 0])
22.1 µs ± 3.47 µs per loop (mean ± std. dev. of 7 runs, 100000 loops each)

Perhaps we should take advantage of this, especally since it would counteract the performance cost of #9475

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0