| 158 | const LinearModule up_proj({config.hidden_size, config.intermediate_size, false, GGML_PREC_F32}); |
| 159 | const LinearModule down_proj({config.intermediate_size, config.hidden_size, false, GGML_PREC_F32}); |
| 160 | auto gate = gate_proj.build(ctx, input, weights.gate_proj); |
| 161 | gate = GeluModule({GeluApproximation::Tanh}).build(ctx, gate); |
| 162 | auto up = up_proj.build(ctx, input, weights.up_proj); |
| 163 | return down_proj.build(ctx, MulModule{}.build(ctx, gate, up), weights.down_proj); |
| 164 | } |
| 165 | |
| 166 | core::TensorValue layer( |
| 167 | core::ModuleBuildContext & ctx, |
| 168 | const core::TensorValue & input, |
| 169 | const core::TensorValue & positions, |
| 170 | const core::TensorValue & additive_attention_mask, |
| 171 | const T5GemmaEncoderLayerWeights & weights, |
| 172 | const T5GemmaEncoderConfig & config) { |
| 173 | auto hidden = gemma_rms_norm(ctx, input, weights.pre_self_attn_norm, config.rms_norm_eps, config.hidden_size); |
| 174 | hidden = self_attention(ctx, hidden, positions, additive_attention_mask, weights, config); |
| 175 | hidden = gemma_rms_norm(ctx, hidden, weights.post_self_attn_norm, config.rms_norm_eps, config.hidden_size); |
| 176 | auto output = AddModule{}.build(ctx, input, hidden); |
| 177 | hidden = gemma_rms_norm(ctx, output, weights.pre_ff_norm, config.rms_norm_eps, config.hidden_size); |
| 178 | hidden = mlp(ctx, hidden, weights, config); |
no test coverage detected