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

Function build_norm

src/framework/modules/norm_modules.cpp:128–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126 result = core::wrap_tensor(ggml_mul(ctx.ggml, result.tensor, weight.tensor), result.shape, GGML_TYPE_F32);
127 }
128 if (config.use_bias) {
129 if (!weights.bias.has_value()) {
130 throw std::runtime_error("bias is required when NormConfig.use_bias is true");
131 }
132 core::validate_shape(*weights.bias, core::TensorShape::from_dims({config.hidden_size}), "bias");
133 const auto bias = ensure_f32(ctx, *weights.bias);
134 result = core::wrap_tensor(ggml_add(ctx.ggml, result.tensor, bias.tensor), result.shape, GGML_TYPE_F32);
135 }
136 return result;
137}
138
139void validate_norm_config(const NormConfig & config) {
140 if (config.hidden_size <= 0) {
141 throw std::runtime_error("NormConfig.hidden_size must be positive");
142 }
143 if (!(config.eps > 0.0f)) {
144 throw std::runtime_error("NormConfig.eps must be positive");
145 }

Callers 1

buildMethod · 0.85

Calls 5

validate_rank_betweenFunction · 0.85
validate_last_dimFunction · 0.85
wrap_tensorFunction · 0.85
apply_affineFunction · 0.85

Tested by

no test coverage detected