| 142 | result = core::wrap_tensor(ggml_mul(ctx.ggml, result.tensor, weight.tensor), result.shape, GGML_TYPE_F32); |
| 143 | } |
| 144 | if (config.use_bias) { |
| 145 | if (!weights.bias.has_value()) { |
| 146 | throw std::runtime_error("bias is required when NormConfig.use_bias is true"); |
| 147 | } |
| 148 | core::validate_shape(*weights.bias, core::TensorShape::from_dims({config.hidden_size}), "bias"); |
| 149 | const auto bias = ensure_f32(ctx, *weights.bias); |
| 150 | result = core::wrap_tensor(ggml_add(ctx.ggml, result.tensor, bias.tensor), result.shape, GGML_TYPE_F32); |
| 151 | } |
| 152 | return result; |
| 153 | } |
| 154 | |
| 155 | void validate_norm_config(const NormConfig & config) { |
no outgoing calls
no test coverage detected