| 97 | } |
| 98 | |
| 99 | static bool check(const std::string & name, const float * got, const ref_tensor & ref, |
| 100 | float atol, int & n_pass, int & n_fail) { |
| 101 | if (ref.data.empty()) { |
| 102 | fprintf(stderr, " [SKIP] %s — no reference data\n", name.c_str()); |
| 103 | return true; |
| 104 | } |
| 105 | auto r = compare_tensors(got, ref.data.data(), ref.numel(), atol); |
| 106 | bool ok = r.max_diff <= atol; |
| 107 | fprintf(stderr, " %s %-45s: max=%.6e mean=%.6e cos=%.8f bad=%d/%d (atol=%.1e)\n", |
| 108 | ok ? "[PASS]" : "[FAIL]", name.c_str(), r.max_diff, r.mean_diff, |
| 109 | r.cosine_sim, r.n_bad, r.n_elements, atol); |
| 110 | if (ok) n_pass++; else n_fail++; |
| 111 | return ok; |
| 112 | } |
| 113 | |
| 114 | // ═══════════════════════════════════════════════════════════════════════════════ |
| 115 | // Test 1: RoPE computation |
no test coverage detected