MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / encoder_layer

Function encoder_layer

src/framework/modules/text_encoders/t5_base_encoder.cpp:157–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155 {input.shape.dims[0], input.shape.dims[1], config.hidden_size}));
156 return o_proj.build(ctx, context, weights.o_proj);
157}
158
159core::TensorValue feed_forward(
160 core::ModuleBuildContext & ctx,
161 const core::TensorValue & input,
162 const T5BaseEncoderLayerWeights & weights,
163 const T5BaseEncoderConfig & config) {
164 auto hidden = LinearModule({config.hidden_size, config.intermediate_size, false, GGML_PREC_F32})
165 .build(ctx, input, weights.wi_proj);
166 if (config.feed_forward_kind == T5BaseFeedForwardKind::Relu) {
167 hidden = ReluModule{}.build(ctx, hidden);
168 } else if (config.feed_forward_kind == T5BaseFeedForwardKind::GatedGeluTanh) {
169 if (!weights.gate_proj.weight.valid()) {
170 throw std::runtime_error("T5BaseEncoder gated GELU feed-forward requires gate_proj.weight");
171 }
172 auto gate = LinearModule({config.hidden_size, config.intermediate_size, false, GGML_PREC_F32})
173 .build(ctx, input, weights.gate_proj);

Callers 1

buildMethod · 0.70

Calls 4

t5_layer_normFunction · 0.85
feed_forwardFunction · 0.85
self_attentionFunction · 0.70
buildMethod · 0.45

Tested by

no test coverage detected