| 541 | } // namespace |
| 542 | |
| 543 | std::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 |
no test coverage detected