| 200 | } |
| 201 | |
| 202 | static metric_row compare_state_nhwc(const sam3_state & state, |
| 203 | const std::string & tensor_name, |
| 204 | const std::string & ref_path, |
| 205 | const std::string & dump_dir) { |
| 206 | metric_row row; |
| 207 | auto ref = load_ref_f32(ref_path); |
| 208 | row.tensor = tensor_name; |
| 209 | row.shape = shape_to_string(ref.shape); |
| 210 | |
| 211 | if (ref.data.empty()) { |
| 212 | row.note = "missing python ref"; |
| 213 | return row; |
| 214 | } |
| 215 | if (!sam3_dump_state_tensor(state, tensor_name, dump_dir + "/" + tensor_name)) { |
| 216 | row.note = "missing state tensor"; |
| 217 | return row; |
| 218 | } |
| 219 | auto cpp = load_ref_f32(dump_dir + "/" + tensor_name); |
| 220 | if (cpp.data.empty()) { |
| 221 | row.note = "missing dumped tensor"; |
| 222 | return row; |
| 223 | } |
| 224 | |
| 225 | auto transposed = ggml_dump_to_nhwc_flat(cpp); |
| 226 | if ((int) transposed.size() != ref.numel()) { |
| 227 | row.note = "numel mismatch"; |
| 228 | return row; |
| 229 | } |
| 230 | return compute_metrics(tensor_name, transposed.data(), ref.data.data(), ref.numel(), ref.shape); |
| 231 | } |
| 232 | |
| 233 | static metric_row compare_state_nchw(const sam3_state & state, |
| 234 | const std::string & tensor_name, |
no test coverage detected