| 60 | w.layer.self_attention.key_norm = {"model.model.transformer.layers.{layer}.self_attn.k_norm.gamma", ""}; |
| 61 | w.layer.cross_attention.query = {"model.model.transformer.layers.{layer}.cross_attn.to_q.weight", ""}; |
| 62 | w.layer.cross_attention.kv = {"model.model.transformer.layers.{layer}.cross_attn.to_kv.weight", ""}; |
| 63 | w.layer.cross_attention.output = {"model.model.transformer.layers.{layer}.cross_attn.to_out.weight", ""}; |
| 64 | w.layer.cross_attention.query_norm = {"model.model.transformer.layers.{layer}.cross_attn.q_norm.gamma", ""}; |
| 65 | w.layer.cross_attention.key_norm = {"model.model.transformer.layers.{layer}.cross_attn.k_norm.gamma", ""}; |
| 66 | w.layer.local_embedding = {{"model.model.transformer.layers.{layer}.to_local_embed.0.weight", "model.model.transformer.layers.{layer}.to_local_embed.0.bias"}, |
| 67 | {"model.model.transformer.layers.{layer}.to_local_embed.2.weight", "model.model.transformer.layers.{layer}.to_local_embed.2.bias"}}; |
| 68 | w.layer.feed_forward_in = {"model.model.transformer.layers.{layer}.ff.ff.0.proj.weight", "model.model.transformer.layers.{layer}.ff.ff.0.proj.bias"}; |
| 69 | w.layer.feed_forward_out = {"model.model.transformer.layers.{layer}.ff.ff.2.weight", "model.model.transformer.layers.{layer}.ff.ff.2.bias"}; |
| 70 | return w; |
| 71 | } |
| 72 | } // namespace |
| 73 | |
| 74 | StableAudioRFDiTRuntime::StableAudioRFDiTRuntime(core::ExecutionContext & execution, |
| 75 | std::shared_ptr<const StableAudioAssets> assets, assets::TensorStorageType storage) |
| 76 | : execution_(&execution), assets_(std::move(assets)), weight_storage_type_(storage) {} |
| 77 | StableAudioRFDiTRuntime::~StableAudioRFDiTRuntime() = default; |
| 78 | |
| 79 | void StableAudioRFDiTRuntime::prepare(const StableAudioSamplingState &, float) const { |
| 80 | if (!runtime_) runtime_ = std::make_unique<modules::DitRuntime>(*execution_, *assets_->model_weights, |
| 81 | runtime_config(assets_->config, weight_storage_type_, execution_->backend_type()), weight_names()); |
| 82 | } |
| 83 | |
| 84 | std::vector<float> StableAudioRFDiTRuntime::sample(const StableAudioSamplingState & sampling, |
no test coverage detected