Skip to content

Commit 58851b5

Browse files
authored
Update ggml_extend.hpp
1 parent b864f15 commit 58851b5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ggml_extend.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,12 +1311,12 @@ class Linear : public UnaryBlock {
13111311

13121312
auto ne = x->ne[0];
13131313
auto im = ggml_mul_mat(ctx, x, w);
1314-
1315-
auto empty = ggml_new_tensor_1d(ctx, GGML_TYPE_F32, ne);
1316-
auto eyev = ggml_set_f32(empty, 1.0f);
1317-
auto eye = ggml_diag(ctx, eyev);
1318-
auto imm = ggml_mul_mat(ctx, im, eye);
1319-
auto ims = ggml_sum_rows(ctx, imm);
1314+
1315+
auto a = ggml_diag_mask_zero(ctx, im, 0);
1316+
auto b = ggml_transpose(ctx, a);
1317+
auto c = ggml_diag_mask_zero(ctx, b, 0);
1318+
auto d = ggml_transpose(ctx, c);
1319+
auto ims = ggml_sum_rows(ctx, d);
13201320
auto imv = ggml_reshape_1d(ctx, ims, ne);
13211321

13221322
//

0 commit comments

Comments
 (0)