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

Function ggml_soft_max_impl

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

Source from the content-addressed store, hash-verified

3933// ggml_soft_max
3934
3935static struct ggml_tensor * ggml_soft_max_impl(
3936 struct ggml_context * ctx,
3937 struct ggml_tensor * a,
3938 struct ggml_tensor * mask,
3939 float scale,
3940 float max_bias,
3941 bool inplace) {
3942 GGML_ASSERT(ggml_is_contiguous(a));
3943
3944 if (mask) {
3945 GGML_ASSERT(mask->type == GGML_TYPE_F16 || mask->type == GGML_TYPE_F32);
3946 GGML_ASSERT(ggml_is_contiguous(mask));
3947 GGML_ASSERT(mask->ne[0] == a->ne[0]);
3948 GGML_ASSERT(mask->ne[1] >= a->ne[1]);
3949 GGML_ASSERT(a->ne[2]%mask->ne[2] == 0);
3950 GGML_ASSERT(a->ne[3]%mask->ne[3] == 0);
3951 }
3952
3953 if (max_bias > 0.0f) {
3954 GGML_ASSERT(mask);
3955 }
3956
3957 struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a);
3958
3959 float params[] = { scale, max_bias };
3960 ggml_set_op_params(result, params, sizeof(params));
3961
3962 result->op = GGML_OP_SOFT_MAX;
3963 result->src[0] = a;
3964 result->src[1] = mask;
3965
3966 return result;
3967}
3968
3969struct ggml_tensor * ggml_soft_max(
3970 struct ggml_context * ctx,

Callers 4

ggml_soft_maxFunction · 0.85
ggml_soft_max_inplaceFunction · 0.85
ggml_soft_max_extFunction · 0.85

Calls 4

ggml_is_contiguousFunction · 0.85
ggml_view_tensorFunction · 0.85
ggml_dup_tensorFunction · 0.85
ggml_set_op_paramsFunction · 0.85

Tested by

no test coverage detected