8000 Replace np.einsum('ijk,ikl->ijl') with np.matmul for performance gain in batch matrix multiplication · Issue #5 · abhi1kumar/groomed_nms · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Replace np.einsum('ijk,ikl->ijl') with np.matmul for performance gain in batch matrix multiplication #5
Open
@SaFE-APIOpt

Description

@SaFE-APIOpt

corners_3d = np.einsum('ijk,ikl->ijl', R, corners)

Hi 👋 I noticed this line:
corners_3d = np.einsum('ijk,ikl->ijl', R, corners)
This can be replaced with:
corners_3d = np.matmul(R, corners)

  • np.matmul is optimized for batch matrix multiplication using BLAS backends (like MKL/OpenBLAS).
  • np.einsum incurs more overhead and is significantly slower in this use case.
  • Benchmarks show 2–3x speedup and reduced memory overhead when switching to matmul.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0