Skip to content

Commit 1623a6e

Browse files
committed
ggml : minor
1 parent c14e0d2 commit 1623a6e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ggml.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7509,20 +7509,23 @@ static void ggml_compute_forward_rope_f32(
75097509
// row index used to determine which thread to use
75107510
int ir = 0;
75117511

7512-
const float theta_scale = powf(10000.0, ((float)-2)/n_dims);
7512+
const float theta_scale = powf(10000.0, -2.0f/n_dims);
75137513

75147514
for (int64_t i3 = 0; i3 < ne3; i3++) {
75157515
for (int64_t i2 = (mode == 0 ? 0 : n_past); i2 < ne2; i2++) {
75167516
const int p = (mode == 0 ? n_past + i2 : i2);
75177517
for (int64_t i1 = 0; i1 < ne1; i1++) {
75187518
if (ir++ < ir0) continue;
75197519
if (ir > ir1) break;
7520+
75207521
float theta = (float)p;
7522+
75217523
for (int i0 = 0; i0 < n_dims; i0 += 2) {
75227524
const float cos_theta = cosf(theta);
75237525
const float sin_theta = sinf(theta);
75247526

75257527
theta *= theta_scale;
7528+
75267529
const float * const src = (float *)((char *) src0->data + i3*nb3 + i2*nb2 + i1*nb1 + i0*nb0);
75277530
float * dst_data = (float *)((char *) dst->data + i3*nb3 + i2*nb2 + i1*nb1 + i0*nb0);
75287531

@@ -7583,20 +7586,23 @@ static void ggml_compute_forward_rope_f16(
75837586
// row index used to determine which thread to use
75847587
int ir = 0;
75857588

7586-
const float theta_scale = powf(10000.0, ((float)-2)/n_dims);
7589+
const float theta_scale = powf(10000.0, -2.0f/n_dims);
75877590

75887591
for (int64_t i3 = 0; i3 < ne3; i3++) {
75897592
for (int64_t i2 = (mode == 0 ? 0 : n_past); i2 < ne2; i2++) {
75907593
const int p = (mode == 0 ? n_past + i2 : i2);
75917594
for (int64_t i1 = 0; i1 < ne1; i1++) {
75927595
if (ir++ < ir0) continue;
75937596
if (ir > ir1) break;
7597+
75947598
float theta = (float)p;
7599+
75957600
for (int i0 = 0; i0 < n_dims; i0 += 2) {
75967601
const float cos_theta = cosf(theta);
75977602
const float sin_theta = sinf(theta);
75987603

75997604
theta *= theta_scale;
7605+
76007606
const ggml_fp16_t * const src = (ggml_fp16_t *)((char *) src0->data + i3*nb3 + i2*nb2 + i1*nb1 + i0*nb0);
76017607
ggml_fp16_t * dst_data = (ggml_fp16_t *)((char *) dst->data + i3*nb3 + i2*nb2 + i1*nb1 + i0*nb0);
76027608

0 commit comments

Comments
 (0)