feat: block tensor literal syntax [ta; tb], (ta, tb), [|ta; tb|]#450
Open
lukstafi wants to merge 4 commits intoahrefs:masterfrom
Open
feat: block tensor literal syntax [ta; tb], (ta, tb), [|ta; tb|]#450lukstafi wants to merge 4 commits intoahrefs:masterfrom
lukstafi wants to merge 4 commits intoahrefs:masterfrom
Conversation
e36082a to
f3ace5b
Compare
Add syntactic sugar for constructing block tensors from component tensors using OCaml list/tuple/array notation inside %op blocks. Lists stack along a new leading output axis, tuples along input axis (top-level only), and arrays along batch axis. Implementation: first-leaf disambiguation (numeric → ndarray constant, non-numeric → block tensor), two-step unsqueeze via einsum1 + concat. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add Concat-Concat element-wise unification case to row.ml's unify_dim, allowing the shape solver to equate structurally-matching Concat dimensions from inner block tensor results when used in outer block tensors. Update test and docs to demonstrate direct nesting (2x2 block matrix). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f3ace5b to
0406075
Compare
Collaborator
Author
|
@codex review Focus on bugs, correctness issues, and edge cases. Do not check adherence to a spec or plan. |
Add ndarray constant regressions (tuple, list, array) to pin the first-leaf disambiguation heuristic, and a tuple-in-apply test to lock Pexp_apply tuple preservation. Remove "upcoming"/"planned" wording from syntax_extensions.md, migration_guide.md, and slides-shapes_and_einsum.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The output-axis concat spec "bt0,...; bt1,..." dropped batch and input rows, causing shape errors when list block tensor components had input or batch axes. Use the full spec "...|...-> bt0,...; ..." to broadcast batch/input rows through concatenation. Add test 13 exercising list block tensors with input-dim components. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Open
4 tasks
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.
Summary
%opPPX:[ta; tb](output axis),(ta, tb)(input axis),[|ta; tb|](batch axis)[[ta; tb]; [tc; td]]constructs 2x2 block matricesTest plan
dune build @checkpassesdune runtestpasses (only pre-existing unrelated failures)test_block_tensor.mlcovering: list/array/tuple block tensors, 3-way, nesting, single-element, 2-way and 3-way gradient flow, ndarray constant regressions, tuple-in-apply preservationtest_concat_graph,test_concat_ppx,small_literal_tensorpass unchanged🤖 Generated with Claude Code