linalg: add kron - #262
Open
axiom-of-choice wants to merge 1 commit into
Open
Conversation
sbryngelson
approved these changes
Sep 2, 2026
sbryngelson
left a comment
Owner
There was a problem hiding this comment.
Verified on device (M5): the kron test passes, and the full linalg suite is unaffected.
The expand_dims/broadcast-multiply/reshape construction is the right shape for this, and
_check_precision=False matches the existing convention in this module (linalg.py:36, 360, 716).
Nothing to change.
One scheduling note: #259, #260 and this all append to the same __all__ block and the same tail
of linalg.py, so whichever lands first will force a rebase on the other two.
This was referenced Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
kron(A, B)toaneforge.linalg, built as a broadcast-multiply of expanded views plus a reshape (no new kernel):A.expand_dims((1, 3)) * B.expand_dims((0, 2))→[m, p, n, q], then reshape to[m*p, n*q].Closes #126.
Testing
test_kronintests/test_linalg.py(two non-square shapes) compares againstnp.kron; on-device M2 Pro: passed (max abs err 4.9e-4, ~half ULP fp16).ruff, pylint 2-space gate,pyright aneforge,compileallclean.