You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: site/notes/ndarray-design.md
-21Lines changed: 0 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -362,24 +362,3 @@ M3 and M5 can proceed in parallel after M2.
362
362
-`Ops[A]` typeclass with instances for `NDArray`, `Jet[NDArray]`, `Node`
363
363
- Plain evaluator, forward AD evaluator, reverse AD evaluator
364
364
365
-
---
366
-
367
-
## Open questions
368
-
369
-
2.~~**Default layout**~~ → Column-major (F-order) for all ranks (decided). Consistent with existing Matrix and BLAS.
370
-
371
-
3.**Copy semantics for views:** NDArray views share backing data. Mutation through one view is visible through others. This is the NumPy/PyTorch model and avoids unnecessary copies. Should we support copy-on-write? (Recommendation: no, too complex, just document the aliasing behavior.) Recommendation, copy on write would silently tank performance. It would be easy enough to write an immutable wrapper over the top if someone wants it. Decided. Recommendation accepted, no copy-on-write. Document aliasing semantics clearly.
372
-
373
-
4.**Naming:**`NDArray[A]` vs `NdArray[A]` vs `Tensor[A]`? Recommendation: `NDArray` for the data structure. Reserve `Tensor` for the AD-aware type in a future module. NDArray - decided.
374
-
375
-
5.**Int indexing API:** Varargs `apply(indices: Int*)` is convenient but allocates. Alternative: overloads for 1, 2, 3, 4, N cases. Or: `IArray[Int]` to signal no mutation. Recommendation: specific overloads for 1-4D, varargs for N>4. Agreed to follow recommendation.
376
-
377
-
6.**Broadcasting: implicit or explicit?** Implicit broadcasting (NumPy-style, where `+` silently expands shapes) vs explicit (`broadcastTo` required before binary ops). **Decided: explicit.** Rationale:
378
-
-**Consistent** with existing `Array[Double]` ops which require same length — no implicit expansion anywhere in vecxt.
379
-
-**Simpler binary ops** — `+` is always same-shape; no broadcasting code path, no shape-mismatch error messages.
380
-
-**Cleaner AD** — `broadcastTo` is a first-class node in the computation graph with a clean VJP rule (sum-reduce along broadcast axes). Binary ops have trivial same-shape gradients.
381
-
-**Better errors** — "cannot broadcastTo shape [4,3] from shape [2,3]" is more actionable than "cannot broadcast shapes [4,3] and [2,3] in +".
382
-
-**`broadcastTo` is free** — it's a zero-copy view (stride-0). The verbosity cost is one method call that documents intent.
383
-
-`NDArray.broadcastPair(a, b)` provides a convenience for the common case of broadcasting two operands to their common shape.
0 commit comments