ggerganov commited on
Commit
67c5387
·
1 Parent(s): d692b06

ggml : restore sigmoid decl order (ggml/0)

Browse files
Files changed (2) hide show
  1. ggml.c +15 -15
  2. ggml.h +4 -4
ggml.c CHANGED
@@ -1951,8 +1951,8 @@ inline static void ggml_vec_step_f32 (const int n, float * y, const float * x) {
1951
  inline static void ggml_vec_tanh_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = tanhf(x[i]); }
1952
  inline static void ggml_vec_elu_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = (x[i] > 0.f) ? x[i] : expf(x[i])-1; }
1953
  inline static void ggml_vec_relu_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = (x[i] > 0.f) ? x[i] : 0.f; }
1954
- inline static void ggml_vec_sigmoid_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = 1.f / (1.f + expf(-x[i])); }
1955
  inline static void ggml_vec_leaky_relu_f32 (const int n, float * y, const float * x, const float ns) { for (int i = 0; i < n; ++i) y[i] = ((x[i] > 0.f) ? x[i] : 0.f) + ns * ((x[i] < 0.0f) ? x[i] : 0.f); }
 
1956
  // TODO: optimize performance
1957
  inline static void ggml_vec_hardswish_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = x[i] * fminf(1.0f, fmaxf(0.0f, (x[i] + 3.0f) / 6.0f)); }
1958
  inline static void ggml_vec_hardsigmoid_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = fminf(1.0f, fmaxf(0.0f, (x[i] + 3.0f) / 6.0f)); }
@@ -4545,20 +4545,6 @@ struct ggml_tensor * ggml_relu_inplace(
4545
  return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_RELU);
4546
  }
4547
 
4548
- // ggml_sigmoid
4549
-
4550
- struct ggml_tensor * ggml_sigmoid(
4551
- struct ggml_context * ctx,
4552
- struct ggml_tensor * a) {
4553
- return ggml_unary(ctx, a, GGML_UNARY_OP_SIGMOID);
4554
- }
4555
-
4556
- struct ggml_tensor * ggml_sigmoid_inplace(
4557
- struct ggml_context * ctx,
4558
- struct ggml_tensor * a) {
4559
- return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_SIGMOID);
4560
- }
4561
-
4562
  // ggml_leaky_relu
4563
 
4564
  struct ggml_tensor * ggml_leaky_relu(
@@ -4580,6 +4566,20 @@ struct ggml_tensor * ggml_leaky_relu(
4580
  return result;
4581
  }
4582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4583
  // ggml_gelu
4584
 
4585
  struct ggml_tensor * ggml_gelu(
 
1951
  inline static void ggml_vec_tanh_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = tanhf(x[i]); }
1952
  inline static void ggml_vec_elu_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = (x[i] > 0.f) ? x[i] : expf(x[i])-1; }
1953
  inline static void ggml_vec_relu_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = (x[i] > 0.f) ? x[i] : 0.f; }
 
1954
  inline static void ggml_vec_leaky_relu_f32 (const int n, float * y, const float * x, const float ns) { for (int i = 0; i < n; ++i) y[i] = ((x[i] > 0.f) ? x[i] : 0.f) + ns * ((x[i] < 0.0f) ? x[i] : 0.f); }
1955
+ inline static void ggml_vec_sigmoid_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = 1.f / (1.f + expf(-x[i])); }
1956
  // TODO: optimize performance
1957
  inline static void ggml_vec_hardswish_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = x[i] * fminf(1.0f, fmaxf(0.0f, (x[i] + 3.0f) / 6.0f)); }
1958
  inline static void ggml_vec_hardsigmoid_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = fminf(1.0f, fmaxf(0.0f, (x[i] + 3.0f) / 6.0f)); }
 
4545
  return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_RELU);
4546
  }
4547
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4548
  // ggml_leaky_relu
4549
 
4550
  struct ggml_tensor * ggml_leaky_relu(
 
4566
  return result;
4567
  }
4568
 
4569
+ // ggml_sigmoid
4570
+
4571
+ struct ggml_tensor * ggml_sigmoid(
4572
+ struct ggml_context * ctx,
4573
+ struct ggml_tensor * a) {
4574
+ return ggml_unary(ctx, a, GGML_UNARY_OP_SIGMOID);
4575
+ }
4576
+
4577
+ struct ggml_tensor * ggml_sigmoid_inplace(
4578
+ struct ggml_context * ctx,
4579
+ struct ggml_tensor * a) {
4580
+ return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_SIGMOID);
4581
+ }
4582
+
4583
  // ggml_gelu
4584
 
4585
  struct ggml_tensor * ggml_gelu(
ggml.h CHANGED
@@ -1066,10 +1066,6 @@ extern "C" {
1066
  struct ggml_context * ctx,
1067
  struct ggml_tensor * a);
1068
 
1069
- GGML_API struct ggml_tensor * ggml_sigmoid(
1070
- struct ggml_context * ctx,
1071
- struct ggml_tensor * a);
1072
-
1073
  GGML_API struct ggml_tensor * ggml_leaky_relu(
1074
  struct ggml_context * ctx,
1075
  struct ggml_tensor * a, float negative_slope, bool inplace);
@@ -1078,6 +1074,10 @@ extern "C" {
1078
  struct ggml_context * ctx,
1079
  struct ggml_tensor * a);
1080
 
 
 
 
 
1081
  GGML_API struct ggml_tensor * ggml_sigmoid_inplace(
1082
  struct ggml_context * ctx,
1083
  struct ggml_tensor * a);
 
1066
  struct ggml_context * ctx,
1067
  struct ggml_tensor * a);
1068
 
 
 
 
 
1069
  GGML_API struct ggml_tensor * ggml_leaky_relu(
1070
  struct ggml_context * ctx,
1071
  struct ggml_tensor * a, float negative_slope, bool inplace);
 
1074
  struct ggml_context * ctx,
1075
  struct ggml_tensor * a);
1076
 
1077
+ GGML_API struct ggml_tensor * ggml_sigmoid(
1078
+ struct ggml_context * ctx,
1079
+ struct ggml_tensor * a);
1080
+
1081
  GGML_API struct ggml_tensor * ggml_sigmoid_inplace(
1082
  struct ggml_context * ctx,
1083
  struct ggml_tensor * a);