ion7-core / tensor

module

tensor

Functions

M.name

Return the tensor's name as a Lua string. Empty string if `t` is `nil` (matches the C bridge's `""` sentinel).

M.name(t)
tcdata`ggml_tensor*`, may be NULL.
→ string

M.type

Return the tensor's `ggml_type` enum value as a Lua integer, or `-1` if `t` is `nil`.

M.type(t)
tcdata`ggml_tensor*`, may be NULL.
→ integer

M.ne

Return the size of dimension `dim` (0..3) in elements, or `0` if `t` is `nil` or `dim` is out of range.

M.ne(t, dim)
tcdata`ggml_tensor*`.
dimintegerDimension index in `[0, 3]`.
→ integer

M.nbytes

Return the total byte size of the tensor data (calls `ggml_nbytes`).

M.nbytes(t)
tcdata`ggml_tensor*`.
→ integerByte count, or 0 when `t` is `nil`.

M.copy_f32

Copy the tensor's data into a caller-provided F32 cdata buffer. Handles CPU, CUDA, Metal and Vulkan backends transparently via `ggml_backend_tensor_get`. F16 and BF16 source tensors are up-converted to F32 row-wise. Quantised types (Q4_K, Q5_K, ...) are intentionally NOT supported — callers should dequantise upstream.

M.copy_f32(t, dst, dst_count)
tcdata`ggml_tensor*`.
dstcdata`float*` writable buffer.
dst_countintegerCapacity of `dst` in floats.
→ integerNumber of floats actually written, or `-1`