| 445 | } |
| 446 | |
| 447 | size_t ParakeetModel::build_convolution_module(CactusGraph* gb, size_t hidden, uint32_t layer_idx, ComputeBackend backend) { |
| 448 | (void)backend; |
| 449 | const auto& layer = weight_nodes_.layers[layer_idx]; |
| 450 | const auto& hidden_shape = gb->get_output_buffer(hidden).shape; |
| 451 | if (hidden_shape.size() != 2) { |
| 452 | throw std::runtime_error("Parakeet convolution module expects [T, D]"); |
| 453 | } |
| 454 | |
| 455 | const size_t T = hidden_shape[0]; |
| 456 | const size_t D = hidden_shape[1]; |
| 457 | |
| 458 | size_t x = gb->reshape(hidden, {1, T, D}); |
| 459 | x = gb->conv1d_pointwise(x, layer.conv_pointwise1_weight, layer.conv_pointwise1_bias); |
| 460 | x = gb->glu(x, -1); |
| 461 | |
| 462 | x = gb->conv1d_same_depthwise_k9(x, layer.conv_depthwise_weight, layer.conv_depthwise_bias); |
| 463 | |
| 464 | x = gb->batchnorm( |
| 465 | x, |
| 466 | layer.conv_batchnorm_weight, |
| 467 | layer.conv_batchnorm_bias, |
| 468 | layer.conv_batchnorm_running_mean, |
| 469 | layer.conv_batchnorm_running_var, |
| 470 | 2, |
| 471 | 1e-5f |
| 472 | ); |
| 473 | |
| 474 | std::string act = config_.encoder_hidden_act; |
| 475 | std::transform(act.begin(), act.end(), act.begin(), ::tolower); |
| 476 | if (act.find("gelu") != std::string::npos) { |
| 477 | x = gb->gelu(x); |
| 478 | } else if (act == "relu") { |
| 479 | x = gb->relu(x); |
| 480 | } else { |
| 481 | x = gb->silu(x); |
| 482 | } |
| 483 | |
| 484 | x = gb->conv1d_pointwise(x, layer.conv_pointwise2_weight, layer.conv_pointwise2_bias); |
| 485 | |
| 486 | x = gb->reshape(x, {T, D}); |
| 487 | return x; |
| 488 | } |
| 489 | |
| 490 | size_t ParakeetModel::build_encoder_block(CactusGraph* gb, size_t hidden, size_t position_embeddings, |
| 491 | uint32_t layer_idx, ComputeBackend backend) { |
nothing calls this directly
no test coverage detected