ggml_mul_mat: Matrix Multiplication (Graph)

View source: R/operations.R

ggml_mul_matR Documentation

Matrix Multiplication (Graph)

Description

Creates a graph node for matrix multiplication. CRITICAL for LLM operations. For matrices A (m x n) and B (n x p), computes C = A * B (m x p).

Usage

ggml_mul_mat(ctx, a, b)

Arguments

ctx

GGML context

a

First matrix tensor

b

Second matrix tensor

Value

Tensor representing the matrix multiplication

Examples


ctx <- ggml_init(1024 * 1024)
A <- ggml_new_tensor_2d(ctx, GGML_TYPE_F32, 4, 3)
B <- ggml_new_tensor_2d(ctx, GGML_TYPE_F32, 4, 2)
ggml_set_f32(A, 1:12)
ggml_set_f32(B, 1:8)
C <- ggml_mul_mat(ctx, A, B)
graph <- ggml_build_forward_expand(ctx, C)
ggml_graph_compute(ctx, graph)
ggml_get_f32(C)
ggml_free(ctx)


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