tinygrad/tensor.bend fails
raw source on the hub · import 0xe6b82fa6c4c459c7023adf4b12a3ac46/tinygrad/tensor.bend as Tensor
tinygrad/tensor.bend -- the lazy tensor core of tinygrad-bend.
Port of upstream tinygrad's semantic core:
- Tensor is LAZY: ops only extend a pending graph (tensor.py _apply_uop,
engine/lazy.py); nothing computes until realize (here: eval).
- elementwise ops broadcast like _broadcasted (align right, 1s stretch)
- movement ops are pure views (mixin/movement.py)
- reductions drop the reduced axis (mixin/reduce.py _reduce)
- matmul is batched dot ((...,m,k) @ (...,k,n) -> (...,m,n)), mixin/op.py
Kernel idiom: Bend outlaws mutual recursion and matching computed values, so every eval kernel is ONE self-recursive def whose pending Array reads travel as ordinary arguments, destructured at the top of each step.
Affine-world deviations from upstream (see README): - F32 only (Bend has no f64; Metal has none either) - dimensions are >= 1 (no size-0 tensors) - a Param's data lives in a caller-owned Params table: sharing a parameter across a graph needs no Array.clone -- the table is the buffer, mirroring tinygrad's realized-buffer identity. - shapes ride along in every node (affinity forbids re-reading a consumed Tensor to ask for its shape)
2 imports
import Base import ./shape.bend as Sh
The reader could not load this file (at 0xe6b82fa6c4c459c7023adf4b12a3ac46/tinygrad/tensor.bend:202). What bend.ts says:
Error:
- message : a type for this operator (write (a * b : Nat))
Location:
201 | +c = row_width(rows)
202>| fill_from_list(r*c, flat, 0n, alloc(r*c), matrix_shape(r, c))
| ^
203 |
Note: we broke this after launch, sorry. Until 2.0.16 a bare operator meant Nat.
That was a bug: operators demand annotation. Wrap the expression and it'll work again.