clika_runtime.io functions
encode_audio
encode_audio(*args, **kwargs)
encode_audio(samples: clika_runtime._core.Tensor, sample_rate: int) -> bytes
encode_audio(samples, sample_rate) -> bytes
Encode a waveform as a 16-bit PCM WAV payload; the same accepted shapes and dtypes as save_audio, and save_audio writes exactly these bytes.
load_audio
load_audio(*args, **kwargs)
load_audio(path: str, target_sample_rate: int = 0, target_channels: int = 0) -> tuple
load_audio(path, target_sample_rate=0, target_channels=0) -> tuple[Tensor, int, int, int]
Decode an audio file (WAV, FLAC, MP3 or OGG Vorbis) to a host Float32 tensor: returns (samples, sample_rate, channels, frames); samples is [frames] for mono or [frames, channels] interleaved. A target_sample_rate / target_channels of 0 keeps the file's native value; a non-zero value resamples / remixes to it. A container outside that set (OGG Opus, M4A/AAC, ...) raises with the file and the container named; damaged data, or a file that is not audio, raises naming what the file holds.
load_gguf
load_gguf(*args, **kwargs)
load_gguf(path: str, device: clika_runtime._core.Device = device(type='cpu')) -> tuple
load_gguf(path, device='cpu') -> tuple[dict[str, Tensor], str]
Load a .gguf checkpoint: returns (tensors as dict[str, Tensor], the file's metadata key/value pairs as JSON text, e.g. general.architecture).
load_npy
load_npy(*args, **kwargs)
load_npy(path: str, device: clika_runtime._core.Device = device(type='cpu')) -> clika_runtime._core.Tensor
load_npy(path, device='cpu') -> Tensor
Load a .npy file as one tensor.
load_safetensors
load_safetensors(*args, **kwargs)
load_safetensors(path: str, device: clika_runtime._core.Device = device(type='cpu')) -> dict
load_safetensors(path, device='cpu') -> dict[str, Tensor]
Load a .safetensors file as a dict of tensors on device (unordered; load_safetensors_entries keeps the file's order and its metadata).
load_safetensors_entries
load_safetensors_entries(*args, **kwargs)
load_safetensors_entries(path: str, device: clika_runtime._core.Device = device(type='cpu')) -> clika_runtime._core.io.SafetensorsEntries
load_safetensors_entries(path, device='cpu') -> SafetensorsEntries
Load a .safetensors file, or a sharded checkpoint through its .index.json, onto device in the file's own order: .entries lists the (name, tensor) pairs as the header states them (a sharded checkpoint: the index's weight_map order) and .metadata the checkpoint-level metadata as (key, value) string pairs in header order (a single file's metadata; a sharded checkpoint's index document metadata; a non-string value arrives as its JSON text).
load_torch_checkpoint
load_torch_checkpoint(*args, **kwargs)
load_torch_checkpoint(path: str, device: clika_runtime._core.Device = device(type='cpu')) -> dict
load_torch_checkpoint(path, device='cpu') -> dict[str, Tensor]
Load a torch checkpoint (.pt / .pth / .bin / .ckpt, a saved state dict) as a dict of tensors on device.
open_gguf
open_gguf(*args, **kwargs)
open_gguf(path: str, *, device: object | None = None, sticky: bool = False) -> tuple
open_gguf(path, *, device=None, sticky=False) -> tuple[TensorsContainer, str]
Open a .gguf checkpoint as (a container whose entries materialize on first use, the file's metadata as JSON text).
open_safetensors
open_safetensors(*args, **kwargs)
open_safetensors(path: str, *, device: object | None = None, sticky: bool = False) -> clika_runtime._core.io.TensorsContainer
open_safetensors(path, *, device=None, sticky=False) -> TensorsContainer
Open a .safetensors file as a container whose entries materialize on first use, on device (None = the CPU).
open_torch_checkpoint
open_torch_checkpoint(*args, **kwargs)
open_torch_checkpoint(path: str, *, device: object | None = None, sticky: bool = False) -> clika_runtime._core.io.TensorsContainer
open_torch_checkpoint(path, *, device=None, sticky=False) -> TensorsContainer
Open a torch checkpoint as a container whose entries materialize on first use, on device (None = the CPU).
save_audio
save_audio(*args, **kwargs)
save_audio(samples: clika_runtime._core.Tensor, sample_rate: int, path: str) -> None
save_audio(samples, sample_rate, path) -> None
Write a waveform as a 16-bit PCM WAV file at path (created / truncated). samples is [frames] (mono) or [frames, channels] interleaved: a float tensor holds values in [-1, 1] (values outside clip); an Int16 tensor is written as is. sample_rate is in Hz. The extension is the format request: .wav (or none) writes; a name asking for another container (.mp3, .ogg, ...) raises with nothing written.
save_npy
save_npy(*args, **kwargs)
save_npy(tensor: clika_runtime._core.Tensor, path: str) -> None
save_npy(tensor, path) -> None
Write one tensor to a .npy file.
save_safetensors
save_safetensors(*args, **kwargs)
save_safetensors(entries: object, path: str, metadata: object | None = None) -> None
save_safetensors(entries, path, metadata=None) -> None
Write tensors to a .safetensors file in the given order: entries is a dict (walked in insertion order) or a sequence of (name, tensor) pairs, and the header lists them as passed. metadata, a dict or a sequence of (key, value) string pairs, becomes the file's metadata in the given order. A repeated name, or the name metadata, is an error and nothing is written.