| 115 | } |
| 116 | |
| 117 | static void print_error_stats(const std::string & name, const error_stats & stats, bool print_histogram) { |
| 118 | double rmse = sqrt(stats.total_error / (double) stats.num_samples); |
| 119 | double median = find_quantile(stats, .5); |
| 120 | double pct95 = find_quantile(stats, .95); |
| 121 | printf("%-50s: rmse %.8f, maxerr %.8f, 95pct<%.4f, median<%.4f\n", name.c_str(), rmse, stats.max_error, pct95, median); |
| 122 | if (print_histogram) { |
| 123 | printf("Error distribution:\n"); |
| 124 | for (size_t i = 0; i < HISTOGRAM_BUCKETS; i++) { |
| 125 | double lower = i * HISTOGRAM_RANGE / HISTOGRAM_BUCKETS; |
| 126 | double upper = (i+1) * HISTOGRAM_RANGE / HISTOGRAM_BUCKETS; |
| 127 | if (i == HISTOGRAM_BUCKETS -1) upper = INFINITY; |
| 128 | printf("[%3.4f, %3.4f): %11" PRIu64 "\n", lower, upper, stats.error_histogram[i]); |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | // copied from ggml.h - verify that we can access this as a flat array |
| 134 | static bool tensor_is_contiguous(const struct ggml_tensor * tensor) { |