| 225 | } |
| 226 | |
| 227 | void 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 | |
| 270 | runtime::TaskResult StableAudioSession::run(const runtime::TaskRequest & request) { |
| 271 | require_prepared("Stable Audio run"); |
nothing calls this directly
no test coverage detected