MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / build_stack

Method build_stack

subprojects/llama.cpp/tools/mtmd/clip.cpp:715–737  ·  view source on GitHub ↗

Generic function to stack frames for audio processing Abstracts out the StackAudioFrames logic used by ultravox

Source from the content-addressed store, hash-verified

713// Generic function to stack frames for audio processing
714// Abstracts out the StackAudioFrames logic used by ultravox
715ggml_tensor * clip_graph::build_stack(ggml_tensor * cur, int32_t stack_factor, int32_t n_embed) {
716 if (stack_factor <= 1) {
717 return cur;
718 }
719
720 int64_t total_elements = ggml_nelements(cur);
721 int64_t stride = n_embed * stack_factor;
722
723 // Calculate padded length
724 int64_t padded_len = GGML_PAD(total_elements, stride);
725 int64_t pad = padded_len - total_elements;
726
727 if (pad > 0) {
728 // Pad the tensor to make it divisible by stride
729 cur = ggml_view_1d(ctx0, cur, total_elements, 0);
730 cur = ggml_pad(ctx0, cur, pad, 0, 0, 0);
731 }
732
733 // Reshape to [stride, padded_len / stride]
734 cur = ggml_view_2d(ctx0, cur, stride, padded_len / stride,
735 ggml_row_size(cur->type, stride), 0);
736 return cur;
737}
738
739// aka pixel_shuffle / pixel_unshuffle / patch_merger (Kimi-VL)
740// support dynamic resolution

Callers

nothing calls this directly

Calls 5

ggml_nelementsFunction · 0.85
ggml_view_1dFunction · 0.85
ggml_padFunction · 0.85
ggml_view_2dFunction · 0.85
ggml_row_sizeFunction · 0.85

Tested by

no test coverage detected