| ggml_permute | R Documentation |
Permutes the tensor dimensions according to specified axes. CRITICAL for attention mechanisms in transformers.
ggml_permute(ctx, a, axis0, axis1, axis2, axis3)
ctx |
GGML context |
a |
Input tensor |
axis0 |
New position for axis 0 |
axis1 |
New position for axis 1 |
axis2 |
New position for axis 2 |
axis3 |
New position for axis 3 |
Permuted tensor
ctx <- ggml_init(16 * 1024 * 1024)
# Create 4D tensor: (2, 3, 4, 5)
t <- ggml_new_tensor_4d(ctx, GGML_TYPE_F32, 2, 3, 4, 5)
# Swap axes 0 and 1: result shape (3, 2, 4, 5)
t_perm <- ggml_permute(ctx, t, 1, 0, 2, 3)
ggml_free(ctx)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.