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

Function load_weight_norm_conv1d

src/models/stable_audio/same_autoencoder.cpp:116–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114 for (int64_t i = 0; i < inner; ++i) {
115 out[base + static_cast<size_t>(i)] = weight_v[base + static_cast<size_t>(i)] * scale;
116 }
117 }
118 return out;
119}
120
121modules::Conv1dWeights load_weight_norm_conv1d(
122 core::BackendWeightStore & store,
123 const assets::TensorSource & source,
124 const std::string & prefix,
125 assets::TensorStorageType storage_type,
126 int64_t out_channels,
127 int64_t in_channels,
128 int64_t kernel,
129 bool use_bias) {
130 auto conv_storage_type = assets::resolve_tensor_storage_type(source, prefix + ".weight_v", storage_type);
131 const ggml_type conv_ggml_type = assets::ggml_type_for_tensor_storage(conv_storage_type);
132 if (ggml_is_quantized(conv_ggml_type) && kernel % ggml_blck_size(conv_ggml_type) != 0) {
133 conv_storage_type = assets::TensorStorageType::F32;
134 }
135 const auto weight_v = source.require_f32(prefix + ".weight_v", {out_channels, in_channels, kernel});
136 const auto weight_g = squeeze_weight_g(source.require_f32(prefix + ".weight_g", {out_channels, 1, 1}), out_channels, prefix);
137 modules::Conv1dWeights weights;
138 weights.weight = store.make_from_f32(
139 core::TensorShape::from_dims({out_channels, in_channels, kernel}),
140 conv_storage_type,
141 fold_weight_norm_dim0(weight_v, weight_g, out_channels, in_channels, kernel, prefix));
142 if (use_bias) {
143 weights.bias = store.load_f32_tensor(source, prefix + ".bias", {out_channels});
144 }

Callers 2

load_decoder_blockFunction · 0.70
load_encoder_blockFunction · 0.70

Calls 9

ggml_is_quantizedFunction · 0.85
ggml_blck_sizeFunction · 0.85
fold_weight_norm_dim0Function · 0.85
make_from_f32Method · 0.80
load_f32_tensorMethod · 0.80
squeeze_weight_gFunction · 0.70
require_f32Method · 0.45

Tested by

no test coverage detected