| 224 | // |
| 225 | |
| 226 | clip_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 | |
| 253 | void clip_graph::cb(ggml_tensor * cur, const char * name, int il) const { |
| 254 | if (il >= 0) { |
nothing calls this directly
no test coverage detected