| 177 | } |
| 178 | |
| 179 | core::TensorValue swiglu( |
| 180 | core::ModuleBuildContext & ctx, |
| 181 | const core::TensorValue & input, |
| 182 | const MioCodecTransformerLayerWeights & weights, |
| 183 | int64_t dim, |
| 184 | int64_t intermediate_dim) { |
| 185 | auto gate = engine::modules::LinearModule({dim, intermediate_dim, weights.feed_forward_w1.bias.has_value()}).build( |
| 186 | ctx, |
| 187 | input, |
| 188 | weights.feed_forward_w1); |
| 189 | gate = core::wrap_tensor(ggml_silu(ctx.ggml, gate.tensor), gate.shape, GGML_TYPE_F32); |
| 190 | auto up = engine::modules::LinearModule({dim, intermediate_dim, weights.feed_forward_w3.bias.has_value()}).build( |
| 191 | ctx, |
| 192 | input, |
| 193 | weights.feed_forward_w3); |
| 194 | auto hidden = engine::modules::MulModule{}.build(ctx, gate, up); |
| 195 | return engine::modules::LinearModule({intermediate_dim, dim, weights.feed_forward_w2.bias.has_value()}).build( |
| 196 | ctx, |
| 197 | hidden, |
| 198 | weights.feed_forward_w2); |
| 199 | } |
| 200 | |
| 201 | core::TensorValue apply_rope_fast( |
| 202 | core::ModuleBuildContext & ctx, |
no test coverage detected