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

Function load_adaln

src/models/heartmula/codec.cpp:217–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215 core::BackendWeightStore & store,
216 const assets::TensorSource & source,
217 const std::string & prefix,
218 assets::TensorStorageType storage_type,
219 int64_t hidden_size,
220 int64_t mlp_hidden_size) {
221 HeartCodecTransformerBlockWeights weights;
222 weights.attn_norm = binding::norm_weight_from_source(store, source, prefix + ".attn_norm", hidden_size);
223 weights.q_proj = binding::linear_from_source(store, source, prefix + ".attn.q_proj", storage_type, hidden_size, hidden_size, false);
224 weights.k_proj = binding::linear_from_source(store, source, prefix + ".attn.k_proj", storage_type, hidden_size, hidden_size, false);
225 weights.v_proj = binding::linear_from_source(store, source, prefix + ".attn.v_proj", storage_type, hidden_size, hidden_size, false);
226 weights.o_proj = binding::linear_from_source(store, source, prefix + ".attn.o_proj", storage_type, hidden_size, hidden_size, false);
227 weights.mlp_norm = binding::norm_weight_from_source(store, source, prefix + ".mlp_norm", hidden_size);
228 weights.mlp_gate = binding::linear_from_source(store, source, prefix + ".mlp.gate", storage_type, mlp_hidden_size, hidden_size, false);
229 weights.mlp_up = binding::linear_from_source(store, source, prefix + ".mlp.up", storage_type, mlp_hidden_size, hidden_size, false);
230 weights.mlp_down = binding::linear_from_source(store, source, prefix + ".mlp.down", storage_type, hidden_size, mlp_hidden_size, false);
231 weights.scale_shift_table = store.load_f32_tensor(source, prefix + ".scale_shift_table", {6, hidden_size});
232 return weights;
233}
234
235std::vector<HeartCodecTransformerBlockWeights> load_transformer_blocks(
236 core::BackendWeightStore & store,
237 const assets::TensorSource & source,
238 const std::string & prefix,
239 assets::TensorStorageType storage_type,
240 int64_t layers,
241 int64_t hidden_size) {
242 std::vector<HeartCodecTransformerBlockWeights> blocks;
243 blocks.reserve(static_cast<size_t>(layers));
244 const int64_t mlp_hidden_size = llama_mlp_hidden_dim(hidden_size);
245 for (int64_t layer = 0; layer < layers; ++layer) {
246 blocks.push_back(load_transformer_block(
247 store,
248 source,
249 prefix + "." + std::to_string(layer),
250 storage_type,
251 hidden_size,
252 mlp_hidden_size));

Callers 1

load_flow_weightsFunction · 0.85

Calls 1

load_linearFunction · 0.70

Tested by

no test coverage detected