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

Method clip_graph

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

Source from the content-addressed store, hash-verified

224//
225
226clip_graph::clip_graph(clip_ctx * ctx, const clip_image_f32 & img) :
227 model(ctx->model),
228 hparams(model.hparams),
229 proj_type(ctx->proj_type()),
230 img(img),
231 patch_size(hparams.patch_size),
232 n_patches_x(img.nx / patch_size),
233 n_patches_y(img.ny / patch_size),
234 n_patches(n_patches_x * n_patches_y),
235 n_embd(hparams.n_embd),
236 n_head(hparams.n_head),
237 d_head(n_embd / n_head),
238 n_layer(hparams.n_layer),
239 n_mmproj_embd(clip_n_mmproj_embd(ctx)),
240 eps(hparams.eps),
241 kq_scale(1.0f / sqrtf((float)d_head)),
242 flash_attn_type(ctx->flash_attn_type) {
243 struct ggml_init_params params = {
244 /*.mem_size =*/ ctx->buf_compute_meta.size(),
245 /*.mem_buffer =*/ ctx->buf_compute_meta.data(),
246 /*.no_alloc =*/ true,
247 };
248 ctx0_ptr.reset(ggml_init(params));
249 ctx0 = ctx0_ptr.get();
250 gf = ggml_new_graph_custom(ctx0, ctx->max_nodes, false);
251}
252
253void clip_graph::cb(ggml_tensor * cur, const char * name, int il) const {
254 if (il >= 0) {

Callers

nothing calls this directly

Calls 8

clip_n_mmproj_embdFunction · 0.85
ggml_initFunction · 0.85
ggml_new_graph_customFunction · 0.85
proj_typeMethod · 0.80
sizeMethod · 0.65
resetMethod · 0.65
getMethod · 0.65
dataMethod · 0.45

Tested by

no test coverage detected