| 443 | } |
| 444 | |
| 445 | static void print_table(const std::string & title, const std::vector<metric_row> & rows) { |
| 446 | fprintf(stderr, "\n%s\n", title.c_str()); |
| 447 | fprintf(stderr, "| tensor | shape | max abs diff | mean abs diff | mean rel err | cosine | note |\n"); |
| 448 | fprintf(stderr, "|--------|-------|--------------|---------------|--------------|--------|------|\n"); |
| 449 | for (const auto & row : rows) { |
| 450 | if (!row.measured) { |
| 451 | fprintf(stderr, "| %s | %s | n/a | n/a | n/a | n/a | %s |\n", |
| 452 | row.tensor.c_str(), row.shape.c_str(), row.note.c_str()); |
| 453 | continue; |
| 454 | } |
| 455 | fprintf(stderr, "| %s | %s | %.6e | %.6e | %.6e | %.8f | %s |\n", |
| 456 | row.tensor.c_str(), row.shape.c_str(), row.max_abs, |
| 457 | row.mean_abs, row.mean_rel, row.cosine, row.note.c_str()); |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | static void print_summary(const backend_run & run) { |
| 462 | fprintf(stderr, "\n=== %s vs Python ===\n", run.backend.c_str()); |