MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / load_activation

Function load_activation

src/framework/modules/bigvgan_vocoder.cpp:197–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197ActivationWeights 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
231ResBlockWeights load_resblock(
232 core::BackendWeightStore & store,

Callers 2

load_resblockFunction · 0.70
load_from_safetensorsMethod · 0.70

Calls 4

reversed_filterFunction · 0.85
make_from_f32Method · 0.80
require_f32Method · 0.45

Tested by

no test coverage detected