loadTensor (Function)

Signature: loadTensor(path: string, name: string) -> Result<List<float>, Error>

Description: Reads one named F64, F32, F16 or BF16 tensor out of a safetensors file as a List, every element widened exactly. Nothing touches the GPU surface.

Parameters

  • path (string): Path to the .safetensors file
  • name (string): Tensor name in its header, e.g. "wte.weight"

Returns: Result<List, Error>

Example

match loadTensor("model.safetensors", "wte.weight") {
  Success { value } => print("${listLength(value)} floats")
  Error { message } => print(message)
}
match loadTensor ("model.safetensors", "wte.weight")
    Success value => print "${listLength(value)} floats"
    Error message => print message