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

Function load_weight_norm_conv_transpose1d

src/models/ace_step/vae_decoder.cpp:272–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270 int dilation,
271 assets::TensorStorageType storage_type,
272 bool use_bias) {
273 const auto g = source.require_f32(prefix + ".weight_g", {in_channels, 1, 1});
274 const auto v = source.require_f32(prefix + ".weight_v", {in_channels, out_channels, kernel});
275 const auto graph_storage_type =
276 compatible_conv_transpose_storage_type(source, prefix + ".weight_v", storage_type);
277 WeightNormConvTranspose1dWeights out = {};
278 out.stride = stride;
279 out.padding = padding;
280 out.dilation = dilation;
281 auto fused_weight = apply_weight_norm(g, v, in_channels, out_channels * kernel);
282 auto col_weight = conv_transpose_col_weight(fused_weight, in_channels, out_channels, kernel);
283 out.conv.weight = store.make_from_f32(
284 core::TensorShape::from_dims({in_channels, out_channels, kernel}),
285 graph_storage_type,
286 std::move(fused_weight));
287 out.col_weight = store.make_from_f32(
288 core::TensorShape::from_dims({out_channels * kernel, in_channels}),
289 graph_storage_type,
290 std::move(col_weight));
291 if (use_bias) {
292 out.conv.bias = store.load_f32_tensor(source, prefix + ".bias", {out_channels});
293 }
294 return out;
295}
296
297ResidualUnitWeights load_residual_unit(
298 core::BackendWeightStore & store,
299 const assets::TensorSource & source,
300 const std::string & prefix,
301 int64_t channels,
302 assets::TensorStorageType storage_type) {
303 ResidualUnitWeights out = {};
304 out.snake1 = load_snake_exact(store, source, prefix + ".snake1", channels);
305 out.conv1 = load_weight_norm_conv1d(store, source, prefix + ".conv1", channels, channels, 7, 1, 3, 1, storage_type, true);
306 out.snake2 = load_snake_exact(store, source, prefix + ".snake2", channels);
307 out.conv2 = load_weight_norm_conv1d(store, source, prefix + ".conv2", channels, channels, 1, 1, 0, 1, storage_type, true);
308 return out;
309}

Callers 1

load_vae_decoder_weightsFunction · 0.70

Calls 6

make_from_f32Method · 0.80
load_f32_tensorMethod · 0.80
apply_weight_normFunction · 0.70
require_f32Method · 0.45

Tested by

no test coverage detected