Learn R Programming

ggmlR (version 0.6.1)

ggml_with_temp_ctx: 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)

Value

Result of the expression

Arguments

mem_size

Context memory size in bytes

expr

Expression to evaluate with the temporary context

Examples

Run this code
# \donttest{
# 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)
})
# }

Run the code above in your browser using DataLab