Skip to content

Commit 03aff83

Browse files
authored
Update ggml_extend.hpp
1 parent b53442e commit 03aff83

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

ggml_extend.hpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,12 +1300,25 @@ class Linear : public UnaryBlock {
13001300
if (bias) {
13011301
b = params["bias"];
13021302
}
1303-
auto act = ggml_nn_linear(ctx, x, w, NULL);
1303+
1304+
struct ggml_tensor* act = NULL;
1305+
struct ggml_tensor* out = NULL;
1306+
1307+
act = ggml_mul_mat(ctx, w, x);
1308+
if (b != NULL) {
1309+
out = ggml_add(ctx, act, b);
1310+
}
1311+
1312+
auto im = ggml_mul_mat(ctx, x, w);
1313+
auto imv = ggml_diag(im);
1314+
13041315
//
13051316
print_ggml_tensor(x, true, "imatrix x");
13061317
print_ggml_tensor(w, true, "imatrix w");
13071318
print_ggml_tensor(act, true, "imatrix act");
1308-
return ggml_nn_linear(ctx, x, w, b);
1319+
print_ggml_tensor(im, true, "imatrix im");
1320+
print_ggml_tensor(imv, true, "imatrix imv");
1321+
return out == NULL ? act : out;
13091322
}
13101323
};
13111324

0 commit comments

Comments
 (0)