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

Function load_layer_weights

src/models/vibevoice/decoder.cpp:183–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183VibeVoiceDecoderLayerWeights load_layer_weights(
184 core::BackendWeightStore & store,
185 const assets::TensorSource & source,
186 const VibeVoiceDecoderConfig & config,
187 int64_t layer,
188 assets::TensorStorageType weight_storage_type) {
189 const int64_t dim = require_head_dim(config);
190 const std::string prefix = "model.language_model.layers." + std::to_string(layer);
191 VibeVoiceDecoderLayerWeights weights;
192 weights.input_norm = source.require_f32_tensor(prefix + ".input_layernorm.weight", {config.hidden_size});
193 weights.self_attention.q_weight = store.load_tensor(
194 source,
195 prefix + ".self_attn.q_proj.weight",
196 weight_storage_type,
197 {config.num_attention_heads * dim, config.hidden_size});
198 weights.self_attention.q_bias = store.load_tensor(
199 source,
200 prefix + ".self_attn.q_proj.bias",
201 assets::TensorStorageType::F32,
202 {config.num_attention_heads * dim});
203 weights.self_attention.k_weight = store.load_tensor(
204 source,
205 prefix + ".self_attn.k_proj.weight",
206 weight_storage_type,
207 {config.num_key_value_heads * dim, config.hidden_size});
208 weights.self_attention.k_bias = store.load_tensor(
209 source,
210 prefix + ".self_attn.k_proj.bias",
211 assets::TensorStorageType::F32,
212 {config.num_key_value_heads * dim});
213 weights.self_attention.v_weight = store.load_tensor(
214 source,
215 prefix + ".self_attn.v_proj.weight",
216 weight_storage_type,
217 {config.num_key_value_heads * dim, config.hidden_size});
218 weights.self_attention.v_bias = store.load_tensor(
219 source,
220 prefix + ".self_attn.v_proj.bias",
221 assets::TensorStorageType::F32,
222 {config.num_key_value_heads * dim});
223 weights.self_attention.out_weight = store.load_tensor(
224 source,
225 prefix + ".self_attn.o_proj.weight",
226 weight_storage_type,
227 {config.hidden_size, config.num_attention_heads * dim});
228 weights.post_norm = source.require_f32_tensor(prefix + ".post_attention_layernorm.weight", {config.hidden_size});
229 weights.mlp.gate_proj.weight = store.load_tensor(
230 source,
231 prefix + ".mlp.gate_proj.weight",
232 weight_storage_type,
233 {config.intermediate_size, config.hidden_size});
234 weights.mlp.up_proj.weight = store.load_tensor(
235 source,
236 prefix + ".mlp.up_proj.weight",
237 weight_storage_type,
238 {config.intermediate_size, config.hidden_size});
239 weights.mlp.down_proj.weight = store.load_tensor(
240 source,

Callers 1

Calls 4

require_f32_tensorMethod · 0.80
load_tensorMethod · 0.80
require_head_dimFunction · 0.70
to_stringFunction · 0.50

Tested by

no test coverage detected