Parses an .onnx file, builds a ggml computation graph, and allocates tensors on the specified device. Weights are loaded via memory-mapped file (zero-copy where possible).
onnx_load(
path,
device = NULL,
input_shapes = NULL,
n_threads = NULL,
dtype = "f32"
)An opaque model object (external pointer) for use with
onnx_run(), onnx_summary(), and onnx_inputs().
Path to .onnx file.
Backend device: "vulkan" (default if available)
or "cpu".
Optional named list of integer vectors specifying
fixed shapes for inputs with dynamic dimensions. Names must match
input tensor names. Each shape must include all dimensions including
batch, e.g. list(image = c(1L, 3L, 224L, 224L)).
Required when the model has dynamic dimensions and no default shape.
Number of CPU threads. NULL (default) reads
getOption("ggmlR.n_threads"); if that is also unset, uses
parallel::detectCores() - 1 (minimum 1).
Weight precision: "f32" (default) or "f16".
When "f16", large weight tensors (>= 256 elements) are stored
in half-precision for faster Vulkan compute and lower VRAM usage.
Small tensors (bias, scalars, batch-norm params) remain in F32
for numerical stability. Inputs and outputs are always F32.