gpuLoadTensor (Function)

Signature: gpuLoadTensor(path: string, name: string) -> Result<GpuBuffer<float>, Error>

Description: Reads one named tensor out of a safetensors file into a GpuBuffer, widening F64, F32, F16 or BF16 storage exactly. An unknown name, another dtype or a truncated file is an Error saying which.

Parameters

  • path (string): The safetensors file
  • name (string): The tensor's name in the header

Returns: Result<GpuBuffer, Error>

Example

gpuLoadTensor("model.safetensors", "wte.weight") ?: toGpu([0.0])
gpuLoadTensor ("model.safetensors", "wte.weight") ?: toGpu [0.0]