MCPcopy Create free account
hub / github.com/PABannier/sam3.cpp / sam3_load_hparams

Function sam3_load_hparams

sam3.cpp:1481–1524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1479*****************************************************************************/
1480
1481static bool sam3_load_hparams(std::ifstream& fin, sam3_hparams& hp) {
1482 auto rd = [&](int32_t& v) { fin.read(reinterpret_cast<char*>(&v), 4); };
1483 rd(hp.img_size);
1484 rd(hp.patch_size);
1485 rd(hp.vit_embed_dim);
1486 rd(hp.vit_depth);
1487 rd(hp.vit_num_heads);
1488 int32_t mlp_ratio_x1000;
1489 rd(mlp_ratio_x1000);
1490 hp.vit_mlp_dim = static_cast<int32_t>(hp.vit_embed_dim * (mlp_ratio_x1000 / 1000.0f));
1491 rd(hp.vit_window_size);
1492 rd(hp.n_global_attn);
1493 for (int i = 0; i < hp.n_global_attn && i < 4; ++i) {
1494 rd(hp.global_attn_idx[i]);
1495 }
1496 rd(hp.text_width);
1497 rd(hp.text_heads);
1498 rd(hp.text_layers);
1499 rd(hp.text_ctx_len);
1500 rd(hp.text_vocab_size);
1501 rd(hp.text_out_dim);
1502 rd(hp.neck_dim);
1503 rd(hp.fenc_layers);
1504 rd(hp.fenc_heads);
1505 rd(hp.fenc_ffn_dim);
1506 rd(hp.ddec_layers);
1507 rd(hp.ddec_heads);
1508 rd(hp.ddec_ffn_dim);
1509 rd(hp.ddec_num_queries);
1510 rd(hp.geom_layers);
1511 rd(hp.n_presence_tokens);
1512 rd(hp.n_geom_queries);
1513 rd(hp.sam_embed_dim);
1514 rd(hp.sam_dec_depth);
1515 rd(hp.sam_n_multimask);
1516 rd(hp.sam_iou_head_depth);
1517 rd(hp.mem_out_dim);
1518 rd(hp.mem_attn_layers);
1519 rd(hp.num_maskmem);
1520 rd(hp.max_obj_ptrs);
1521 rd(hp.n_amb_experts);
1522 rd(hp.visual_only);
1523 return !fin.fail();
1524}
1525
1526static void sam3_print_hparams(const sam3_hparams& hp) {
1527 fprintf(stderr, " img_size = %d\n", hp.img_size);

Callers 2

sam3_load_modelFunction · 0.85
sam3_test_load_tokenizerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected