From dc431105b33f27659a334d2d1cccfbea6c9ba051 Mon Sep 17 00:00:00 2001 From: leejet Date: Tue, 4 Aug 2026 22:12:27 +0800 Subject: [PATCH] format code --- src/model/diffusion/minimax_h3.hpp | 28 +++---- src/model/vae/minimax_h3_audio_vae.hpp | 16 ++-- src/model/vae/minimax_h3_vae.hpp | 100 ++++++++++++------------- 3 files changed, 72 insertions(+), 72 deletions(-) diff --git a/src/model/diffusion/minimax_h3.hpp b/src/model/diffusion/minimax_h3.hpp index 798daced..d0683166 100644 --- a/src/model/diffusion/minimax_h3.hpp +++ b/src/model/diffusion/minimax_h3.hpp @@ -397,7 +397,7 @@ namespace MiniMaxH3 { config.attention_head_dim, config.qk_norm_eps); blocks["mlp"] = std::make_shared(config.hidden_size, - config.ffn_hidden_size); + config.ffn_hidden_size); blocks["adaln_proj"] = std::make_shared(config.time_embed_dim, config.hidden_size, 6, @@ -561,7 +561,7 @@ namespace MiniMaxH3 { 1); ggml_tensor* angles = nullptr; for (int axis = 0; axis < 3; ++axis) { - auto pos = ggml_ext_slice(ctx->ggml_ctx, position_ids, 0, axis, axis + 1); + auto pos = ggml_ext_slice(ctx->ggml_ctx, position_ids, 0, axis, axis + 1); auto expanded_inv = ggml_repeat_4d(ctx->ggml_ctx, inv, inv->ne[0], @@ -569,7 +569,7 @@ namespace MiniMaxH3 { 1, 1); auto a = ggml_mul(ctx->ggml_ctx, expanded_inv, pos); - angles = angles == nullptr ? a : ggml_concat(ctx->ggml_ctx, angles, a, 0); + angles = angles == nullptr ? a : ggml_concat(ctx->ggml_ctx, angles, a, 0); } auto c = ggml_reshape_4d(ctx->ggml_ctx, ggml_cos(ctx->ggml_ctx, angles), 1, angles->ne[0], angles->ne[1], 1); auto s = ggml_reshape_4d(ctx->ggml_ctx, ggml_sin(ctx->ggml_ctx, angles), 1, angles->ne[0], angles->ne[1], 1); @@ -756,17 +756,17 @@ namespace MiniMaxH3 { } static PackedSequenceLayout build_layout(int64_t text_len, - int64_t latent_t, - int64_t latent_h, - int64_t latent_w, - int64_t audio_t, - const std::vector>& condition_videos, - const std::vector>& condition_audios, - const sd::Tensor& keyframe_indices, - const std::vector& reference_blocks, - const sd::Tensor& text_tags, - float video_t, - float audio_timestep) { + int64_t latent_t, + int64_t latent_h, + int64_t latent_w, + int64_t audio_t, + const std::vector>& condition_videos, + const std::vector>& condition_audios, + const sd::Tensor& keyframe_indices, + const std::vector& reference_blocks, + const sd::Tensor& text_tags, + float video_t, + float audio_timestep) { PackedSequenceLayout layout; float sqrt_area = std::sqrt(static_cast(latent_h * latent_w)); auto h_axis = spatial_axis(latent_h, sqrt_area); diff --git a/src/model/vae/minimax_h3_audio_vae.hpp b/src/model/vae/minimax_h3_audio_vae.hpp index 8a69c117..5af751e3 100644 --- a/src/model/vae/minimax_h3_audio_vae.hpp +++ b/src/model/vae/minimax_h3_audio_vae.hpp @@ -397,14 +397,14 @@ namespace MiniMaxH3 { ggml_mul(ctx->ggml_ctx, latent, std), mean); - auto dec_in = std::dynamic_pointer_cast(blocks["dec_in_proj"]); - auto decoder = std::dynamic_pointer_cast(blocks["decoder"]); - int64_t streams = latent->ne[2] * latent->ne[3]; - latent = ggml_reshape_3d(ctx->ggml_ctx, - latent, - latent->ne[0], - latent->ne[1], - streams); + auto dec_in = std::dynamic_pointer_cast(blocks["dec_in_proj"]); + auto decoder = std::dynamic_pointer_cast(blocks["decoder"]); + int64_t streams = latent->ne[2] * latent->ne[3]; + latent = ggml_reshape_3d(ctx->ggml_ctx, + latent, + latent->ne[0], + latent->ne[1], + streams); ggml_tensor* waveform = nullptr; for (int64_t stream = 0; stream < streams; ++stream) { auto stream_latent = ggml_ext_slice(ctx->ggml_ctx, latent, 2, stream, stream + 1); diff --git a/src/model/vae/minimax_h3_vae.hpp b/src/model/vae/minimax_h3_vae.hpp index af25f0b8..163a9447 100644 --- a/src/model/vae/minimax_h3_vae.hpp +++ b/src/model/vae/minimax_h3_vae.hpp @@ -86,14 +86,14 @@ namespace MiniMaxH3VAE { frame->ne[1], num_channels, batch_size); - frame = GroupNorm::forward(ctx, frame); - frame = ggml_reshape_4d(ctx->ggml_ctx, - frame, - frame->ne[0], - frame->ne[1], - 1, - num_channels * batch_size); - result = result == nullptr ? frame : ggml_concat(ctx->ggml_ctx, result, frame, 2); + frame = GroupNorm::forward(ctx, frame); + frame = ggml_reshape_4d(ctx->ggml_ctx, + frame, + frame->ne[0], + frame->ne[1], + 1, + num_channels * batch_size); + result = result == nullptr ? frame : ggml_concat(ctx->ggml_ctx, result, frame, 2); } return result; } @@ -257,49 +257,49 @@ namespace MiniMaxH3VAE { ggml_tensor* forward(GGMLRunnerContext* ctx, ggml_tensor* x, ggml_tensor* pe) { - auto to_qkv = std::dynamic_pointer_cast(blocks["to_qkv"]); - auto to_out = std::dynamic_pointer_cast(blocks["to_out"]); + auto to_qkv = std::dynamic_pointer_cast(blocks["to_qkv"]); + auto to_out = std::dynamic_pointer_cast(blocks["to_out"]); auto qkv_projection = to_qkv->forward(ctx, x); - int64_t sequence = x->ne[1]; - int64_t batch_size = x->ne[2] * x->ne[3]; - qkv_projection = ggml_reshape_4d(ctx->ggml_ctx, - qkv_projection, - 3 * head_dim, - num_head, - sequence, - batch_size); - auto qkv = ggml_ext_chunk(ctx->ggml_ctx, qkv_projection, 3, 0); - auto q = ggml_reshape_4d(ctx->ggml_ctx, - qkv[0], - head_dim, - num_head, - sequence, - batch_size); - auto k = ggml_reshape_4d(ctx->ggml_ctx, - qkv[1], - head_dim, - num_head, - sequence, - batch_size); - auto v = ggml_reshape_4d(ctx->ggml_ctx, - qkv[2], - head_dim, - num_head, - sequence, - batch_size); - q = ggml_rms_norm(ctx->ggml_ctx, q, 1e-5f); - k = ggml_rms_norm(ctx->ggml_ctx, k, 1e-5f); - q = apply_partial_rope(ctx->ggml_ctx, q, pe); - k = apply_partial_rope(ctx->ggml_ctx, k, pe); - auto out = ggml_ext_attention_ext(ctx->ggml_ctx, - ctx->backend, - q, - k, - v, - num_head, - nullptr, - true, - ctx->flash_attn_enabled); + int64_t sequence = x->ne[1]; + int64_t batch_size = x->ne[2] * x->ne[3]; + qkv_projection = ggml_reshape_4d(ctx->ggml_ctx, + qkv_projection, + 3 * head_dim, + num_head, + sequence, + batch_size); + auto qkv = ggml_ext_chunk(ctx->ggml_ctx, qkv_projection, 3, 0); + auto q = ggml_reshape_4d(ctx->ggml_ctx, + qkv[0], + head_dim, + num_head, + sequence, + batch_size); + auto k = ggml_reshape_4d(ctx->ggml_ctx, + qkv[1], + head_dim, + num_head, + sequence, + batch_size); + auto v = ggml_reshape_4d(ctx->ggml_ctx, + qkv[2], + head_dim, + num_head, + sequence, + batch_size); + q = ggml_rms_norm(ctx->ggml_ctx, q, 1e-5f); + k = ggml_rms_norm(ctx->ggml_ctx, k, 1e-5f); + q = apply_partial_rope(ctx->ggml_ctx, q, pe); + k = apply_partial_rope(ctx->ggml_ctx, k, pe); + auto out = ggml_ext_attention_ext(ctx->ggml_ctx, + ctx->backend, + q, + k, + v, + num_head, + nullptr, + true, + ctx->flash_attn_enabled); return to_out->forward(ctx, out); } };