@@ -1458,7 +1458,6 @@ inline static void ggml_vec_scale_f32(const int n, float * y, const float v) {
1458
1458
inline static void ggml_vec_norm_f32 (const int n, float * s, const float * x) { ggml_vec_dot_f32(n, s, x, x); *s = sqrtf(*s); }
1459
1459
inline static void ggml_vec_sqr_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = x[i]*x[i]; }
1460
1460
inline static void ggml_vec_sqrt_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = sqrtf(x[i]); }
1461
- inline static void ggml_vec_exp_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = expf(x[i]); }
1462
1461
inline static void ggml_vec_log_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = logf(x[i]); }
1463
1462
inline static void ggml_vec_abs_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = fabsf(x[i]); }
1464
1463
inline static void ggml_vec_sgn_f32 (const int n, float * y, const float * x) { for (int i = 0; i < n; ++i) y[i] = (x[i] > 0.f) ? 1.f : ((x[i] < 0.f) ? -1.f : 0.f); }
@@ -1654,7 +1653,6 @@ static const char * GGML_OP_NAME[GGML_OP_COUNT] = {
1654
1653
"DIV",
1655
1654
"SQR",
1656
1655
"SQRT",
1657
- "EXP",
1658
1656
"LOG",
1659
1657
"SUM",
1660
1658
"SUM_ROWS",
@@ -1688,7 +1686,6 @@ static const char * GGML_OP_NAME[GGML_OP_COUNT] = {
1688
1686
"DIAG_MASK_ZERO",
1689
1687
"SOFT_MAX",
1690
1688
"SOFT_MAX_BACK",
1691
- "SOFT_PLUS",
1692
1689
"ROPE",
1693
1690
"ROPE_BACK",
1694
1691
"ALIBI",
@@ -1729,7 +1726,7 @@ static const char * GGML_OP_NAME[GGML_OP_COUNT] = {
1729
1726
"CROSS_ENTROPY_LOSS_BACK",
1730
1727
};
1731
1728
1732
- static_assert(GGML_OP_COUNT == 75 , "GGML_OP_COUNT != 75 ");
1729
+ static_assert(GGML_OP_COUNT == 73 , "GGML_OP_COUNT != 73 ");
1733
1730
1734
1731
static const char * GGML_OP_SYMBOL[GGML_OP_COUNT] = {
1735
1732
"none",
@@ -1743,7 +1740,6 @@ static const char * GGML_OP_SYMBOL[GGML_OP_COUNT] = {
1743
1740
"x/y",
1744
1741
"x^2",
1745
1742
"√x",
1746
- "e^x", // or should this be "exp(x)"?
1747
1743
"log(x)",
1748
1744
"Σx",
1749
1745
"Σx_k",
@@ -1777,7 +1773,6 @@ static const char * GGML_OP_SYMBOL[GGML_OP_COUNT] = {
1777
1773
"diag_mask_zero(x)",
1778
1774
"soft_max(x)",
1779
1775
"soft_max_back(x)",
1780
- "soft_plus(x)",
1781
1776
"rope(x)",
1782
1777
"rope_back(x)",
1783
1778
"alibi(x)",
@@ -1818,7 +1813,7 @@ static const char * GGML_OP_SYMBOL[GGML_OP_COUNT] = {
1818
1813
"cross_entropy_loss_back(x,y)",
1819
1814
};
1820
1815
1821
- static_assert(GGML_OP_COUNT == 75 , "GGML_OP_COUNT != 75 ");
1816
+ static_assert(GGML_OP_COUNT == 73 , "GGML_OP_COUNT != 73 ");
1822
1817
1823
1818
static_assert(GGML_OP_POOL_COUNT == 2, "GGML_OP_POOL_COUNT != 2");
1824
1819
@@ -3630,39 +3625,6 @@ struct ggml_tensor * ggml_sqrt_inplace(
3630
3625
return ggml_sqrt_impl(ctx, a, true);
3631
3626
}
3632
3627
3633
- // ggml_exp
3634
-
3635
- static struct ggml_tensor * ggml_exp_impl(
3636
- struct ggml_context * ctx,
3637
- struct ggml_tensor * a,
3638
- bool inplace) {
3639
- bool is_node = false;
3640
-
3641
- if (!inplace && (a->grad)) {
3642
- is_node = true;
3643
- }
3644
-
3645
- struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a);
3646
-
3647
- result->op = GGML_OP_EXP;
3648
- result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
3649
- result->src[0] = a;
3650
-
3651
- return result;
3652
- }
3653
-
3654
- struct ggml_tensor * ggml_exp(
3655
- struct ggml_context * ctx,
3656
- struct ggml_tensor * a) {
3657
- return ggml_exp_impl(ctx, a, false);
3658
- }
3659
-
3660
- struct ggml_tensor * ggml_exp_inplace(
3661
- struct ggml_context * ctx,
3662
- struct ggml_tensor * a) {
3663
- return ggml_exp_impl(ctx, a, true);
3664
- }
3665
-
3666
3628
// ggml_log
3667
3629
3668
3630
static struct ggml_tensor * ggml_log_impl(
@@ -5143,40 +5105,6 @@ struct ggml_tensor * ggml_soft_max_back_inplace(
5143
5105
return ggml_soft_max_back_impl(ctx, a, b, true);
5144
5106
}
5145
5107
5146
- // ggml_soft_plus
5147
-
5148
- static struct ggml_tensor * ggml_soft_plus_impl(
5149
- struct ggml_context * ctx,
5150
- struct ggml_tensor * a,
5151
- bool inplace) {
5152
-
5153
- bool is_node = false;
5154
-
5155
- if (a->grad) {
5156
- is_node = true; // TODO : implement backward pass
5157
- }
5158
-
5159
- struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a);
5160
-
5161
- result->op = GGML_OP_SOFT_PLUS;
5162
- result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
5163
- result->src[0] = a;
5164
-
5165
- return result;
5166
- }
5167
-
5168
- struct ggml_tensor * ggml_soft_plus(
5169
- struct ggml_context * ctx,
5170
- struct ggml_tensor * a) {
5171
- return ggml_soft_plus_impl(ctx, a, false);
5172
- }
5173
-
5174
- struct ggml_tensor * ggml_soft_plus_inplace(
5175
- struct ggml_context * ctx,
5176
- struct ggml_tensor * a) {
5177
- return ggml_soft_plus_impl(ctx, a, true);
5178
- }
5179
-
5180
5108
// ggml_rope
5181
5109
5182
5110
static struct ggml_tensor * ggml_rope_impl(
@@ -8458,57 +8386,6 @@ static void ggml_compute_forward_sqrt(
8458
8386
}
8459
8387
}
8460
8388
8461
- // ggml_compute_forward_exp
8462
-
8463
- static void ggml_compute_forward_exp_f32(
8464
- const struct ggml_compute_params * params,
8465
- const struct ggml_tensor * src0,
8466
- struct ggml_tensor * dst) {
8467
- GGML_ASSERT(ggml_is_contiguous_except_dim_1(src0));
8468
- GGML_ASSERT(ggml_is_contiguous_except_dim_1(dst));
8469
- GGML_ASSERT(ggml_are_same_shape(src0, dst));
8470
-
8471
- if (params->type == GGML_TASK_INIT || params->type == GGML_TASK_FINALIZE) {
8472
- return;
8473
- }
8474
-
8475
- const int ith = params->ith;
8476
- const int nth = params->nth;
8477
-
8478
- const int nc = src0->ne[0];
8479
- const int nr = ggml_nrows(src0);
8480
-
8481
- // rows per thread
8482
- const int dr = (nr + nth - 1)/nth;
8483
-
8484
- // row range for this thread
8485
- const int ir0 = dr*ith;
8486
- const int ir1 = MIN(ir0 + dr, nr);
8487
-
8488
- for (int i1 = ir0; i1 < ir1; i1++) {
8489
- ggml_vec_exp_f32(nc,
8490
- (float *) ((char *) dst->data + i1*( dst->nb[1])),
8491
- (float *) ((char *) src0->data + i1*(src0->nb[1])));
8492
- };
8493
- }
8494
-
8495
- static void ggml_compute_forward_exp(
8496
- const struct ggml_compute_params * params,
8497
- const struct ggml_tensor * src0,
8498
- struct ggml_tensor * dst) {
8499
- switch (src0->type) {
8500
- case GGML_TYPE_F32:
8501
- {
8502
- ggml_compute_forward_exp_f32(params, src0, dst);
8503
- } break;
8504
- case GGML_TYPE_F16: // TODO: use ggml_table_exp_f16
8505
- default:
8506
- {
8507
- GGML_ASSERT(false);
8508
- } break;
8509
- }
8510
- }
8511
-
8512
8389
// ggml_compute_forward_log
8513
8390
8514
8391
static void ggml_compute_forward_log_f32(
@@ -11771,48 +11648,6 @@ static void ggml_compute_forward_soft_max_back(
11771
11648
}
11772
11649
}
11773
11650
11774
- static void ggml_compute_forward_soft_plus_f32(
11775
- const struct ggml_compute_params * params,
11776
- const struct ggml_tensor * src0,
11777
- struct ggml_tensor * dst) {
11778
- GGML_ASSERT(params->ith == 0);
11779
- GGML_ASSERT(ggml_are_same_shape(src0, dst));
11780
-
11781
- if (params->type == GGML_TASK_INIT || params->type == GGML_TASK_FINALIZE) {
11782
- return;
11783
- }
11784
-
11785
- const int nc = src0->ne[0];
11786
- const int nr = ggml_nrows(src0);
11787
-
11788
- GGML_ASSERT( dst->nb[0] == sizeof(float));
11789
- GGML_ASSERT(src0->nb[0] == sizeof(float));
11790
-
11791
- for (int i = 0; i < nr; ++i) {
11792
- float * x = (float *) ((char *) dst->data + i*( dst->nb[1]));
11793
- float * y = (float *) ((char *) src0->data + i*(src0->nb[1]));
11794
- for (int j = 0; j < nc; ++j) {
11795
- x[j] = logf(1.0f + expf(y[j]));
11796
- }
11797
- }
11798
- }
11799
-
11800
- static void ggml_compute_forward_soft_plus(
11801
- const struct ggml_compute_params * params,
11802
- const struct ggml_tensor * src0,
11803
- struct ggml_tensor * dst) {
11804
- switch (src0->type) {
11805
- case GGML_TYPE_F32:
11806
- {
11807
- ggml_compute_forward_soft_plus_f32(params, src0, dst);
11808
- } break;
11809
- default:
11810
- {
11811
- GGML_ASSERT(false);
11812
- } break;
11813
- }
11814
- }
11815
-
11816
11651
// ggml_compute_forward_alibi
11817
11652
11818
11653
static void ggml_compute_forward_alibi_f32(
@@ -15220,10 +15055,6 @@ static void ggml_compute_forward(struct ggml_compute_params * params, struct ggm
15220
15055
{
15221
15056
ggml_compute_forward_sqrt(params, tensor->src[0], tensor);
15222
15057
} break;
15223
- case GGML_OP_EXP:
15224
- {
15225
- ggml_compute_forward_exp(params, tensor->src[0], tensor);
15226
- } break;
15227
15058
case GGML_OP_LOG:
15228
15059
{
15229
15060
ggml_compute_forward_log(params, tensor->src[0], tensor);
@@ -15348,10 +15179,6 @@ static void ggml_compute_forward(struct ggml_compute_params * params, struct ggm
15348
15179
{
15349
15180
ggml_compute_forward_soft_max_back(params, tensor->src[0], tensor->src[1], tensor);
15350
15181
} break;
15351
- case GGML_OP_SOFT_PLUS:
15352
- {
15353
- ggml_compute_forward_soft_plus(params, tensor->src[0], tensor);
15354
- } break;
15355
15182
case GGML_OP_ROPE:
15356
15183
{
15357
15184
ggml_compute_forward_rope(params, tensor->src[0], tensor->src[1], tensor);
@@ -15908,10 +15735,6 @@ static void ggml_compute_backward(struct ggml_context * ctx, struct ggml_tensor
15908
15735
zero_table);
15909
15736
}
15910
15737
} break;
15911
- case GGML_OP_EXP:
15912
- {
15913
- GGML_ASSERT(false); // TODO: implement
15914
- } break;
15915
15738
case GGML_OP_LOG:
15916
15739
{
15917
15740
if (src0->grad) {
@@ -16290,10 +16113,6 @@ static void ggml_compute_backward(struct ggml_context * ctx, struct ggml_tensor
16290
16113
{
16291
16114
GGML_ASSERT(false); // TODO: not implemented
16292
16115
} break;
16293
- case GGML_OP_SOFT_PLUS:
16294
- {
16295
- GGML_ASSERT(false); // TODO: not implemented
16296
- } break;
16297
16116
case GGML_OP_ROPE:
16298
16117
{
16299
16118
// necessary for llama
@@ -17015,7 +16834,6 @@ static int ggml_get_n_tasks(struct ggml_tensor * node, int n_threads) {
17015
16834
case GGML_OP_ADD:
17016
16835
case GGML_OP_ADD1:
17017
16836
case GGML_OP_ACC:
17018
- case GGML_OP_EXP:
17019
16837
{
17020
16838
n_tasks = n_threads;
17021
16839
} break;
@@ -17122,10 +16940,6 @@ static int ggml_get_n_tasks(struct ggml_tensor * node, int n_threads) {
17122
16940
{
17123
16941
n_tasks = MIN(n_threads, ggml_nrows(node->src[0]));
17124
16942
} break;
17125
- case GGML_OP_SOFT_PLUS:
17126
- {
17127
- n_tasks = 1; //TODO
17128
- } break;
17129
16943
case GGML_OP_CONV_TRANSPOSE_1D:
17130
16944
{
17131
16945
n_tasks = n_threads;
@@ -17499,7 +17313,6 @@ struct ggml_cplan ggml_graph_plan(const struct ggml_cgraph * cgraph, int n_threa
17499
17313
}
17500
17314
} break;
17501
17315
case GGML_OP_SOFT_MAX:
17502
- case GGML_OP_SOFT_PLUS:
17503
17316
case GGML_OP_ROPE:
17504
17317
{
17505
17318
cur = ggml_type_size(GGML_TYPE_F32) * node->ne[0] * n_tasks;
0 commit comments