template <typename receiver_type_>
class model Each verb is written once, filling its C struct with the result as its output. Every input, handler, report and arena a deferred call names stays the caller's until it is final.
Ask your coding agent about this page, or add the docs server to it
curl -s 'https://www.unum.cloud/docs/uform/cpp/models.md' | claude -p "How would this fit my code?"model_t::load_ram and model_t::load_vram copy a safetensors checkpoint into host memory or onto GPUs, and load_ram_buffer and load_vram_buffer take the checkpoint’s bytes instead.
Each takes the C argument struct, which reaches the executor, the placement and its class ceiling, the quantization and a progress handler, and always loads blocking:
std::int32_t const device = 0;
auto [model, model_status] = uf::model_t::load_vram({
.executor = executor.handle(),
.path = uf::bytes_view("model.safetensors"),
.vram = {.devices = &device, .devices_count = 1},
.quantization = uform_scalar_e4m3_k,
});
auto [description, describe_status] = model.on(executor).describe(); // geometry, placement, classes and headsA description reports the cpu_class or gpu_class the model dispatched as, and the heads the checkpoint carries: a nonzero token_width for token vectors, and a nonzero choice_temperature_groups for choices.
Blocks run in uform_scalar_bf16_k, as the checkpoint stores them, or uform_scalar_e4m3_k quantized at load, and a zero quantization is refused.
modelA model and its verbs, completed as receiver_type_ says: the owning handle blocks on the calling thread, on blocks on an executor, and both answer a status_t or an expected, while deferred submits to an executor and answers a deferred call.16template <typename receiver_type_>
class model Each verb is written once, filling its C struct with the result as its output. Every input, handler, report and arena a deferred call names stays the caller's until it is final.
modelrequires an_owning_receiver<receiver_type_>
model() noexcept=default; handle_fieldThe output field a lifecycle verb writes the new handle into.requires an_owning_receiver<receiver_type_>
uform_model_t * handle_field() noexcept; onThe same handle, whose verbs block on executor.model<caller_owned<uform_model_t, uform_completion_blocking_k>> on(
executor_t const & executor) const noexcept; deferredThe same handle, whose verbs submit to executor, each answering a deferred call.model<caller_owned<uform_model_t, uform_completion_deferred_k>> deferred(
executor_t const & executor) const noexcept; describeReports the model's geometry, placement, classes and heads in one call.deferrable<uform_model_description_t> describe() const noexcept; text_encodeEncodes UTF-8 texts through one forward, a token per byte, keeping the surfaces kept names in arena.deferrable<encoded_t> text_encode(
tape_view<char> texts,
encode_outputs_t kept,
text_encode_config_t const & config,
arena_t & arena) const noexcept; text_chooseScores each item's legal choices, one byte each, after its UTF-8 state in texts, answering one probability per choice in arena, a softmax over the item's choices.deferrable<tape_view<float>> text_choose(
tape_view<char> texts,
tape_view<char> choices,
text_choose_config_t const & config,
arena_t & arena) const noexcept; image_encodeDecodes and encodes JPEG, PNG or WebP images; an undecodable file fails the call with status_code_t::malformed_k.deferrable<encoded_t> image_encode(
tape_view<std::uint8_t> images,
encode_outputs_t kept,
image_encode_config_t const & config,
arena_t & arena) const noexcept; image_encode_pixelsEncodes decoded images of interleaved 8-bit RGB, item i holding heights [i] rows of widths [i] pixels.deferrable<encoded_t> image_encode_pixels(
tape_view<std::uint8_t> pixels,
std::span<std::uint32_t const> heights,
std::span<std::uint32_t const> widths,
encode_outputs_t kept,
image_encode_config_t const & config,
arena_t & arena) const noexcept; video_encodeDecodes and encodes MP4 or WebM videos.deferrable<encoded_t> video_encode(
tape_view<std::uint8_t> videos,
encode_outputs_t kept,
video_encode_config_t const & config,
arena_t & arena) const noexcept; audio_encodeDecodes and encodes WAV, FLAC, MP3 or Opus recordings, resampled to mono.deferrable<encoded_t> audio_encode(
tape_view<std::uint8_t> recordings,
encode_outputs_t kept,
audio_encode_config_t const & config,
arena_t & arena) const noexcept; audio_encode_samplesEncodes decoded mono samples sharing one sample_rate, resampled to the model's rate where it differs.deferrable<encoded_t> audio_encode_samples(
tape_view<float> samples,
std::uint32_t sample_rate,
encode_outputs_t kept,
audio_encode_config_t const & config,
arena_t & arena) const noexcept; load_ramCopies a safetensors checkpoint file into host memory and packs it for the CPU, blocking.requires an_owning_receiver<receiver_type_>
expected<model> load_ram(uform_model_load_ram_t arguments) noexcept; load_ram_bufferCopies a checkpoint held in memory into host memory and packs it for the CPU, blocking.requires an_owning_receiver<receiver_type_>
expected<model> load_ram_buffer(
uform_model_load_ram_buffer_t arguments) noexcept; load_vramCopies a checkpoint file onto the GPUs arguments names and packs it there, blocking.requires an_owning_receiver<receiver_type_>
expected<model> load_vram(uform_model_load_vram_t arguments) noexcept; load_vram_bufferCopies a checkpoint held in memory onto the GPUs arguments names, blocking.requires an_owning_receiver<receiver_type_>
expected<model> load_vram_buffer(
uform_model_load_vram_buffer_t arguments) noexcept;