| 118 | } |
| 119 | |
| 120 | int main(int argc, char ** argv) { |
| 121 | if (argc < 4) { |
| 122 | fprintf(stderr, "Usage: %s <ref_dir> <model_path> <cases_tsv>\n", argv[0]); |
| 123 | return 1; |
| 124 | } |
| 125 | |
| 126 | const std::string ref_dir = argv[1]; |
| 127 | const std::string model_path = argv[2]; |
| 128 | const std::string cases_path = argv[3]; |
| 129 | const std::string cpp_root = ref_dir + "/cpp_out_phase7"; |
| 130 | |
| 131 | if (!ensure_dir(cpp_root)) { |
| 132 | fprintf(stderr, "Failed to create %s\n", cpp_root.c_str()); |
| 133 | return 1; |
| 134 | } |
| 135 | |
| 136 | auto cases = load_cases(cases_path); |
| 137 | if (cases.empty()) { |
| 138 | fprintf(stderr, "No phase 7 cases loaded from %s\n", cases_path.c_str()); |
| 139 | return 1; |
| 140 | } |
| 141 | |
| 142 | sam3_params params; |
| 143 | params.model_path = model_path; |
| 144 | params.n_threads = 1; |
| 145 | params.use_gpu = false; |
| 146 | |
| 147 | auto model = sam3_load_model(params); |
| 148 | if (!model) { |
| 149 | fprintf(stderr, "Failed to load model from %s\n", model_path.c_str()); |
| 150 | return 1; |
| 151 | } |
| 152 | |
| 153 | bool overall_ok = true; |
| 154 | std::vector<report_row> report; |
| 155 | |
| 156 | for (const auto & tc : cases) { |
| 157 | fprintf(stderr, "\n=== Phase 7 Case %s ===\n", tc.id.c_str()); |
| 158 | |
| 159 | const std::string case_ref_dir = ref_dir + "/" + tc.id; |
| 160 | const std::string case_cpp_dir = cpp_root + "/" + tc.id; |
| 161 | if (!ensure_dir(case_cpp_dir)) { |
| 162 | fprintf(stderr, "Failed to create %s\n", case_cpp_dir.c_str()); |
| 163 | overall_ok = false; |
| 164 | continue; |
| 165 | } |
| 166 | |
| 167 | if (!sam3_test_dump_phase7_from_ref_inputs(*model, case_ref_dir, case_cpp_dir, params.n_threads)) { |
| 168 | fprintf(stderr, " [FAIL] could not dump C++ phase 7 tensors for %s\n", tc.id.c_str()); |
| 169 | overall_ok = false; |
| 170 | continue; |
| 171 | } |
| 172 | |
| 173 | for (const auto & tensor : tensor_cases_for(case_ref_dir)) { |
| 174 | auto ref = load_ref_f32(case_ref_dir + "/" + tensor.name); |
| 175 | auto got = load_ref_f32(case_cpp_dir + "/" + tensor.name); |
| 176 | |
| 177 | report_row row; |
nothing calls this directly
no test coverage detected