MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / ggml_permute

Function ggml_permute

subprojects/llama.cpp/ggml/src/ggml.c:3703–3755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3701// ggml_permute
3702
3703struct ggml_tensor * ggml_permute(
3704 struct ggml_context * ctx,
3705 struct ggml_tensor * a,
3706 int axis0,
3707 int axis1,
3708 int axis2,
3709 int axis3) {
3710 GGML_ASSERT(axis0 >= 0 && axis0 < GGML_MAX_DIMS);
3711 GGML_ASSERT(axis1 >= 0 && axis1 < GGML_MAX_DIMS);
3712 GGML_ASSERT(axis2 >= 0 && axis2 < GGML_MAX_DIMS);
3713 GGML_ASSERT(axis3 >= 0 && axis3 < GGML_MAX_DIMS);
3714
3715 GGML_ASSERT(axis0 != axis1);
3716 GGML_ASSERT(axis0 != axis2);
3717 GGML_ASSERT(axis0 != axis3);
3718 GGML_ASSERT(axis1 != axis2);
3719 GGML_ASSERT(axis1 != axis3);
3720 GGML_ASSERT(axis2 != axis3);
3721
3722 struct ggml_tensor * result = ggml_view_tensor(ctx, a);
3723 ggml_format_name(result, "%s (permuted)", a->name);
3724
3725 int ne[GGML_MAX_DIMS];
3726 int nb[GGML_MAX_DIMS];
3727
3728 ne[axis0] = a->ne[0];
3729 ne[axis1] = a->ne[1];
3730 ne[axis2] = a->ne[2];
3731 ne[axis3] = a->ne[3];
3732
3733 nb[axis0] = a->nb[0];
3734 nb[axis1] = a->nb[1];
3735 nb[axis2] = a->nb[2];
3736 nb[axis3] = a->nb[3];
3737
3738 result->ne[0] = ne[0];
3739 result->ne[1] = ne[1];
3740 result->ne[2] = ne[2];
3741 result->ne[3] = ne[3];
3742
3743 result->nb[0] = nb[0];
3744 result->nb[1] = nb[1];
3745 result->nb[2] = nb[2];
3746 result->nb[3] = nb[3];
3747
3748 result->op = GGML_OP_PERMUTE;
3749 result->src[0] = a;
3750
3751 int32_t params[] = { axis0, axis1, axis2, axis3 };
3752 ggml_set_op_params(result, params, sizeof(params));
3753
3754 return result;
3755}
3756
3757// ggml_transpose
3758

Callers 15

build_attnMethod · 0.85
buildMethod · 0.85
buildMethod · 0.85
buildMethod · 0.85
buildMethod · 0.85
buildMethod · 0.85
rms_norm_2dMethod · 0.85
build_mobilenet_attnMethod · 0.85
buildMethod · 0.85
buildMethod · 0.85

Calls 3

ggml_view_tensorFunction · 0.85
ggml_format_nameFunction · 0.85
ggml_set_op_paramsFunction · 0.85

Tested by 10

test_view_inplaceFunction · 0.68
build_graphMethod · 0.68
build_graphMethod · 0.68
build_graphMethod · 0.68
build_graphMethod · 0.68
build_graphMethod · 0.68
build_graphMethod · 0.68
build_graphMethod · 0.68
build_graphMethod · 0.68
llm_build_kqvMethod · 0.68