struct DType
pub struct DType {
}Purpose
Dense scalar encodings with little-endian storage.
Public fields
This type has no public fields.
#tensorStandard library package `#tensor`.
struct DTypepub struct DType {
}Dense scalar encodings with little-endian storage.
This type has no public fields.
dtype_f32pub fn dtype_f32() DTypeDtype f32.
No arguments are required.
DType — a value of this type
dtype_f16pub fn dtype_f16() DTypeDtype f16.
No arguments are required.
DType — a value of this type
dtype_bf16pub fn dtype_bf16() DTypeDtype bf16.
No arguments are required.
DType — a value of this type
dtype_fp8_e4m3fnpub fn dtype_fp8_e4m3fn() DTypeDtype fp8 e4m3fn.
No arguments are required.
DType — a value of this type
dtype_fp8_e5m2pub fn dtype_fp8_e5m2() DTypeDtype fp8 e5m2.
No arguments are required.
DType — a value of this type
dtype_fp8_e4m3fnuzpub fn dtype_fp8_e4m3fnuz() DTypeDtype fp8 e4m3fnuz.
No arguments are required.
DType — a value of this type
dtype_fp8_e5m2fnuzpub fn dtype_fp8_e5m2fnuz() DTypeDtype fp8 e5m2fnuz.
No arguments are required.
DType — a value of this type
(DType) is_f32pub fn (dtype DType) is_f32() boolOperation on DType: whether it is f32.
dtype DTypeDType instance used by this call (value receiver).bool — true or false
(DType) element_bytespub fn (dtype DType) element_bytes() intOperation on DType: element bytes.
dtype DTypeDType instance used by this call (value receiver).int — a value of this type
(DType) decode_bitspub fn (dtype DType) decode_bits(raw int) f32Decode scalar bits to f32. Unused upper bits are ignored.
dtype DTypeDType instance used by this call (value receiver).raw intf32 — a value of this type
(DType) encode_bitspub fn (dtype DType) encode_bits(value f32) intEncode a compute value to the scalar's storage bits.
dtype DTypeDType instance used by this call (value receiver).value f32int — a value of this type
safetensors_dtypepub fn safetensors_dtype(name &string) DTypeSafetensors dtype. Throws on failure; handle the error or propagate it to the caller.
name &stringDType — a value of this type
dtype_namedpub fn dtype_named(name &string) DTypeParse the short names used to select an in-memory tensor encoding. Throws on failure; handle the error or propagate it to the caller.
name &stringDType — a value of this type
struct F16pub struct F16 {
pub bits u16
}Fixed-width storage scalars. Raw bits are exposed for lossless serialization.
bits u16struct BF16pub struct BF16 {
pub bits u16
}Structure encapsulating bits.
bits u16struct Fp8E4M3Fnpub struct Fp8E4M3Fn {
pub bits u8
}Structure encapsulating bits.
bits u8struct Fp8E5M2pub struct Fp8E5M2 {
pub bits u8
}Structure encapsulating bits.
bits u8struct Fp8E4M3Fnuzpub struct Fp8E4M3Fnuz {
pub bits u8
}Structure encapsulating bits.
bits u8struct Fp8E5M2Fnuzpub struct Fp8E5M2Fnuz {
pub bits u8
}Structure encapsulating bits.
bits u8f16pub fn f16(value f32) F16Convert to IEEE binary16, rounding to nearest with ties to even.
value f32F16 — a value of this type
(&F16) to_f32pub fn (x &F16) to_f32() f32Operation on &F16: convert to f32.
x &F16F16 instance used by this call (borrow).f32 — a value of this type
bf16pub fn bf16(value f32) BF16Convert to bfloat16, rounding to nearest with ties to even and quieting NaNs.
value f32BF16 — a value of this type
(&BF16) to_f32pub fn (x &BF16) to_f32() f32Operation on &BF16: convert to f32.
x &BF16BF16 instance used by this call (borrow).f32 — a value of this type
fp8_e4m3fnpub fn fp8_e4m3fn(value f32) Fp8E4M3FnFP8 constructors saturate finite overflow and round ties to even. Formats with infinity preserve it. FNUZ formats use an unsigned zero.
value f32Fp8E4M3Fn — a value of this type
fp8_e5m2pub fn fp8_e5m2(value f32) Fp8E5M2Fp8 e5m2.
value f32Fp8E5M2 — a value of this type
fp8_e4m3fnuzpub fn fp8_e4m3fnuz(value f32) Fp8E4M3FnuzFp8 e4m3fnuz.
value f32Fp8E4M3Fnuz — a value of this type
fp8_e5m2fnuzpub fn fp8_e5m2fnuz(value f32) Fp8E5M2FnuzFp8 e5m2fnuz.
value f32Fp8E5M2Fnuz — a value of this type
(&Fp8E4M3Fn) to_f32pub fn (x &Fp8E4M3Fn) to_f32() f32Operation on &Fp8E4M3Fn: convert to f32.
x &Fp8E4M3FnFp8E4M3Fn instance used by this call (borrow).f32 — a value of this type
(&Fp8E5M2) to_f32pub fn (x &Fp8E5M2) to_f32() f32Operation on &Fp8E5M2: convert to f32.
x &Fp8E5M2Fp8E5M2 instance used by this call (borrow).f32 — a value of this type
(&Fp8E4M3Fnuz) to_f32pub fn (x &Fp8E4M3Fnuz) to_f32() f32Operation on &Fp8E4M3Fnuz: convert to f32.
x &Fp8E4M3FnuzFp8E4M3Fnuz instance used by this call (borrow).f32 — a value of this type
(&Fp8E5M2Fnuz) to_f32pub fn (x &Fp8E5M2Fnuz) to_f32() f32Operation on &Fp8E5M2Fnuz: convert to f32.
x &Fp8E5M2FnuzFp8E5M2Fnuz instance used by this call (borrow).f32 — a value of this type
dot_f32pub fn dot_f32(a &[]f32, b &[]f32, n int) f32Dot f32.
a &[]f32b &[]f32n intf32 — a value of this type
axpy_f32pub fn axpy_f32(dst $&[]f32, src &[]f32, alpha f32, n int)Axpy f32.
dst $&[]f32src &[]f32alpha f32n intThis call does not return a value.
vadd_f32pub fn vadd_f32(dst $&[]f32, src &[]f32, n int)Vadd f32.
dst $&[]f32src &[]f32n intThis call does not return a value.
vmul_f32pub fn vmul_f32(out $&[]f32, a &[]f32, b &[]f32, n int)Vmul f32.
out $&[]f32a &[]f32b &[]f32n intThis call does not return a value.
vscale_f32pub fn vscale_f32(dst $&[]f32, scale f32, n int)Vscale f32.
dst $&[]f32scale f32n intThis call does not return a value.
rmsnorm_f32pub fn rmsnorm_f32(out $&[]f32, x &[]f32, weight &[]f32, n int, eps f64)Rmsnorm f32.
out $&[]f32x &[]f32weight &[]f32n inteps f64This call does not return a value.
softmax_f32pub fn softmax_f32(scores $&[]f32, n int, scale f32)Softmax f32.
scores $&[]f32n intscale f32This call does not return a value.
swiglu_f32pub fn swiglu_f32(out $&[]f32, gate &[]f32, up &[]f32, n int)Swiglu f32.
out $&[]f32gate &[]f32up &[]f32n intThis call does not return a value.
matvec_f32pub fn matvec_f32(out $&[]f32, x &[]f32, weights &[]f32, rows int, cols int)Matvec f32.
out $&[]f32x &[]f32weights &[]f32rows intcols intThis call does not return a value.
matmul_f32pub fn matmul_f32(out $&[]f32, x &[]f32, weights &[]f32, m_cnt int, rows int, cols int)Matmul f32.
out $&[]f32x &[]f32weights &[]f32m_cnt introws intcols intThis call does not return a value.
argmax_f32pub fn argmax_f32(x &[]f32, n int) intArgmax f32.
x &[]f32n intint — a value of this type
quantize_q8_0pub fn quantize_q8_0(x &[]f32, xq $&[]i8, scales $&[]f32, n int)Quantize q8 0.
x &[]f32xq $&[]i8scales $&[]f32n intThis call does not return a value.
vsub_f32pub fn vsub_f32(out $&[]f32, a &[]f32, b &[]f32, n int)Vsub f32.
out $&[]f32a &[]f32b &[]f32n intThis call does not return a value.
silu_f32pub fn silu_f32(out $&[]f32, x &[]f32, n int)Silu f32.
out $&[]f32x &[]f32n intThis call does not return a value.
gelu_f32pub fn gelu_f32(out $&[]f32, x &[]f32, n int)Gelu f32.
out $&[]f32x &[]f32n intThis call does not return a value.
layernorm_f32pub fn layernorm_f32(out $&[]f32, x &[]f32, weight &[]f32, bias &[]f32, n int, eps f64)Layernorm f32.
out $&[]f32x &[]f32weight &[]f32bias &[]f32n inteps f64This call does not return a value.
l2_normalize_f32pub fn l2_normalize_f32(out $&[]f32, x &[]f32, n int, eps f64)L2 normalize f32.
out $&[]f32x &[]f32n inteps f64This call does not return a value.
cosine_similarity_f32pub fn cosine_similarity_f32(a &[]f32, b &[]f32, n int) f32Cosine similarity f32.
a &[]f32b &[]f32n intf32 — a value of this type
rope_f32pub fn rope_f32(vec $&[]f32, n_heads int, head_dim int, pos int, theta f64)Rope f32.
vec $&[]f32n_heads inthead_dim intpos inttheta f64This call does not return a value.
quantize_q4_0_rowpub fn quantize_q4_0_row(x &[]f32, qs $&[]u8, scales $&[]f32, n int)Quantize q4 0 row.
x &[]f32qs $&[]u8scales $&[]f32n intThis call does not return a value.
rope_interleaved_f32pub fn rope_interleaved_f32(vec $&[]f32, n_heads int, head_dim int, pos int, theta f64)Rope interleaved f32.
vec $&[]f32n_heads inthead_dim intpos inttheta f64This call does not return a value.
geglu_f32pub fn geglu_f32(out $&[]f32, gate &[]f32, up &[]f32, n int)Geglu f32.
out $&[]f32gate &[]f32up &[]f32n intThis call does not return a value.
log_softmax_f32pub fn log_softmax_f32(scores $&[]f32, n int)Log softmax f32.
scores $&[]f32n intThis call does not return a value.
add_rmsnorm_f32pub fn add_rmsnorm_f32(norm_out $&[]f32, residual_out $&[]f32, x &[]f32, residual &[]f32, weight &[]f32, n int, eps f64)Add rmsnorm f32.
norm_out $&[]f32residual_out $&[]f32x &[]f32residual &[]f32weight &[]f32n inteps f64This call does not return a value.
topk_f32pub fn topk_f32(x &[]f32, n int, k int, out_idx $&[]int, out_val $&[]f32) intTopk f32.
x &[]f32n intk intout_idx $&[]intout_val $&[]f32int — a value of this type
moe_router_f32pub fn moe_router_f32(logits &[]f32, n_experts int, top_k int, use_sigmoid bool, norm_topk bool, scale f64, bias &[]f32, out_idx $&[]int, out_w $&[]f32) intMoe router f32.
logits &[]f32n_experts inttop_k intuse_sigmoid boolnorm_topk boolscale f64bias &[]f32out_idx $&[]intout_w $&[]f32int — a value of this type
rope_yarn_f32pub fn rope_yarn_f32(vec $&[]f32, n_heads int, head_dim int, rope_dim int, interleaved bool, pos int, theta f64, scale f64, orig_ctx int, beta_fast f64, beta_slow f64, attn_factor f64)Rope yarn f32.
vec $&[]f32n_heads inthead_dim intrope_dim intinterleaved boolpos inttheta f64scale f64orig_ctx intbeta_fast f64beta_slow f64attn_factor f64This call does not return a value.
topk_cosine_f32pub fn topk_cosine_f32(query &[]f32, corpus &[]f32, n_docs int, dim int, k int, out_idx $&[]int, out_score $&[]f32) intTopk cosine f32.
query &[]f32corpus &[]f32n_docs intdim intk intout_idx $&[]intout_score $&[]f32int — a value of this type
cross_entropy_grad_f32pub fn cross_entropy_grad_f32(dlogits $&[]f32, logits &[]f32, target int, n int) f32Cross entropy grad f32.
dlogits $&[]f32logits &[]f32target intn intf32 — a value of this type
adamw_step_f32pub fn adamw_step_f32(param $&[]f32, grad &[]f32, m $&[]f32, v $&[]f32, n int, lr f32, beta1 f32, beta2 f32, eps f32, weight_decay f32, step int)Adamw step f32.
param $&[]f32grad &[]f32m $&[]f32v $&[]f32n intlr f32beta1 f32beta2 f32eps f32weight_decay f32step intThis call does not return a value.
lora_add_f32pub fn lora_add_f32(out $&[]f32, x &[]f32, a &[]f32, b &[]f32, rows int, cols int, rank int, scale f32)Lora add f32.
out $&[]f32x &[]f32a &[]f32b &[]f32rows intcols intrank intscale f32This call does not return a value.
lora_backward_f32pub fn lora_backward_f32(dx $&[]f32, da $&[]f32, db $&[]f32, dy &[]f32, x &[]f32, a &[]f32, b &[]f32, out_dim int, in_dim int, rank int, scale f64)Lora backward f32.
dx $&[]f32da $&[]f32db $&[]f32dy &[]f32x &[]f32a &[]f32b &[]f32out_dim intin_dim intrank intscale f64This call does not return a value.
rmsnorm_backward_f32pub fn rmsnorm_backward_f32(dx $&[]f32, dw $&[]f32, dy &[]f32, x &[]f32, w &[]f32, n int, eps f64)Rmsnorm backward f32.
dx $&[]f32dw $&[]f32dy &[]f32x &[]f32w &[]f32n inteps f64This call does not return a value.
swiglu_backward_f32pub fn swiglu_backward_f32(dgate $&[]f32, dup $&[]f32, dy &[]f32, gate &[]f32, up &[]f32, n int)Swiglu backward f32.
dgate $&[]f32dup $&[]f32dy &[]f32gate &[]f32up &[]f32n intThis call does not return a value.
layernorm_backward_f32pub fn layernorm_backward_f32(dx $&[]f32, dw $&[]f32, db $&[]f32, dy &[]f32, x &[]f32, weight &[]f32, n int, eps f64)Layernorm backward f32.
dx $&[]f32dw $&[]f32db $&[]f32dy &[]f32x &[]f32weight &[]f32n inteps f64This call does not return a value.
softmax_backward_f32pub fn softmax_backward_f32(dx $&[]f32, dy &[]f32, probs &[]f32, n int)Softmax backward f32.
dx $&[]f32dy &[]f32probs &[]f32n intThis call does not return a value.
grad_clip_norm_f32pub fn grad_clip_norm_f32(grad $&[]f32, n int, max_norm f32) f32Grad clip norm f32.
grad $&[]f32n intmax_norm f32f32 — a value of this type
kl_div_grad_f32pub fn kl_div_grad_f32(grad_student $&[]f32, student_logits &[]f32, teacher_logits &[]f32, n int, temperature f32) f32Kl div grad f32.
grad_student $&[]f32student_logits &[]f32teacher_logits &[]f32n inttemperature f32f32 — a value of this type
dpo_loss_grad_f32pub fn dpo_loss_grad_f32(pi_chosen_logp f32, pi_rejected_logp f32, ref_chosen_logp f32, ref_rejected_logp f32, beta f32, out_grad $&[]f32) f32Dpo loss grad f32.
pi_chosen_logp f32pi_rejected_logp f32ref_chosen_logp f32ref_rejected_logp f32beta f32out_grad $&[]f32f32 — a value of this type
grpo_advantages_f32pub fn grpo_advantages_f32(out_adv $&[]f32, rewards &[]f32, n int, eps f32)Grpo advantages f32.
out_adv $&[]f32rewards &[]f32n inteps f32This call does not return a value.
conv1d_causal_step_f32pub fn conv1d_causal_step_f32(out $&[]f32, state $&[]f32, x &[]f32, weight &[]f32, bias &[]f32, d_inner int, k_size int)Conv1d causal step f32.
out $&[]f32state $&[]f32x &[]f32weight &[]f32bias &[]f32d_inner intk_size intThis call does not return a value.
ssm_scan_step_f32pub fn ssm_scan_step_f32(out $&[]f32, state $&[]f32, x &[]f32, dt &[]f32, a_log &[]f32, b_vec &[]f32, c_vec &[]f32, d_skip &[]f32, d_inner int, d_state int)Ssm scan step f32.
out $&[]f32state $&[]f32x &[]f32dt &[]f32a_log &[]f32b_vec &[]f32c_vec &[]f32d_skip &[]f32d_inner intd_state intThis call does not return a value.
linear_attn_step_f32pub fn linear_attn_step_f32(out $&[]f32, state $&[]f32, z_state $&[]f32, q &[]f32, k &[]f32, v &[]f32, decay f32, n_heads int, head_dim int, eps f32)Linear attn step f32.
out $&[]f32state $&[]f32z_state $&[]f32q &[]f32k &[]f32v &[]f32decay f32n_heads inthead_dim inteps f32This call does not return a value.
ppo_clip_grad_f32pub fn ppo_clip_grad_f32(new_logp f32, old_logp f32, ref_logp f32, advantage f32, clip_eps f32, kl_beta f32, out_grad $&[]f32) f32Ppo clip grad f32.
new_logp f32old_logp f32ref_logp f32advantage f32clip_eps f32kl_beta f32out_grad $&[]f32f32 — a value of this type
conv2d_patch_embed_f32pub fn conv2d_patch_embed_f32(out $&[]f32, img &[]f32, weight &[]f32, bias &[]f32, in_c int, img_h int, img_w int, out_c int, patch int)Conv2d patch embed f32.
out $&[]f32img &[]f32weight &[]f32bias &[]f32in_c intimg_h intimg_w intout_c intpatch intThis call does not return a value.
mha_sdpa_f32pub fn mha_sdpa_f32(out $&[]f32, q &[]f32, k &[]f32, v &[]f32, seq_q int, seq_k int, n_heads int, head_dim int, causal bool)Mha sdpa f32.
out $&[]f32q &[]f32k &[]f32v &[]f32seq_q intseq_k intn_heads inthead_dim intcausal boolThis call does not return a value.
avg_pool2d_f32pub fn avg_pool2d_f32(out $&[]f32, x &[]f32, channels int, h int, w int, kernel int, stride int)Avg pool2d f32.
out $&[]f32x &[]f32channels inth intw intkernel intstride intThis call does not return a value.
const GGML_BLOCK_VALUESpub const GGML_BLOCK_VALUES = 32Constant GGML_BLOCK_VALUES, defining protocol or algorithm parameters.
const Q4_0_BYTESpub const Q4_0_BYTES = 18Constant Q4_0_BYTES, defining protocol or algorithm parameters.
const Q4_1_BYTESpub const Q4_1_BYTES = 20Constant Q4_1_BYTES, defining protocol or algorithm parameters.
const Q5_0_BYTESpub const Q5_0_BYTES = 22Constant Q5_0_BYTES, defining protocol or algorithm parameters.
const Q5_1_BYTESpub const Q5_1_BYTES = 24Constant Q5_1_BYTES, defining protocol or algorithm parameters.
const Q8_0_BYTESpub const Q8_0_BYTES = 34Constant Q8_0_BYTES, defining protocol or algorithm parameters.
const QK_Kpub const QK_K = 256Constant QK_K, defining protocol or algorithm parameters.
const Q2_K_BYTESpub const Q2_K_BYTES = 84Constant Q2_K_BYTES, defining protocol or algorithm parameters.
const Q3_K_BYTESpub const Q3_K_BYTES = 110Constant Q3_K_BYTES, defining protocol or algorithm parameters.
const Q4_K_BYTESpub const Q4_K_BYTES = 144Constant Q4_K_BYTES, defining protocol or algorithm parameters.
const Q5_K_BYTESpub const Q5_K_BYTES = 176Constant Q5_K_BYTES, defining protocol or algorithm parameters.
const Q6_K_BYTESpub const Q6_K_BYTES = 210Constant Q6_K_BYTES, defining protocol or algorithm parameters.
const Q8_K_BYTESpub const Q8_K_BYTES = 292Constant Q8_K_BYTES, defining protocol or algorithm parameters.
struct Q4Blockpub struct Q4Block {
pub scale F16
pub packed [16]u8
}GGML Q4_0 stores a little-endian binary16 scale and 16 packed bytes. Each byte contains a low nibble for index i and a high nibble for i+16.
scale F16packed [16]u8struct Q41Blockpub struct Q41Block {
pub d F16
pub m F16
pub qs [16]u8
}GGML Q4_1 stores little-endian f16 d, f16 m, and 16 nibble bytes (x = q*d + m).
d F16m F16qs [16]u8struct Q51Blockpub struct Q51Block {
pub d F16
pub m F16
pub qh [4]u8
pub qs [16]u8
}GGML Q5_1 stores little-endian f16 d, f16 m, 4 bytes high bits, and 16 nibble bytes.
d F16m F16qh [4]u8qs [16]u8struct Q2KBlockpub struct Q2KBlock {
pub scales [16]u8
pub qs [64]u8
pub d F16
pub dmin F16
}GGML Q2_K super-block encodes 256 values in 84 bytes: 16 scale/min bytes, 64 bytes of 2-bit quants, trailing f16 d and f16 dmin.
scales [16]u8qs [64]u8d F16dmin F16struct Q3KBlockpub struct Q3KBlock {
pub hmask [32]u8
pub qs [64]u8
pub scales [12]u8
pub d F16
}GGML Q3_K super-block encodes 256 values in 110 bytes: 32 hmask bytes, 64 bytes of 2-bit low quants, 12 packed 6-bit scales, and trailing f16 d.
hmask [32]u8qs [64]u8scales [12]u8d F16struct Q5Blockpub struct Q5Block {
pub scale F16
pub qh [4]u8
pub qs [16]u8
}GGML Q5_0 stores a little-endian binary16 scale, 4 bytes of 5th high bits, and 16 bytes of packed low nibbles.
scale F16qh [4]u8qs [16]u8struct Q8Blockpub struct Q8Block {
pub scale F16
pub quants [32]i8
}GGML Q8_0 stores the same scale followed by 32 signed quantized bytes.
scale F16quants [32]i8struct Q4KBlockpub struct Q4KBlock {
pub d F16
pub dmin F16
pub scales [12]u8
pub qs [128]u8
}GGML Q4_K super-block encodes 256 values in 144 bytes: f16 d/dmin, 12 packed 6-bit scale/min bytes, and 128 bytes of 4-bit unsigned nibbles.
d F16dmin F16scales [12]u8qs [128]u8struct Q5KBlockpub struct Q5KBlock {
pub d F16
pub dmin F16
pub scales [12]u8
pub qh [32]u8
pub qs [128]u8
}GGML Q5_K super-block encodes 256 values in 176 bytes: f16 d/dmin, 12 packed 6-bit scale/min bytes, 32 high-bit bytes qh, and 128 low-nibble bytes qs.
d F16dmin F16scales [12]u8qh [32]u8qs [128]u8struct Q6KBlockpub struct Q6KBlock {
pub ql [128]u8
pub qh [64]u8
pub scales [16]i8
pub d F16
}GGML Q6_K super-block encodes 256 values in 210 bytes: 128 low-nibble bytes, 64 high-2-bit bytes, 16 signed int8 sub-scales, and a trailing f16 scale d.
ql [128]u8qh [64]u8scales [16]i8d F16read_q4_0pub fn read_q4_0(storage &string, offset int) Q4BlockRead q4 0. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intQ4Block — a value of this type
read_q8_0pub fn read_q8_0(storage &string, offset int) Q8BlockRead q8 0. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intQ8Block — a value of this type
(&Q4Block) atpub fn (block &Q4Block) at(index int) f32Execute at on &Q4Block. Throws on failure; handle the error or propagate it to the caller.
block &Q4BlockQ4Block instance used by this call (borrow).index intf32 — a value of this type
(&Q8Block) atpub fn (block &Q8Block) at(index int) f32Execute at on &Q8Block. Throws on failure; handle the error or propagate it to the caller.
block &Q8BlockQ8Block instance used by this call (borrow).index intf32 — a value of this type
(&Q4Block) append_f32pub fn (block &Q4Block) append_f32(out $&[]f32)Operation on &Q4Block: append f32.
block &Q4BlockQ4Block instance used by this call (borrow).out $&[]f32This call does not return a value.
(&Q8Block) append_f32pub fn (block &Q8Block) append_f32(out $&[]f32)Operation on &Q8Block: append f32.
block &Q8BlockQ8Block instance used by this call (borrow).out $&[]f32This call does not return a value.
read_q4_kpub fn read_q4_k(storage &string, offset int) Q4KBlockRead q4 k. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intQ4KBlock — a value of this type
(&Q4KBlock) atpub fn (block &Q4KBlock) at(index int) f32Execute at on &Q4KBlock. Throws on failure; handle the error or propagate it to the caller.
block &Q4KBlockQ4KBlock instance used by this call (borrow).index intf32 — a value of this type
(&Q4KBlock) append_f32pub fn (block &Q4KBlock) append_f32(out $&[]f32)Operation on &Q4KBlock: append f32.
block &Q4KBlockQ4KBlock instance used by this call (borrow).out $&[]f32This call does not return a value.
(&Q4KBlock) dot_f32pub fn (block &Q4KBlock) dot_f32(x &[]f32, x_off int) f32Operation on &Q4KBlock: dot f32.
block &Q4KBlockQ4KBlock instance used by this call (borrow).x &[]f32x_off intf32 — a value of this type
read_q5_kpub fn read_q5_k(storage &string, offset int) Q5KBlockRead q5 k. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intQ5KBlock — a value of this type
(&Q5KBlock) atpub fn (block &Q5KBlock) at(index int) f32Execute at on &Q5KBlock. Throws on failure; handle the error or propagate it to the caller.
block &Q5KBlockQ5KBlock instance used by this call (borrow).index intf32 — a value of this type
(&Q5KBlock) append_f32pub fn (block &Q5KBlock) append_f32(out $&[]f32)Operation on &Q5KBlock: append f32.
block &Q5KBlockQ5KBlock instance used by this call (borrow).out $&[]f32This call does not return a value.
(&Q5KBlock) dot_f32pub fn (block &Q5KBlock) dot_f32(x &[]f32, x_off int) f32Operation on &Q5KBlock: dot f32.
block &Q5KBlockQ5KBlock instance used by this call (borrow).x &[]f32x_off intf32 — a value of this type
read_q6_kpub fn read_q6_k(storage &string, offset int) Q6KBlockRead q6 k. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intQ6KBlock — a value of this type
(&Q6KBlock) atpub fn (block &Q6KBlock) at(index int) f32Execute at on &Q6KBlock. Throws on failure; handle the error or propagate it to the caller.
block &Q6KBlockQ6KBlock instance used by this call (borrow).index intf32 — a value of this type
(&Q6KBlock) append_f32pub fn (block &Q6KBlock) append_f32(out $&[]f32)Operation on &Q6KBlock: append f32.
block &Q6KBlockQ6KBlock instance used by this call (borrow).out $&[]f32This call does not return a value.
(&Q6KBlock) dot_f32pub fn (block &Q6KBlock) dot_f32(x &[]f32, x_off int) f32Operation on &Q6KBlock: dot f32.
block &Q6KBlockQ6KBlock instance used by this call (borrow).x &[]f32x_off intf32 — a value of this type
read_q5_0pub fn read_q5_0(storage &string, offset int) Q5BlockRead q5 0. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intQ5Block — a value of this type
(&Q5Block) atpub fn (block &Q5Block) at(index int) f32Execute at on &Q5Block. Throws on failure; handle the error or propagate it to the caller.
block &Q5BlockQ5Block instance used by this call (borrow).index intf32 — a value of this type
(&Q5Block) append_f32pub fn (block &Q5Block) append_f32(out $&[]f32)Operation on &Q5Block: append f32.
block &Q5BlockQ5Block instance used by this call (borrow).out $&[]f32This call does not return a value.
(&Q5Block) dot_f32pub fn (block &Q5Block) dot_f32(x &[]f32, x_off int) f32Operation on &Q5Block: dot f32.
block &Q5BlockQ5Block instance used by this call (borrow).x &[]f32x_off intf32 — a value of this type
q5_0_dot_f32pub fn q5_0_dot_f32(storage &string, offset int, x &[]f32, x_off int) f32Zero-copy block dot products directly over caller-owned byte storage. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intx &[]f32x_off intf32 — a value of this type
q8_0_dot_f32pub fn q8_0_dot_f32(storage &string, offset int, x &[]f32, x_off int) f32Q8 0 dot f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intx &[]f32x_off intf32 — a value of this type
q4_k_dot_f32pub fn q4_k_dot_f32(storage &string, offset int, x &[]f32, x_off int) f32Q4 k dot f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intx &[]f32x_off intf32 — a value of this type
q6_k_dot_f32pub fn q6_k_dot_f32(storage &string, offset int, x &[]f32, x_off int) f32Q6 k dot f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intx &[]f32x_off intf32 — a value of this type
dot_q5_0_row_f32pub fn dot_q5_0_row_f32(storage &string, row_off int, x &[]f32, x_off int, n_blocks int) f32Bounds-checked once per row, avoiding per-block throwing calls and helpers. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intx &[]f32x_off intn_blocks intf32 — a value of this type
dot_q8_0_row_f32pub fn dot_q8_0_row_f32(storage &string, row_off int, x &[]f32, x_off int, n_blocks int) f32Dot q8 0 row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intx &[]f32x_off intn_blocks intf32 — a value of this type
dot_q4_k_row_f32pub fn dot_q4_k_row_f32(storage &string, row_off int, x &[]f32, x_off int, n_blocks int) f32Dot q4 k row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intx &[]f32x_off intn_blocks intf32 — a value of this type
dot_q6_k_row_f32pub fn dot_q6_k_row_f32(storage &string, row_off int, x &[]f32, x_off int, n_blocks int) f32Dot q6 k row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intx &[]f32x_off intn_blocks intf32 — a value of this type
quantize_q5_0_rowpub fn quantize_q5_0_row(x &[]f32, out $&[]u8, n int)Quantize q5 0 row.
x &[]f32out $&[]u8n intThis call does not return a value.
dequant_f16_to_f32pub fn dequant_f16_to_f32(src &string, off int, dst $&[]f32, dst_off int, n int) intDequant f16 to f32. Throws on failure; handle the error or propagate it to the caller.
src &stringoff intdst $&[]f32dst_off intn intint — a value of this type
dequant_bf16_to_f32pub fn dequant_bf16_to_f32(src &string, off int, dst $&[]f32, dst_off int, n int) intDequant bf16 to f32. Throws on failure; handle the error or propagate it to the caller.
src &stringoff intdst $&[]f32dst_off intn intint — a value of this type
quantize_q8_k_rowpub fn quantize_q8_k_row(x &[]f32, x_off int, qs $&[]i8, d_out $&[]f32, bsums $&[]int, n_blocks int) intQuantize q8 k row. Throws on failure; handle the error or propagate it to the caller.
x &[]f32x_off intqs $&[]i8d_out $&[]f32bsums $&[]intn_blocks intint — a value of this type
dot_q4_k_q8_k_row_f32pub fn dot_q4_k_q8_k_row_f32(storage &string, row_off int, q8_qs &[]i8, q8_d &[]f32, q8_bsums &[]int, n_blocks int) f32Dot q4 k q8 k row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intq8_qs &[]i8q8_d &[]f32q8_bsums &[]intn_blocks intf32 — a value of this type
dot_q5_k_bytes_f32pub fn dot_q5_k_bytes_f32(storage &string, offset int, x &[]f32, x_off int) f32Dot q5 k bytes f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intx &[]f32x_off intf32 — a value of this type
dot_q5_k_row_f32pub fn dot_q5_k_row_f32(storage &string, row_off int, x &[]f32, x_off int, n_blocks int) f32Dot q5 k row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intx &[]f32x_off intn_blocks intf32 — a value of this type
dot_q5_k_q8_k_row_f32pub fn dot_q5_k_q8_k_row_f32(storage &string, row_off int, q8_qs &[]i8, q8_d &[]f32, q8_bsums &[]int, n_blocks int) f32Dot q5 k q8 k row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intq8_qs &[]i8q8_d &[]f32q8_bsums &[]intn_blocks intf32 — a value of this type
dot_q6_k_q8_k_row_f32pub fn dot_q6_k_q8_k_row_f32(storage &string, row_off int, q8_qs &[]i8, q8_d &[]f32, n_blocks int) f32Dot q6 k q8 k row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intq8_qs &[]i8q8_d &[]f32n_blocks intf32 — a value of this type
read_q4_1pub fn read_q4_1(storage &string, offset int) Q41BlockRead q4 1. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intQ41Block — a value of this type
(&Q41Block) append_f32pub fn (block &Q41Block) append_f32(out $&[]f32)Operation on &Q41Block: append f32.
block &Q41BlockQ41Block instance used by this call (borrow).out $&[]f32This call does not return a value.
(&Q41Block) dot_f32pub fn (block &Q41Block) dot_f32(x &[]f32, x_off int) f32Operation on &Q41Block: dot f32.
block &Q41BlockQ41Block instance used by this call (borrow).x &[]f32x_off intf32 — a value of this type
dot_q4_1_row_f32pub fn dot_q4_1_row_f32(storage &string, row_off int, x &[]f32, x_off int, n_blocks int) f32Dot q4 1 row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intx &[]f32x_off intn_blocks intf32 — a value of this type
read_q5_1pub fn read_q5_1(storage &string, offset int) Q51BlockRead q5 1. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intQ51Block — a value of this type
(&Q51Block) append_f32pub fn (block &Q51Block) append_f32(out $&[]f32)Operation on &Q51Block: append f32.
block &Q51BlockQ51Block instance used by this call (borrow).out $&[]f32This call does not return a value.
(&Q51Block) dot_f32pub fn (block &Q51Block) dot_f32(x &[]f32, x_off int) f32Operation on &Q51Block: dot f32.
block &Q51BlockQ51Block instance used by this call (borrow).x &[]f32x_off intf32 — a value of this type
dot_q5_1_row_f32pub fn dot_q5_1_row_f32(storage &string, row_off int, x &[]f32, x_off int, n_blocks int) f32Dot q5 1 row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intx &[]f32x_off intn_blocks intf32 — a value of this type
read_q2_kpub fn read_q2_k(storage &string, offset int) Q2KBlockRead q2 k. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intQ2KBlock — a value of this type
(&Q2KBlock) append_f32pub fn (block &Q2KBlock) append_f32(out $&[]f32)Operation on &Q2KBlock: append f32.
block &Q2KBlockQ2KBlock instance used by this call (borrow).out $&[]f32This call does not return a value.
dot_q2_k_row_f32pub fn dot_q2_k_row_f32(storage &string, row_off int, x &[]f32, x_off int, n_blocks int) f32Dot q2 k row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intx &[]f32x_off intn_blocks intf32 — a value of this type
dot_q2_k_q8_k_row_f32pub fn dot_q2_k_q8_k_row_f32(storage &string, row_off int, q8_qs &[]i8, q8_d &[]f32, q8_bsums &[]int, n_blocks int) f32Dot q2 k q8 k row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intq8_qs &[]i8q8_d &[]f32q8_bsums &[]intn_blocks intf32 — a value of this type
read_q3_kpub fn read_q3_k(storage &string, offset int) Q3KBlockRead q3 k. Throws on failure; handle the error or propagate it to the caller.
storage &stringoffset intQ3KBlock — a value of this type
(&Q3KBlock) append_f32pub fn (block &Q3KBlock) append_f32(out $&[]f32)Operation on &Q3KBlock: append f32.
block &Q3KBlockQ3KBlock instance used by this call (borrow).out $&[]f32This call does not return a value.
dot_q3_k_row_f32pub fn dot_q3_k_row_f32(storage &string, row_off int, x &[]f32, x_off int, n_blocks int) f32Dot q3 k row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intx &[]f32x_off intn_blocks intf32 — a value of this type
dot_q3_k_q8_k_row_f32pub fn dot_q3_k_q8_k_row_f32(storage &string, row_off int, q8_qs &[]i8, q8_d &[]f32, n_blocks int) f32Dot q3 k q8 k row f32. Throws on failure; handle the error or propagate it to the caller.
storage &stringrow_off intq8_qs &[]i8q8_d &[]f32n_blocks intf32 — a value of this type
struct TensorViewpub struct TensorView {
}TensorView describes a dense tensor in caller-owned little-endian storage. Offsets are in bytes. Strides are in elements and can be zero for broadcast.
This type has no public fields.
strided_viewpub fn strided_view(kind DType, shape &[]int, strides &[]int, byte_offset int, storage_bytes int) TensorViewCreate a view over storage_bytes bytes and validate the entire reachable span. Throws on failure; handle the error or propagate it to the caller.
kind DTypeshape &[]intstrides &[]intbyte_offset intstorage_bytes intTensorView — a value of this type
contiguous_viewpub fn contiguous_view(kind DType, shape &[]int, byte_offset int, storage_bytes int) TensorViewCreate a row-major view. An empty shape is a scalar and a zero axis is empty. Throws on failure; handle the error or propagate it to the caller.
kind DTypeshape &[]intbyte_offset intstorage_bytes intTensorView — a value of this type
(&TensorView) dtypepub fn (v &TensorView) dtype() DTypeExecute dtype on &TensorView.
v &TensorViewTensorView instance used by this call (borrow).DType — a value of this type
(&TensorView) rankpub fn (v &TensorView) rank() intExecute rank on &TensorView.
v &TensorViewTensorView instance used by this call (borrow).int — a value of this type
(&TensorView) element_countpub fn (v &TensorView) element_count() intOperation on &TensorView: element count.
v &TensorViewTensorView instance used by this call (borrow).int — a value of this type
(&TensorView) storage_startpub fn (v &TensorView) storage_start() intOperation on &TensorView: storage start.
v &TensorViewTensorView instance used by this call (borrow).int — a value of this type
(&TensorView) storage_endpub fn (v &TensorView) storage_end() intOperation on &TensorView: storage end.
v &TensorViewTensorView instance used by this call (borrow).int — a value of this type
(&TensorView) is_contiguouspub fn (v &TensorView) is_contiguous() boolOperation on &TensorView: whether it is contiguous.
v &TensorViewTensorView instance used by this call (borrow).bool — true or false
(&TensorView) dimensionpub fn (v &TensorView) dimension(axis int) intExecute dimension on &TensorView. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).axis intint — a value of this type
(&TensorView) stridepub fn (v &TensorView) stride(axis int) intExecute stride on &TensorView. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).axis intint — a value of this type
(&TensorView) transposepub fn (v &TensorView) transpose(a int, b int) TensorViewSwap two axes and keep the same caller-owned buffer. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).a intb intTensorView — a value of this type
(&TensorView) slicepub fn (v &TensorView) slice(axis int, first int, stop int, step int) TensorViewSlice one axis over [first, stop) with a positive element step. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).axis intfirst intstop intstep intTensorView — a value of this type
(&TensorView) reshapepub fn (v &TensorView) reshape(new_shape &[]int) TensorViewReshape a contiguous view without copying the backing bytes. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).new_shape &[]intTensorView — a value of this type
(&TensorView) permutepub fn (v &TensorView) permute(axes &[]int) TensorViewReorder axes without copying the backing bytes. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).axes &[]intTensorView — a value of this type
(&TensorView) byte_offsetpub fn (v &TensorView) byte_offset(indices &[]int) intOperation on &TensorView: byte offset. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).indices &[]intint — a value of this type
(&TensorView) read_f32pub fn (v &TensorView) read_f32(storage &string, indices &[]int) f32Read one scalar without copying or taking ownership of the storage. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).storage &stringindices &[]intf32 — a value of this type
(&TensorView) read_f32_linearpub fn (v &TensorView) read_f32_linear(storage &string, linear int) f32Read by logical row-major index, including transposed and stepped views. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).storage &stringlinear intf32 — a value of this type
(&TensorView) append_f32pub fn (v &TensorView) append_f32(storage &string, out $&[]f32) intAppend decoded values in logical row-major order after validating storage. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).storage &stringout $&[]f32int — a value of this type
(&TensorView) copy_f32pub fn (v &TensorView) copy_f32(storage &string, first int, count int, out $&[]f32, output_offset int) intDecode a logical range into an existing output buffer. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).storage &stringfirst intcount intout $&[]f32output_offset intint — a value of this type
(&TensorView) read_f32_bytespub fn (v &TensorView) read_f32_bytes(storage &[]u8, indices &[]int) f32Read one scalar from a mutable []u8 backing buffer. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).storage &[]u8indices &[]intf32 — a value of this type
(&TensorView) write_f32_bytespub fn (v &TensorView) write_f32_bytes(storage $&[]u8, indices &[]int, value f32) intEncode and write one scalar into a caller-owned []u8 backing buffer. Throws on failure; handle the error or propagate it to the caller.
v &TensorViewTensorView instance used by this call (borrow).storage $&[]u8indices &[]intvalue f32int — a value of this type