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

Function load_sortformer_diar_weights

src/models/sortformer_diar/assets.cpp:251–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249 assets::TensorStorageType conv_storage_type,
250 size_t weight_context_bytes) {
251 if (assets.model_weights == nullptr) {
252 throw std::runtime_error("Sortformer tensor source must not be null");
253 }
254 const auto & tensor_source = *assets.model_weights;
255 const auto & config = assets.model_config;
256 auto weights = std::make_shared<SortformerDiarWeights>();
257 weights->store = std::make_shared<core::BackendWeightStore>(
258 backend,
259 backend_type,
260 "sortformer diar weights",
261 weight_context_bytes);
262
263 const auto & fc = config.fc_encoder;
264 weights->subsampling.conv0 = modules::binding::conv2d_from_source(
265 *weights->store,
266 tensor_source,
267 "fc_encoder.subsampling.layers.0",
268 conv_storage_type,
269 fc.subsampling_conv_channels,
270 1,
271 fc.subsampling_conv_kernel_size,
272 fc.subsampling_conv_kernel_size,
273 true);
274 weights->subsampling.depthwise1_weight = weights->store->load_tensor(
275 tensor_source,
276 "fc_encoder.subsampling.layers.2.weight",
277 conv_storage_type,
278 {fc.subsampling_conv_channels, 1, fc.subsampling_conv_kernel_size, fc.subsampling_conv_kernel_size});
279 weights->subsampling.depthwise1_bias = weights->store->load_f32_tensor(
280 tensor_source,
281 "fc_encoder.subsampling.layers.2.bias", {fc.subsampling_conv_channels});
282 weights->subsampling.pointwise1 = modules::binding::conv2d_from_source(
283 *weights->store,
284 tensor_source,
285 "fc_encoder.subsampling.layers.3",
286 conv_storage_type,
287 fc.subsampling_conv_channels,
288 fc.subsampling_conv_channels,
289 1,
290 1,
291 true);
292 weights->subsampling.depthwise2_weight = weights->store->load_tensor(
293 tensor_source,
294 "fc_encoder.subsampling.layers.5.weight",
295 conv_storage_type,
296 {fc.subsampling_conv_channels, 1, fc.subsampling_conv_kernel_size, fc.subsampling_conv_kernel_size});
297 weights->subsampling.depthwise2_bias = weights->store->load_f32_tensor(
298 tensor_source,
299 "fc_encoder.subsampling.layers.5.bias", {fc.subsampling_conv_channels});
300 weights->subsampling.pointwise2 = modules::binding::conv2d_from_source(
301 *weights->store,
302 tensor_source,
303 "fc_encoder.subsampling.layers.6",
304 conv_storage_type,
305 fc.subsampling_conv_channels,
306 fc.subsampling_conv_channels,
307 1,
308 1,

Callers 1

SortformerDiarSessionMethod · 0.85

Calls 8

conv2d_from_sourceFunction · 0.85
linear_from_sourceFunction · 0.85
load_conformer_layerFunction · 0.85
load_transformer_layerFunction · 0.85
load_tensorMethod · 0.80
load_f32_tensorMethod · 0.80
uploadMethod · 0.80
resizeMethod · 0.45

Tested by

no test coverage detected