Skip to content

feat: add einsum support#37

Draft
vgene wants to merge 23 commits intomainfrom
feat/einsum
Draft

feat: add einsum support#37
vgene wants to merge 23 commits intomainfrom
feat/einsum

Conversation

@vgene
Copy link
Contributor

@vgene vgene commented Feb 28, 2026

Description of changes:

  • Add einsum support to NKIPy

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

jlonge4 and others added 23 commits January 17, 2026 22:30
Implements Einstein summation notation (einsum) for NKIPy, supporting:
- Matrix multiplication and batch operations (ij,jk->ik, bij,bjk->bik)
- Transpose and dimension permutation (ij->ji, ijk->kji)
- Reductions and trace operations (ij->, ii->)
- Outer products (i,j->ij)
- Broadcasting patterns (ij,j->ij)
- Complex tensor contractions (ijk,jkl->il)
- N-ary operations (i,ij,j->)

Implementation decomposes einsum patterns into HLO primitives:
- dot_general for contractions
- transpose for dimension reordering
- reduce for summations
- broadcast/multiply for outer products

Includes comprehensive tests covering all major einsum patterns
and examples demonstrating real-world usage including simplified
attention mechanisms.
This script tests various einsum operations using NumPy and NKIPy. It includes matrix multiplication, batch matrix multiplication, dot product, outer product, and more, verifying results against NumPy outputs.
@vgene vgene requested a review from a team February 28, 2026 06:28
@vgene vgene marked this pull request as draft February 28, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants