| 195 | } |
| 196 | |
| 197 | ActivationWeights load_activation( |
| 198 | core::BackendWeightStore & store, |
| 199 | const assets::TensorSource & source, |
| 200 | const std::string & prefix, |
| 201 | int64_t channels, |
| 202 | assets::TensorStorageType storage_type) { |
| 203 | (void) storage_type; |
| 204 | const auto alpha_raw = source.require_f32(prefix + ".act.alpha", {channels}); |
| 205 | const auto beta_raw = source.require_f32(prefix + ".act.beta", {channels}); |
| 206 | std::vector<float> alpha(static_cast<size_t>(channels), 0.0F); |
| 207 | std::vector<float> inv_beta(static_cast<size_t>(channels), 0.0F); |
| 208 | for (int64_t index = 0; index < channels; ++index) { |
| 209 | alpha[static_cast<size_t>(index)] = std::exp(alpha_raw[static_cast<size_t>(index)]); |
| 210 | inv_beta[static_cast<size_t>(index)] = |
| 211 | 1.0F / (std::exp(beta_raw[static_cast<size_t>(index)]) + 1.0e-9F); |
| 212 | } |
| 213 | ActivationWeights out; |
| 214 | out.alpha = store.make_from_f32(core::TensorShape::from_dims({channels}), assets::TensorStorageType::F32, std::move(alpha)); |
| 215 | out.inv_beta = store.make_from_f32(core::TensorShape::from_dims({channels}), assets::TensorStorageType::F32, std::move(inv_beta)); |
| 216 | const auto up_filter = reversed_filter( |
| 217 | source.require_f32(prefix + ".upsample.filter", {1, 1, kBigVganActivationKernel})); |
| 218 | const auto down_filter = |
| 219 | source.require_f32(prefix + ".downsample.lowpass.filter", {1, 1, kBigVganActivationKernel}); |
| 220 | out.up_filter = store.make_from_f32( |
| 221 | core::TensorShape::from_dims({channels, 1, 1, kBigVganActivationKernel}), |
| 222 | assets::TensorStorageType::F32, |
| 223 | expand_activation_filter_2d(up_filter, channels)); |
| 224 | out.down_filter = store.make_from_f32( |
| 225 | core::TensorShape::from_dims({channels, 1, 1, kBigVganActivationKernel}), |
| 226 | assets::TensorStorageType::F32, |
| 227 | expand_activation_filter_2d(down_filter, channels)); |
| 228 | return out; |
| 229 | } |
| 230 | |
| 231 | ResBlockWeights load_resblock( |
| 232 | core::BackendWeightStore & store, |
no test coverage detected