ggml_with_temp_ctx: Execute with Temporary Context

View source: R/helpers.R

ggml_with_temp_ctxR Documentation

Execute with Temporary Context

Description

Creates a temporary context, executes code, and frees it automatically. Useful when you need to create large temporary tensors.

Usage

ggml_with_temp_ctx(mem_size, expr)

Arguments

mem_size

Context memory size in bytes

expr

Expression to evaluate with the temporary context

Value

Result of the expression

Examples


# Create tensors in temporary context
result <- ggml_with_temp_ctx(1024 * 1024, {
  a <- ggml_new_tensor_1d(ctx, GGML_TYPE_F32, 10)
  ggml_set_f32(a, 1:10)
  ggml_get_f32(a)
})


ggmlR documentation built on July 14, 2026, 1:08 a.m.