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

Method prepare

src/models/stable_audio/session.cpp:227–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227void StableAudioSession::prepare(const runtime::SessionPreparationRequest & request) {
228 if (!conditioner_inputs_) {
229 conditioner_inputs_ = std::make_unique<StableAudioConditionerInputs>(assets_);
230 }
231 if (!conditioner_runtime_) {
232 conditioner_runtime_ = std::make_unique<StableAudioConditionerRuntime>(
233 execution_context(),
234 assets_,
235 weight_storage_type_,
236 max_batch_);
237 }
238 if (!rf_dit_) {
239 rf_dit_ = std::make_unique<StableAudioRfDitRuntime>(
240 execution_context(),
241 assets_,
242 weight_storage_type_);
243 }
244 if (!same_) {
245 same_ = std::make_unique<StableAudioSameRuntime>(
246 execution_context(),
247 assets_,
248 weight_storage_type_);
249 }
250 conditioner_runtime_->prepare();
251 if (request.text.has_value() || !request.options.empty()) {
252 runtime::TaskRequest task_request;
253 task_request.text_input = request.text;
254 task_request.options = request.options;
255 const StableAudioRequest parsed = clamp_request_to_model_limit(
256 parse_stable_audio_request(task_request),
257 assets_->config);
258 const auto rng_policy = engine::sampling::resolve_torch_cuda_sampling_policy(
259 execution_context().backend_type(),
260 execution_context().config().device,
261 "stable_audio.rng",
262 "Stable Audio");
263 const StableAudioSamplingState sampling = prepare_stable_audio_sampling_state(assets_->config, parsed, rng_policy);
264 rf_dit_->prepare(sampling, parsed.guidance_scale);
265 same_->prepare_decode(sampling.batch, sampling.latent_sample_size, parsed.chunked_decode);
266 }
267 mark_prepared();
268}
269
270runtime::TaskResult StableAudioSession::run(const runtime::TaskRequest & request) {
271 require_prepared("Stable Audio run");

Callers

nothing calls this directly

Calls 7

emptyMethod · 0.45
backend_typeMethod · 0.45
prepare_decodeMethod · 0.45

Tested by

no test coverage detected