Skip to content
Konjure / spatial intelligence

tensor

← Builtin reference

Constructs packed numeric data with explicit dimensions.

Signature

func tensor[T](values: List[T], dimensions: List[Number]) -> Res[Tensor[T], DataError]

T is a numeric dtype. Values are row-major and their count must equal the checked product of the dimensions. Invalid shapes return Err(DataError). Host byte and execution limits reject execution before allocation.

Parameters

values: List[T]
Flat elements of the selected dtype; literals inherit T.
dimensions: List[f64]
Nonnegative integer dimensions in row-major axis order; [] constructs a rank-zero scalar from one value.

Returns

Res[Tensor[T], DataError]

Ok(Tensor[T]) with packed storage, or Err(DataError) for invalid dimensions or an element-count mismatch.

Examples

Constructs packed numeric data with explicit dimensions

Run the example, then change the data and inspect the result.

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

Rust definition

Rust SDK data primitives; the language checker specializes the same runtime operation.

See also