| ggml_matmul | R Documentation |
%*%)Computes A %*% B on the Vulkan GPU and returns an ordinary R matrix,
with a transparent CPU fallback. A drop-in accelerator for a large matrix
multiply: no autograd, no wrapper types required — plain matrices in and out.
ggml_matmul(A, B, device = "auto", prec = "f32")
A, B |
Numeric matrices with |
device |
|
prec |
|
Precision: R multiplies in double precision (f64); a GPU offers f32 at best,
so the GPU result never matches R to full double precision. prec = "f32"
(the default) requests the f32 accumulation kernel, but how close the result
actually lands depends on the Vulkan driver: some accumulate mul_mat in
f16 regardless (e.g. RADV / Mesa), giving a relative error around
1e-3 either way. Treat the GPU path as a fast, approximate multiply —
typically 1e-3, better on drivers with true f32 accumulation — not a
bit-for-bit replacement for %*%. prec = "f16" only ever lowers
precision; use it when speed matters more than the last digits.
The product A %*% B as a numeric matrix.
ggml_crossprod, ggml_tcrossprod,
as_gpu_matrix
A <- matrix(rnorm(4), 2); B <- matrix(rnorm(4), 2)
ggml_matmul(A, B, device = "cpu")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.