Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
remove ne_repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhenzhong1 committed Mar 1, 2024
1 parent 6ebad2f commit 30d9d9d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions neural_speed/models/chatglm/chatglm2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ static bool chatglm_model_eval_internal(model_context* ctx, const model_input* i

// self-attention
cur = ne_rms_norm(ctx0, inpL, hparams.rms_norm_eps);
cur = ne_mul(ctx0, ne_repeat(ctx0, model.layers[il].norm[0], cur), cur);
cur = ne_mul(ctx0, cur, model.layers[il].norm[0]);
{
// compute QKV
cur = ne_mul_mat(ctx0, model.layers[il].attn[0], cur);
cur = ne_add(ctx0, ne_repeat(ctx0, model.layers[il].attn[1], cur), cur);
cur = ne_add(ctx0, cur, model.layers[il].attn[1]);

struct ne_tensor* query_layer =
ne_view_3d(ctx0, cur, head_size, n_head, N, head_size * ne_element_size(cur), cur->nb[1],
Expand Down Expand Up @@ -298,7 +298,7 @@ static bool chatglm_model_eval_internal(model_context* ctx, const model_input* i

// mlp.forward
struct ne_tensor* mlp_output = ne_rms_norm(ctx0, hidden_states, hparams.rms_norm_eps);
mlp_output = ne_mul(ctx0, ne_repeat(ctx0, model.layers[il].norm[1], mlp_output), mlp_output);
mlp_output = ne_mul(ctx0, mlp_output, model.layers[il].norm[1]);

if (model.layers[il].ffn_fusion &&
bestla_fusion_FFN_SiLu_f32f32_support(model.layers[il].ffn[2]->data, model.layers[il].ffn[1]->data,
Expand Down Expand Up @@ -333,9 +333,7 @@ static bool chatglm_model_eval_internal(model_context* ctx, const model_input* i
// norm
{
inpL = ne_rms_norm(ctx0, inpL, hparams.rms_norm_eps);
ne_set_name(inpL, "inpL");
// inpL = ne_mul(ctx0, inpL, model.others[1]);
inpL = ne_mul(ctx0, ne_repeat(ctx0, model.others[1], inpL), inpL);
inpL = ne_mul(ctx0, inpL, model.others[1]);
}

lctx.use_buf(ctx0, -1);
Expand Down

0 comments on commit 30d9d9d

Please sign in to comment.