ggml_permute: Permute Tensor Dimensions (Graph)

View source: R/operations.R

ggml_permuteR Documentation

Permute Tensor Dimensions (Graph)

Description

Permutes the tensor dimensions according to specified axes. CRITICAL for attention mechanisms in transformers.

Usage

ggml_permute(ctx, a, axis0, axis1, axis2, axis3)

Arguments

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

Value

Permuted tensor

Examples


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)


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