| ggml_concat | R Documentation |
Concatenates two tensors along a specified dimension. CRITICAL for KV-cache operations in transformers.
ggml_concat(ctx, a, b, dim = 0)
ctx |
GGML context |
a |
First tensor |
b |
Second tensor (must match a in all dimensions except the concat dim) |
dim |
Dimension along which to concatenate (0-3) |
Concatenated tensor
ctx <- ggml_init(16 * 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, rnorm(12))
ggml_set_f32(b, rnorm(8))
# Concatenate along dimension 1: result is 4x5
c <- ggml_concat(ctx, a, b, 1)
graph <- ggml_build_forward_expand(ctx, c)
ggml_graph_compute(ctx, graph)
ggml_free(ctx)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.