@@ -1500,7 +1500,6 @@ inline static void ggml_vec_scale_f32(const int n, float * y, const float v) {
1500
1500
inline static void ggml_vec_norm_f32 (const int n, float * s, const float * x) { ggml_vec_dot_f32(n, s, 0, x, 0, x, 0, 1); *s = sqrtf(*s); }
1501
1501
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]; }
1502
1502
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]); }
1503
- 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]); }
1504
1503
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]); }
1505
1504
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]); }
1506
1505
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); }
@@ -1696,7 +1695,6 @@ static const char * GGML_OP_NAME[GGML_OP_COUNT] = {
1696
1695
"DIV",
1697
1696
"SQR",
1698
1697
"SQRT",
1699
- "EXP",
1700
1698
"LOG",
1701
1699
"SUM",
1702
1700
"SUM_ROWS",
@@ -1730,7 +1728,6 @@ static const char * GGML_OP_NAME[GGML_OP_COUNT] = {
1730
1728
"DIAG_MASK_ZERO",
1731
1729
"SOFT_MAX",
1732
1730
"SOFT_MAX_BACK",
1733
- "SOFT_PLUS",
1734
1731
"ROPE",
1735
1732
"ROPE_BACK",
1736
1733
"ALIBI",
@@ -1771,7 +1768,7 @@ static const char * GGML_OP_NAME[GGML_OP_COUNT] = {
1771
1768
"CROSS_ENTROPY_LOSS_BACK",
1772
1769
};
1773
1770
1774
- static_assert(GGML_OP_COUNT == 75 , "GGML_OP_COUNT != 75 ");
1771
+ static_assert(GGML_OP_COUNT == 73 , "GGML_OP_COUNT != 73 ");
1775
1772
1776
1773
static const char * GGML_OP_SYMBOL[GGML_OP_COUNT] = {
1777
1774
"none",
@@ -1785,7 +1782,6 @@ static const char * GGML_OP_SYMBOL[GGML_OP_COUNT] = {
1785
1782
"x/y",
1786
1783
"x^2",
1787
1784
"√x",
1788
- "e^x", // or should this be "exp(x)"?
1789
1785
"log(x)",
1790
1786
"Σx",
1791
1787
"Σx_k",
@@ -1819,7 +1815,6 @@ static const char * GGML_OP_SYMBOL[GGML_OP_COUNT] = {
1819
1815
"diag_mask_zero(x)",
1820
1816
"soft_max(x)",
1821
1817
"soft_max_back(x)",
1822
- "soft_plus(x)",
1823
1818
"rope(x)",
1824
1819
"rope_back(x)",
1825
1820
"alibi(x)",
@@ -1860,7 +1855,7 @@ static const char * GGML_OP_SYMBOL[GGML_OP_COUNT] = {
1860
1855
"cross_entropy_loss_back(x,y)",
1861
1856
};
1862
1857
1863
- static_assert(GGML_OP_COUNT == 75 , "GGML_OP_COUNT != 75 ");
1858
+ static_assert(GGML_OP_COUNT == 73 , "GGML_OP_COUNT != 73 ");
1864
1859
1865
1860
static_assert(GGML_OP_POOL_COUNT == 2, "GGML_OP_POOL_COUNT != 2");
1866
1861
@@ -3673,39 +3668,6 @@ struct ggml_tensor * ggml_sqrt_inplace(
3673
3668
return ggml_sqrt_impl(ctx, a, true);
3674
3669
}
3675
3670
3676
- // ggml_exp
3677
-
3678
- static struct ggml_tensor * ggml_exp_impl(
3679
- struct ggml_context * ctx,
3680
- struct ggml_tensor * a,
3681
- bool inplace) {
3682
- bool is_node = false;
3683
-
3684
- if (!inplace && (a->grad)) {
3685
- is_node = true;
3686
- }
3687
-
3688
- struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a);
3689
-
3690
- result->op = GGML_OP_EXP;
3691
- result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
3692
- result->src[0] = a;
3693
-
3694
- return result;
3695
- }
3696
-
3697
- struct ggml_tensor * ggml_exp(
3698
- struct ggml_context * ctx,
3699
- struct ggml_tensor * a) {
3700
- return ggml_exp_impl(ctx, a, false);
3701
- }
3702
-
3703
- struct ggml_tensor * ggml_exp_inplace(
3704
- struct ggml_context * ctx,
3705
- struct ggml_tensor * a) {
3706
- return ggml_exp_impl(ctx, a, true);
3707
- }
3708
-
3709
3671
// ggml_log
3710
3672
3711
3673
static struct ggml_tensor * ggml_log_impl(
@@ -5186,40 +5148,6 @@ struct ggml_tensor * ggml_soft_max_back_inplace(
5186
5148
return ggml_soft_max_back_impl(ctx, a, b, true);
5187
5149
}
5188
5150
5189
- // ggml_soft_plus
5190
-
5191
- static struct ggml_tensor * ggml_soft_plus_impl(
5192
- struct ggml_context * ctx,
5193
- struct ggml_tensor * a,
5194
- bool inplace) {
5195
-
5196
- bool is_node = false;
5197
-
5198
- if (a->grad) {
5199
- is_node = true; // TODO : implement backward pass
5200
- }
5201
-
5202
- struct ggml_tensor * result = inplace ? ggml_view_tensor(ctx, a) : ggml_dup_tensor(ctx, a);
5203
-
5204
- result->op = GGML_OP_SOFT_PLUS;
5205
- result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
5206
- result->src[0] = a;
5207
-
5208
- return result;
5209
- }
5210
-
5211
- struct ggml_tensor * ggml_soft_plus(
5212
- struct ggml_context * ctx,
5213
- struct ggml_tensor * a) {
5214
- return ggml_soft_plus_impl(ctx, a, false);
5215
- }
5216
-
5217
- struct ggml_tensor * ggml_soft_plus_inplace(
5218
- struct ggml_context * ctx,
5219
- struct ggml_tensor * a) {
5220
- return ggml_soft_plus_impl(ctx, a, true);
5221
- }
5222
-
5223
5151
// ggml_rope
5224
5152
5225
5153
static struct ggml_tensor * ggml_rope_impl(
@@ -8501,57 +8429,6 @@ static void ggml_compute_forward_sqrt(
8501
8429
}
8502
8430
}
8503
8431
8504
- // ggml_compute_forward_exp
8505
-
8506
- static void ggml_compute_forward_exp_f32(
8507
- const struct ggml_compute_params * params,
8508
- const struct ggml_tensor * src0,
8509
- struct ggml_tensor * dst) {
8510
- GGML_ASSERT(ggml_is_contiguous_except_dim_1(src0));
8511
- GGML_ASSERT(ggml_is_contiguous_except_dim_1(dst));
8512
- GGML_ASSERT(ggml_are_same_shape(src0, dst));
8513
-
8514
- if (params->type == GGML_TASK_INIT || params->type == GGML_TASK_FINALIZE) {
8515
- return;
8516
- }
8517
-
8518
- const int ith = params->ith;
8519
- const int nth = params->nth;
8520
-
8521
- const int nc = src0->ne[0];
8522
- const int nr = ggml_nrows(src0);
8523
-
8524
- // rows per thread
8525
- const int dr = (nr + nth - 1)/nth;
8526
-
8527
- // row range for this thread
8528
- const int ir0 = dr*ith;
8529
- const int ir1 = MIN(ir0 + dr, nr);
8530
-
8531
- for (int i1 = ir0; i1 < ir1; i1++) {
8532
- ggml_vec_exp_f32(nc,
8533
- (float *) ((char *) dst->data + i1*( dst->nb[1])),
8534
- (float *) ((char *) src0->data + i1*(src0->nb[1])));
8535
- };
8536
- }
8537
-
8538
- static void ggml_compute_forward_exp(
8539
- const struct ggml_compute_params * params,
8540
- const struct ggml_tensor * src0,
8541
- struct ggml_tensor * dst) {
8542
- switch (src0->type) {
8543
- case GGML_TYPE_F32:
8544
- {
8545
- ggml_compute_forward_exp_f32(params, src0, dst);
8546
- } break;
8547
- case GGML_TYPE_F16: // TODO: use ggml_table_exp_f16
8548
- default:
8549
- {
8550
- GGML_ASSERT(false);
8551
- } break;
8552
- }
8553
- }
8554
-
8555
8432
// ggml_compute_forward_log
8556
8433
8557
8434
static void ggml_compute_forward_log_f32(
@@ -11828,48 +11705,6 @@ static void ggml_compute_forward_soft_max_back(
11828
11705
}
11829
11706
}
11830
11707
11831
- static void ggml_compute_forward_soft_plus_f32(
11832
- const struct ggml_compute_params * params,
11833
- const struct ggml_tensor * src0,
11834
- struct ggml_tensor * dst) {
11835
- GGML_ASSERT(params->ith == 0);
11836
- GGML_ASSERT(ggml_are_same_shape(src0, dst));
11837
-
11838
- if (params->type == GGML_TASK_INIT || params->type == GGML_TASK_FINALIZE) {
11839
- return;
11840
- }
11841
-
11842
- const int nc = src0->ne[0];
11843
- const int nr = ggml_nrows(src0);
11844
-
11845
- GGML_ASSERT( dst->nb[0] == sizeof(float));
11846
- GGML_ASSERT(src0->nb[0] == sizeof(float));
11847
-
11848
- for (int i = 0; i < nr; ++i) {
11849
- float * x = (float *) ((char *) dst->data + i*( dst->nb[1]));
11850
- float * y = (float *) ((char *) src0->data + i*(src0->nb[1]));
11851
- for (int j = 0; j < nc; ++j) {
11852
- x[j] = logf(1.0f + expf(y[j]));
11853
- }
11854
- }
11855
- }
11856
-
11857
- static void ggml_compute_forward_soft_plus(
11858
- const struct ggml_compute_params * params,
11859
- const struct ggml_tensor * src0,
11860
- struct ggml_tensor * dst) {
11861
- switch (src0->type) {
11862
- case GGML_TYPE_F32:
11863
- {
11864
- ggml_compute_forward_soft_plus_f32(params, src0, dst);
11865
- } break;
11866
- default:
11867
- {
11868
- GGML_ASSERT(false);
11869
- } break;
11870
- }
11871
- }
11872
-
11873
11708
// ggml_compute_forward_alibi
11874
11709
11875
11710
static void ggml_compute_forward_alibi_f32(
@@ -15279,10 +15114,6 @@ static void ggml_compute_forward(struct ggml_compute_params * params, struct ggm
15279
15114
{
15280
15115
ggml_compute_forward_sqrt(params, tensor->src[0], tensor);
15281
15116
} break;
15282
- case GGML_OP_EXP:
15283
- {
15284
- ggml_compute_forward_exp(params, tensor->src[0], tensor);
15285
- } break;
15286
15117
case GGML_OP_LOG:
15287
15118
{
15288
15119
ggml_compute_forward_log(params, tensor->src[0], tensor);
@@ -15407,10 +15238,6 @@ static void ggml_compute_forward(struct ggml_compute_params * params, struct ggm
15407
15238
{
15408
15239
ggml_compute_forward_soft_max_back(params, tensor->src[0], tensor->src[1], tensor);
15409
15240
} break;
15410
- case GGML_OP_SOFT_PLUS:
15411
- {
15412
- ggml_compute_forward_soft_plus(params, tensor->src[0], tensor);
15413
- } break;
15414
15241
case GGML_OP_ROPE:
15415
15242
{
15416
15243
ggml_compute_forward_rope(params, tensor->src[0], tensor->src[1], tensor);
@@ -15967,10 +15794,6 @@ static void ggml_compute_backward(struct ggml_context * ctx, struct ggml_tensor
15967
15794
zero_table);
15968
15795
}
15969
15796
} break;
15970
- case GGML_OP_EXP:
15971
- {
15972
- GGML_ASSERT(false); // TODO: implement
15973
- } break;
15974
15797
case GGML_OP_LOG:
15975
15798
{
15976
15799
if (src0->grad) {
@@ -16349,10 +16172,6 @@ static void ggml_compute_backward(struct ggml_context * ctx, struct ggml_tensor
16349
16172
{
16350
16173
GGML_ASSERT(false); // TODO: not implemented
16351
16174
} break;
16352
- case GGML_OP_SOFT_PLUS:
16353
- {
16354
- GGML_ASSERT(false); // TODO: not implemented
16355
- } break;
16356
16175
case GGML_OP_ROPE:
16357
16176
{
16358
16177
// necessary for llama
@@ -17074,7 +16893,6 @@ static int ggml_get_n_tasks(struct ggml_tensor * node, int n_threads) {
17074
16893
case GGML_OP_ADD:
17075
16894
case GGML_OP_ADD1:
17076
16895
case GGML_OP_ACC:
17077
- case GGML_OP_EXP:
17078
16896
{
17079
16897
n_tasks = n_threads;
17080
16898
} break;
@@ -17181,10 +16999,6 @@ static int ggml_get_n_tasks(struct ggml_tensor * node, int n_threads) {
17181
16999
{
17182
17000
n_tasks = MIN(n_threads, ggml_nrows(node->src[0]));
17183
17001
} break;
17184
- case GGML_OP_SOFT_PLUS:
17185
- {
17186
- n_tasks = 1; //TODO
17187
- } break;
17188
17002
case GGML_OP_CONV_TRANSPOSE_1D:
17189
17003
{
17190
17004
n_tasks = n_threads;
@@ -17558,7 +17372,6 @@ struct ggml_cplan ggml_graph_plan(const struct ggml_cgraph * cgraph, int n_threa
17558
17372
}
17559
17373
} break;
17560
17374
case GGML_OP_SOFT_MAX:
17561
- case GGML_OP_SOFT_PLUS:
17562
17375
case GGML_OP_ROPE:
17563
17376
{
17564
17377
cur = ggml_type_size(GGML_TYPE_F32) * node->ne[0] * n_tasks;
0 commit comments