Skip to content
Konjure / spatial intelligence

Tensors and media

Packed arrays, shaped values and typed geometry.

Tensor[T] is a packed numeric value with an element type, shape, and strides. Use List[T] for general values such as records and functions. A nested typed literal constructs a tensor directly:

SourceKonjure
let matrix = [[1, 2], [3, 4]]:f32;

Every nested row must have the same shape. [[1, 2], [3]]:f32 is a compile error, before allocation or execution. A tensor literal has one numeric dtype; mixed element types are also rejected.

Tick 0 · 0.00 s⌘ / Ctrl + EnterThis device
main.kj
Loading the language runtime…
Output 0
No output.

Read and transform data

matrix.get([1, 0]) returns Opt[T]. matrix.shape() returns the extents. The operations that can fail return Res[..., DataError]:

SourceKonjure
let transposed = matrix.transpose()?;
let column = matrix.reshape([4, 1])?;
let total = matrix.sum()?;
let product = matrix.matmul(matrix)?;
let pixels = matrix.convert[u8]()?;

reshape checks the element count, transpose checks its axis permutation, and matmul checks dtype and compatible matrix dimensions. Scalar and tensor arithmetic use the same checked data errors. The ? requires a compatible Res or Opt return context; see Enums and results.

Inspect accepted values

Click a tensor name in the code, or select a stored value in Debug, to see its first values, shape, min/max, mean, standard deviation and histogram. Press Alt+Enter to inspect the symbol at the cursor. Statistics identify sampled values and approximate results; exact numeric previews retain their precision. Inspection reads accepted state without running code or changing the scene.

Feed geometry

Mesh.positions is Tensor[f32] with shape [vertices, 3]; Mesh.indices is Tensor[u32] with shape [triangles, 3].

Tick 0 · 0.00 sThis device
main.kj⌘ / Ctrl + Enter
Loading…Drag to orbit · select to inspect
0 entities
Loading the language runtime…
Output 0
No output.

The renderer reads logical coordinates, including strided views, and validates coordinate limits, topology, and triangle area before accepting a scene change. Decoded media remains a host boundary: a tensor describes accepted pixels or samples, while capture, codecs, playback, and streams require a host contract.