-
Notifications
You must be signed in to change notification settings - Fork 12.2k
ggml: Add epsilon as a parameter for group_norm #8818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5358,6 +5358,7 @@ static struct ggml_tensor * ggml_group_norm_impl( | |
struct ggml_context * ctx, | ||
struct ggml_tensor * a, | ||
int n_groups, | ||
float eps, | ||
bool inplace) { | ||
|
||
bool is_node = false; | ||
|
@@ -5368,7 +5369,8 @@ static struct ggml_tensor * ggml_group_norm_impl( | |
|
||
struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a); | ||
|
||
result->op_params[0] = n_groups; | ||
ggml_set_op_params_i32(result, 0, n_groups); | ||
ggml_set_op_params_f32(result, 1, eps); | ||
|
||
result->op = GGML_OP_GROUP_NORM; | ||
result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL; | ||
|
@@ -5380,15 +5382,17 @@ static struct ggml_tensor * ggml_group_norm_impl( | |
struct ggml_tensor * ggml_group_norm( | ||
struct ggml_context * ctx, | ||
struct ggml_tensor * a, | ||
int n_groups) { | ||
return ggml_group_norm_impl(ctx, a, n_groups, false); | ||
int n_groups, | ||
float eps) { | ||
return ggml_group_norm_impl(ctx, a, n_groups, eps, false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Side question) Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess yes? |
||
} | ||
|
||
struct ggml_tensor * ggml_group_norm_inplace( | ||
struct ggml_context * ctx, | ||
struct ggml_tensor * a, | ||
int n_groups) { | ||
return ggml_group_norm_impl(ctx, a, n_groups, true); | ||
int n_groups, | ||
float eps) { | ||
return ggml_group_norm_impl(ctx, a, n_groups, eps, true); | ||
} | ||
|
||
// ggml_mul_mat | ||
|
@@ -12079,10 +12083,11 @@ static void ggml_compute_forward_group_norm_f32( | |
|
||
GGML_TENSOR_UNARY_OP_LOCALS | ||
|
||
const float eps = 1e-6f; // TODO: make this a parameter | ||
|
||
// TODO: optimize | ||
|
||
float eps; | ||
memcpy(&eps, dst->op_params + 1, sizeof(float)); | ||
|
||
int n_channels = src0->ne[2]; | ||
int n_groups = dst->op_params[0]; | ||
int n_channels_per_group = (n_channels + n_groups - 1) / n_groups; | ||
|
Uh oh!
There was an error while loading. Please reload this page.