stdlib/safetensorsView source ↗
safetensors
20 items · generated by scribe fromstdlib/safetensors.fd· synced 2026-11-15
Contents
- StFile (struct)
- st_open (function)
- st_names (function)
- st_dtype_size (function)
- StTensor (struct)
- st_tensor (function)
- st_elems (function)
- st_f32bits_f64 (function)
- st_f32 (function)
- st_f16_f32 (function)
- st_bf16_f32 (function)
- st_f16 (function)
- st_bf16 (function)
- st_int (function)
- st_uint (function)
- st_meta (function)
StFile
pub struct StFile {Fields:
| Name | Type |
|---|---|
ok | bool |
header | str |
data_off | i64 |
names | Vec<str> |
Defined at line 7
st_open
Parse the file bytes. Returns ok=false on any malformed field.
pub fn st_open(b: Vec<i64>) -> StFile {Parameters:
b:Vec<i64>
Returns: StFile
Defined at line 36
st_names
Names of all tensors in the file.
pub fn st_names(st: StFile) -> Vec<str> {Parameters:
st:StFile
Returns: Vec<str>
Defined at line 75
st_dtype_size
Bytes per element for a safetensors dtype string, or 0 if unknown.
pub fn st_dtype_size(dt: str) -> i64 {Parameters:
dt:str
Returns: i64
Defined at line 82
StTensor
pub struct StTensor {Fields:
| Name | Type |
|---|---|
found | bool |
dtype | str |
shape | Vec<i64> |
data_begin | i64 |
data_end | i64 |
Defined at line 107
st_tensor
Look up a tensor by name; found=false when absent or malformed.
pub fn st_tensor(b: Vec<i64>, st: StFile, name: str) -> StTensor {Parameters:
b:Vec<i64>st:StFilename:str
Returns: StTensor
Defined at line 117
st_elems
Element count implied by the shape.
pub fn st_elems(t: StTensor) -> i64 {Parameters:
t:StTensor
Returns: i64
Defined at line 177
st_f32bits_f64
Decode IEEE f32 bits to f64 in pure math (the interp has no f32-from-bits primitive). sign|exp(8)|man(23), normals/subnormals. inf/nan return the largest finite magnitude with sign.
pub fn st_f32bits_f64(bits: i64) -> f64 {Parameters:
bits:i64
Returns: f64
Defined at line 200
st_f32
f32 element i of a tensor whose dtype is F32.
pub fn st_f32(b: Vec<i64>, t: StTensor, i: i64) -> f64 {Parameters:
b:Vec<i64>t:StTensori:i64
Returns: f64
Defined at line 222
st_f16_f32
IEEE f16 bits -> f64 value.
pub fn st_f16_f32(bits: i64) -> f64 {Parameters:
bits:i64
Returns: f64
Defined at line 258
st_bf16_f32
bf16 -> f64: it’s just the top half of the f32 word.
pub fn st_bf16_f32(bits: i64) -> f64 {Parameters:
bits:i64
Returns: f64
Defined at line 263
st_f16
f16 element i.
pub fn st_f16(b: Vec<i64>, t: StTensor, i: i64) -> f64 {Parameters:
b:Vec<i64>t:StTensori:i64
Returns: f64
Defined at line 268
st_bf16
bf16 element i.
pub fn st_bf16(b: Vec<i64>, t: StTensor, i: i64) -> f64 {Parameters:
b:Vec<i64>t:StTensori:i64
Returns: f64
Defined at line 273
st_int
Integer element i (I8..I64, sign-extended).
pub fn st_int(b: Vec<i64>, t: StTensor, i: i64) -> i64 {Parameters:
b:Vec<i64>t:StTensori:i64
Returns: i64
Defined at line 285
st_uint
Unsigned element i (U8..U32; U64 truncated to lo32 — document it).
pub fn st_uint(b: Vec<i64>, t: StTensor, i: i64) -> i64 {Parameters:
b:Vec<i64>t:StTensori:i64
Returns: i64
Defined at line 318
st_meta
metadata object value for key, or "" — metadata stays a JSON string the caller interprets.
pub fn st_meta(st: StFile, key: str) -> str {Parameters:
st:StFilekey:str
Returns: str
Defined at line 332
Generated by scribe, the Fides documentation generator