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

Method ensure_graph

src/models/seed_vc/astral_quantizer.cpp:363–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361 void ensure_graph(int64_t batch, int64_t tokens) {
362 if (ggml_ != nullptr && batch_ == batch && tokens_ == tokens) {
363 return;
364 }
365 release_graph();
366 ggml_init_params params{
367 1024ull * 1024ull * 512ull,
368 nullptr,
369 true,
370 };
371 ggml_ = ggml_init(params);
372 if (ggml_ == nullptr) {
373 throw std::runtime_error("failed to initialize Seed-VC ASTRAL graph context");
374 }
375 engine::core::ModuleBuildContext ctx{
376 ggml_,
377 "seed_vc.astral",
378 execution_context_.backend_type()};
379 input_ = engine::core::make_tensor(
380 ctx,
381 GGML_TYPE_F32,
382 engine::core::TensorShape::from_dims({batch, tokens, input_channels_}));
383 output_ = build_astral_projected(
384 ctx,
385 input_,
386 graph_weights_,
387 input_channels_,
388 channels_,
389 intermediate_channels_);
390 graph_ = ggml_new_graph_custom(ggml_, 65536, false);
391 ggml_build_forward_expand(graph_, output_.tensor);
392 gallocr_ = ggml_gallocr_new(ggml_backend_get_default_buffer_type(execution_context_.backend()));
393 if (gallocr_ == nullptr ||
394 !ggml_gallocr_reserve(gallocr_, graph_) ||
395 !ggml_gallocr_alloc_graph(gallocr_, graph_)) {
396 release_graph();
397 throw std::runtime_error("failed to allocate Seed-VC ASTRAL graph tensors");
398 }
399 batch_ = batch;
400 tokens_ = tokens;
401 }
402
403 engine::core::ExecutionContext & execution_context_;
404 AstralWeights graph_weights_;
405 int64_t input_channels_ = 0;
406 int64_t channels_ = 0;

Callers

nothing calls this directly

Calls 11

ggml_initFunction · 0.85
make_tensorFunction · 0.85
build_astral_projectedFunction · 0.85
ggml_new_graph_customFunction · 0.85
ggml_gallocr_newFunction · 0.85
ggml_gallocr_reserveFunction · 0.85
ggml_gallocr_alloc_graphFunction · 0.85
backend_typeMethod · 0.45
backendMethod · 0.45

Tested by

no test coverage detected