Skip to content

Codec ​

codec.as_wire ​

as_wire(t) — normalize a tensor argument: a wire record rebuilds

an identical record; an opaque TaggedValue::Tensor (a host op's result) materializes the wire record of its projected shape and data. A non-tensor errors at the .__tensor__ field access (the host impl's TypeMismatch — accept/reject parity, not message parity).

Signature: codec.as_wire((t))

codec.from_list ​

tensor.from_list — nested number arrays → wire tensor. A

non-array argument is an error (matching the host's TypeMismatch); [] is the rank-1 empty tensor of shape [0]; [[], []] is [2, 0]. Leaves are number-checked by flat_num.

Signature: codec.from_list((xs))

codec.ones ​

tensor.ones — a tensor of shape filled with 1.

Signature: codec.ones((shp))

codec.shape ​

tensor.shape — the extent-per-axis list. Pure on both

representations for the same reason.

Signature: codec.shape((t))

codec.to_list ​

tensor.to_list — tensor → nested number arrays. Pure on both

representations: the wire view makes t.__tensor__ project the {shape, data, dtype} record whether t is a wire record or an opaque Tensor.

Signature: codec.to_list((t))

codec.wire ​

The canonical wire encoding of (shape, data). (The parentheses are

load-bearing: a bare ~> { parses as a block, not a record literal.)

Signature: codec.wire((shape, ds))

codec.wire_data ​

Flat row-major payload for a wire record or opaque tensor — the

.__tensor__ field projects on both representations (the opaque case reads through the tagged-object view).

Signature: codec.wire_data((t))

codec.wire_shape ​

Extent-per-axis for either representation.

Signature: codec.wire_shape((t))

codec.zeros ​

tensor.zeros — a tensor of shape filled with 0. The host fills

with 0.0; the wire data here is integer 0, which is f64 0.0 the moment it crosses the Function boundary (0 == 0.0 holds elementwise under to_list comparison either way).

Signature: codec.zeros((shp))