| 152 | const core::TensorValue & normalized, |
| 153 | const NormConfig & config, |
| 154 | const NormWeights & weights) { |
| 155 | core::TensorValue result = normalized; |
| 156 | if (config.use_weight) { |
| 157 | if (!weights.weight.has_value()) { |
| 158 | throw std::runtime_error("weight is required when NormConfig.use_weight is true"); |
| 159 | } |
| 160 | core::validate_shape(*weights.weight, core::TensorShape::from_dims({config.hidden_size}), "weight"); |
| 161 | const auto weight = ensure_f32(ctx, *weights.weight); |
| 162 | result = core::wrap_tensor(ggml_mul(ctx.ggml, result.tensor, weight.tensor), result.shape, GGML_TYPE_F32); |
| 163 | } |
| 164 | if (config.use_bias) { |
| 165 | if (!weights.bias.has_value()) { |
| 166 | throw std::runtime_error("bias is required when NormConfig.use_bias is true"); |
no test coverage detected