| 415 | } |
| 416 | |
| 417 | MioCodecSnakeBetaWeights bind_snake_beta( |
| 418 | MioCodecWeights & weights, |
| 419 | const engine::assets::TensorSource & source, |
| 420 | const std::string & prefix, |
| 421 | int64_t channels) { |
| 422 | std::vector<float> alpha(static_cast<size_t>(channels), 0.0F); |
| 423 | std::vector<float> inv_beta(static_cast<size_t>(channels), 0.0F); |
| 424 | const auto alpha_source = source.require_f32(prefix + ".alpha", {channels}); |
| 425 | const auto beta_source = source.require_f32(prefix + ".beta", {channels}); |
| 426 | for (int64_t i = 0; i < channels; ++i) { |
| 427 | alpha[static_cast<size_t>(i)] = std::exp(alpha_source[static_cast<size_t>(i)]); |
| 428 | inv_beta[static_cast<size_t>(i)] = 1.0F / (std::exp(beta_source[static_cast<size_t>(i)]) + 1.0e-9F); |
| 429 | } |
| 430 | return { |
| 431 | weights.store->make_f32(engine::core::TensorShape::from_dims({channels}), std::move(alpha)), |
| 432 | weights.store->make_f32(engine::core::TensorShape::from_dims({channels}), std::move(inv_beta)), |
| 433 | }; |
| 434 | } |
| 435 | |
| 436 | MioCodecResNetBlockWeights bind_resnet_block( |
| 437 | const MioCodecWeights & weights, |
no test coverage detected