feat: block tensor literal syntax [ta; tb], (ta, tb), [|ta; tb|] in %op#10
feat: block tensor literal syntax [ta; tb], (ta, tb), [|ta; tb|] in %op#10
Conversation
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>
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>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ba7d3bd6b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| | `Output -> | ||
| String.concat ~sep:"; " (List.map labels ~f:(fun l -> l ^ ",...")) | ||
| ^ " => " ^ concat_parts ^ ",..." |
There was a problem hiding this comment.
Preserve batch/input rows in output-axis block concat
Update the output-axis branch in translate_block_tensor to generate a full shape spec, not just an output-row spec. The current string (bt0,...; bt1,... => bt0^bt1,...) drops |...->..., so %op [ta; tb] only works when components are output-only tensors; if ta/tb have input or batch axes, shape inference compares them against empty default rows and fails (or cannot preserve those axes). This makes list block tensors unusable for nontrivial tensor shapes.
Useful? React with 👍 / 👎.
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>
|
Forwarded to upstream: ahrefs#450 |
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