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

Function main

tests/test_phase4.cpp:150–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150int main(int argc, char ** argv) {
151 if (argc < 4) {
152 fprintf(stderr, "Usage: %s <ref_dir> <model_path> <prompts_tsv>\n", argv[0]);
153 return 1;
154 }
155
156 const std::string ref_dir = argv[1];
157 const std::string model_path = argv[2];
158 const std::string prompts_path = argv[3];
159 const float atol = 1e-4f;
160
161 auto prompts = load_prompt_cases(prompts_path);
162 if (prompts.empty()) {
163 fprintf(stderr, "No prompts loaded from %s\n", prompts_path.c_str());
164 return 1;
165 }
166
167 if (!sam3_test_load_tokenizer(model_path)) {
168 fprintf(stderr, "Failed to load tokenizer from %s\n", model_path.c_str());
169 return 1;
170 }
171
172 sam3_params params;
173 params.model_path = model_path;
174 params.n_threads = 1;
175 params.use_gpu = false;
176
177 auto model = sam3_load_model(params);
178 if (!model) {
179 fprintf(stderr, "Failed to load model from %s\n", model_path.c_str());
180 return 1;
181 }
182
183 const std::string cpp_root = ref_dir + "/cpp_out_phase4";
184 if (!ensure_dir(cpp_root)) {
185 fprintf(stderr, "Failed to create %s\n", cpp_root.c_str());
186 return 1;
187 }
188
189 const std::vector<std::string> names = tensor_names();
190 const std::vector<std::string> category_order = {
191 "token_ids",
192 "causal_mask",
193 "text_token_embed",
194 "text_after_pos_embed",
195 "block_after_ln1",
196 "block_qkv",
197 "block_attn_out",
198 "block_after_attn_residual",
199 "block_after_ln2",
200 "block_mlp_fc1",
201 "block_mlp_gelu",
202 "block_mlp_out",
203 "block_out",
204 "text_final_ln",
205 "text_features_2d",
206 };
207

Callers

nothing calls this directly

Calls 15

sam3_test_load_tokenizerFunction · 0.85
sam3_load_modelFunction · 0.85
ensure_dirFunction · 0.85
tensor_namesFunction · 0.85
load_ref_i32Function · 0.85
sam3_test_tokenizeFunction · 0.85
compare_exact_i32Function · 0.85
load_ref_f32Function · 0.85
category_for_tensorFunction · 0.85
update_summaryFunction · 0.85
label_for_categoryFunction · 0.85

Tested by

no test coverage detected