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

Function load_miocodec_weights

src/models/miocodec/weights.cpp:543–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

541} // namespace
542
543std::shared_ptr<const MioCodecWeights> load_miocodec_weights(
544 const engine::assets::TensorSource & source,
545 engine::core::ExecutionContext & execution_context,
546 size_t weight_context_bytes,
547 const MioCodecConfig & config,
548 engine::assets::TensorStorageType storage_type) {
549 auto weights = std::make_shared<MioCodecWeights>();
550 weights->source_path = source.source_path();
551 weights->store = std::make_shared<engine::core::BackendWeightStore>(
552 execution_context.backend(),
553 execution_context.backend_type(),
554 "miocodec.weights",
555 weight_context_bytes);
556
557 const auto tensors = source.tensors();
558 weights->tensors.reserve(tensors.size());
559 for (const auto & tensor : tensors) {
560 weights->parameter_count += num_elements(tensor.shape);
561 if (is_transformer_qkv_weight_name(tensor.name)) {
562 continue;
563 }
564 weights->tensors.emplace(
565 tensor.name,
566 weights->store->load_tensor(
567 source,
568 tensor.name,
569 storage_type_for_miocodec_tensor(tensor.name, storage_type),
570 tensor.shape));
571 ++weights->loaded_tensor_count;
572 }
573 bind_component_weights(*weights, source, storage_type);
574 weights->content_token_embeddings = build_content_token_embedding_table(source, config);
575 weights->store->upload();
576 source.release_storage();
577 return weights;
578}
579
580} // namespace engine::models::miocodec

Callers 2

MioCodecSessionMethod · 0.85
MioTTSSessionMethod · 0.85

Calls 13

open_tensor_sourceFunction · 0.85
num_elementsFunction · 0.85
bind_component_weightsFunction · 0.85
load_tensorMethod · 0.80
uploadMethod · 0.80
backendMethod · 0.45
backend_typeMethod · 0.45
tensorsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected