| 182 | } // namespace |
| 183 | |
| 184 | StableAudioSession::StableAudioSession( |
| 185 | runtime::TaskSpec task, |
| 186 | runtime::SessionOptions options, |
| 187 | std::shared_ptr<const StableAudioAssets> assets) |
| 188 | : runtime::RuntimeSessionBase(options), |
| 189 | task_(task), |
| 190 | assets_(require_assets(std::move(assets))) { |
| 191 | max_batch_ = runtime::parse_int_option(options.options, {"stable_audio.max_batch"}).value_or(max_batch_); |
| 192 | if (max_batch_ <= 0) { |
| 193 | throw std::runtime_error("stable_audio.max_batch must be positive"); |
| 194 | } |
| 195 | if (const auto it = this->options().options.find("stable_audio.weight_type"); it != this->options().options.end()) { |
| 196 | weight_storage_type_ = engine::assets::parse_tensor_storage_type(it->second); |
| 197 | validate_weight_storage(weight_storage_type_, "stable_audio.weight_type"); |
| 198 | } |
| 199 | if (const auto mem_saver = runtime::find_option(this->options().options, {"stable_audio.mem_saver"})) { |
| 200 | mem_saver_ = runtime::parse_bool_option(*mem_saver, "stable_audio.mem_saver"); |
| 201 | } |
| 202 | for (const auto & [key, value] : this->options().options) { |
| 203 | if (key == "stable_audio.max_batch" || key == "stable_audio.weight_type" || key == "stable_audio.mem_saver") { |
| 204 | (void) value; |
| 205 | continue; |
| 206 | } |
| 207 | if (key.rfind("stable_audio.", 0) == 0) { |
| 208 | throw std::runtime_error("unknown Stable Audio session option: " + key); |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | StableAudioSession::~StableAudioSession() = default; |
| 214 |
nothing calls this directly
no test coverage detected