| 492 | } |
| 493 | |
| 494 | MioCodecGlobalEncoderWeights bind_global_encoder(const MioCodecWeights & weights) { |
| 495 | MioCodecGlobalEncoderWeights global; |
| 496 | global.embedding = bind_conv1d(weights, "global_encoder.backbone.embed", 384, 768, 7, 1, 3); |
| 497 | global.embedding_norm = bind_norm(weights, "global_encoder.backbone.norm", 384); |
| 498 | global.blocks.reserve(4); |
| 499 | for (int64_t layer = 0; layer < 4; ++layer) { |
| 500 | const std::string prefix = "global_encoder.backbone.convnext." + std::to_string(layer); |
| 501 | MioCodecConvNeXtBlockWeights block; |
| 502 | block.depthwise_conv_config = {384, 7, 1, 3, 1, true}; |
| 503 | block.depthwise_conv = { |
| 504 | require_loaded_tensor(weights, prefix + ".dwconv.weight", {384, 1, 7}), |
| 505 | require_loaded_tensor(weights, prefix + ".dwconv.bias", {384}), |
| 506 | }; |
| 507 | block.norm = bind_norm(weights, prefix + ".norm", 384); |
| 508 | block.pointwise_conv1 = bind_linear(weights, prefix + ".pwconv1", 384, 1152); |
| 509 | block.pointwise_conv2 = bind_linear(weights, prefix + ".pwconv2", 1152, 384); |
| 510 | block.gamma = require_loaded_tensor(weights, prefix + ".gamma", {384}); |
| 511 | global.blocks.push_back(std::move(block)); |
| 512 | } |
| 513 | global.final_norm = bind_norm(weights, "global_encoder.backbone.final_layer_norm", 384); |
| 514 | global.attention_conv1 = bind_conv1d(weights, "global_encoder.pooling.attn.0", 128, 384, 1); |
| 515 | global.attention_conv2 = bind_conv1d(weights, "global_encoder.pooling.attn.2", 384, 128, 1); |
| 516 | global.pooling_projection = bind_linear(weights, "global_encoder.pooling.proj", 768, 128); |
| 517 | global.pooling_norm = bind_norm(weights, "global_encoder.pooling.norm", 128); |
| 518 | return global; |
| 519 | } |
| 520 | |
| 521 | void bind_component_weights( |
| 522 | MioCodecWeights & weights, |
no test coverage detected