Add sparse tensor primitives with einsum contraction#48
Open
imlvts wants to merge 2 commits intotrueagi-io:mainfrom
Open
Add sparse tensor primitives with einsum contraction#48imlvts wants to merge 2 commits intotrueagi-io:mainfrom
imlvts wants to merge 2 commits intotrueagi-io:mainfrom
Conversation
Integrate N-dimensional sparse tensors into MORK expressions: - SparseTensorF64: PathMap-backed sparse tensor with BOB encoding, arbitrary rank, element-wise add/mul via lattice operations - einsum-dyn: copied into workspace as local crate, runtime Einstein summation with VM compiler supporting arbitrary N-D specs - Tensor sinks (tensor_collect, tensor_einsum, tensor_add, tensor_mul, tensor_free) using WriteResource::TensorStore through the standard resource infrastructure — no thread-locals - tensor_get/tensor_nnz pure functions via ExprSource.context pointer propagated through EvalScope - End-to-end test: load matrix data as S-expressions, collect into tensors via exec, einsum multiply, verify result MeTTa usage: (exec P1 (, (a $r $c $v)) (O (tensor_collect A $r $c $v))) (exec P2 (,) (O (tensor_einsum "ab,bc->ac" A B C))) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- tensor_get now parses indices from string symbols (not binary u32), matching how MeTTa S-expressions encode numbers - End-to-end test exercises full pipeline: load data → tensor_collect → tensor_einsum → tensor_get to verify C[0,0]=19.0 and C[1,1]=50.0 - TensorEinsumSink strips quotes from spec string - Command sinks (einsum, binop, free) parse args in new() for literal templates, or in sink() for variable-bound templates Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Integrate N-dimensional sparse tensors into MORK expressions:
MeTTa usage: