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

Function decoder_layer

src/models/ace_step/text_encoder.cpp:169–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167TextEncoderWeights load_text_encoder_weights(
168 ggml_backend_t backend,
169 core::BackendType backend_type,
170 const AceStepAssets & assets,
171 assets::TensorStorageType storage_type) {
172 const auto & config = assets.config.text_encoder;
173 const auto & source = *assets.text_encoder_weights;
174 const int64_t dim = config.head_dim;
175
176 TextEncoderWeights weights;
177 weights.store = std::make_shared<core::BackendWeightStore>(
178 backend,
179 backend_type,
180 "ace_step.text_encoder.weights",
181 64ull * 1024ull * 1024ull);
182
183 weights.embed_tokens = weights.store->load_tensor(
184 source,
185 "embed_tokens.weight",
186 storage_type,
187 {config.vocab_size, config.hidden_size});
188
189 weights.layers.reserve(static_cast<size_t>(config.num_hidden_layers));
190 for (int64_t i = 0; i < config.num_hidden_layers; ++i) {
191 const std::string prefix = "layers." + std::to_string(i);
192 TextEncoderLayerWeights layer;
193 layer.input_norm = weights.store->load_f32_tensor(source, prefix + ".input_layernorm.weight", {config.hidden_size});
194 layer.post_norm =
195 weights.store->load_f32_tensor(source, prefix + ".post_attention_layernorm.weight", {config.hidden_size});
196 layer.q_norm = weights.store->load_f32_tensor(source, prefix + ".self_attn.q_norm.weight", {dim});
197 layer.k_norm = weights.store->load_f32_tensor(source, prefix + ".self_attn.k_norm.weight", {dim});
198 layer.q_proj = weights.store->load_tensor(
199 source,
200 prefix + ".self_attn.q_proj.weight",
201 storage_type,
202 {config.num_attention_heads * dim, config.hidden_size});
203 layer.k_proj = weights.store->load_tensor(
204 source,
205 prefix + ".self_attn.k_proj.weight",
206 storage_type,
207 {config.num_key_value_heads * dim, config.hidden_size});
208 layer.v_proj = weights.store->load_tensor(
209 source,
210 prefix + ".self_attn.v_proj.weight",
211 storage_type,
212 {config.num_key_value_heads * dim, config.hidden_size});
213 layer.o_proj = weights.store->load_tensor(
214 source,
215 prefix + ".self_attn.o_proj.weight",
216 storage_type,
217 {config.hidden_size, config.num_attention_heads * dim});
218 layer.gate_proj =
219 weights.store->load_tensor(source, prefix + ".mlp.gate_proj.weight", storage_type, {config.intermediate_size, config.hidden_size});
220 layer.up_proj =
221 weights.store->load_tensor(source, prefix + ".mlp.up_proj.weight", storage_type, {config.intermediate_size, config.hidden_size});
222 layer.down_proj =
223 weights.store->load_tensor(source, prefix + ".mlp.down_proj.weight", storage_type, {config.hidden_size, config.intermediate_size});
224 weights.layers.push_back(std::move(layer));
225 }
226

Callers 1

buildMethod · 0.70

Calls 12

norm_dataFunction · 0.85
linear_dataFunction · 0.85
RoPEModuleClass · 0.85
TransposeModuleClass · 0.85
reshape_tensorFunction · 0.85
LinearModuleClass · 0.85
head_dimFunction · 0.70
reshape_headsFunction · 0.70
repeat_kv_headsFunction · 0.70
attention_from_headsFunction · 0.70
ensure_contiguousFunction · 0.70
buildMethod · 0.45

Tested by

no test coverage detected