File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -2451,6 +2451,30 @@ struct test_cpy : public test_case {
2451
2451
}
2452
2452
2453
2453
double max_nmse_err () override {
2454
+ if (type_src == type_dst) {
2455
+ return 0.0 ;
2456
+ }
2457
+ if (type_dst == GGML_TYPE_Q4_0 || type_dst == GGML_TYPE_Q4_1 || type_dst == GGML_TYPE_IQ4_NL ||
2458
+ type_dst == GGML_TYPE_Q5_0 || type_dst == GGML_TYPE_Q5_1 || type_dst == GGML_TYPE_Q8_0) {
2459
+ // estimate what the max nmse error would be if one quantized value is
2460
+ // off by one. The test values are distributed in [-150,150], so it'll be
2461
+ // roughly (150*2.0 / 2^bits)^2, divided by the mean square value of the reference,
2462
+ // which is roughly 0.25*150^2 times the number of elements.
2463
+ double err_estimate = 1 .0f /8 .0f * 150 .0f ;
2464
+ if (type_dst == GGML_TYPE_IQ4_NL) {
2465
+ // iq4_nl values are a bit more spread out
2466
+ err_estimate *= 2 .0f ;
2467
+ }
2468
+ if (type_dst == GGML_TYPE_Q5_0 || type_dst == GGML_TYPE_Q5_1) {
2469
+ err_estimate /= 2 .0f ;
2470
+ }
2471
+ if (type_dst == GGML_TYPE_Q8_0) {
2472
+ err_estimate /= 8 .0f ;
2473
+ }
2474
+ err_estimate *= err_estimate;
2475
+ err_estimate /= (150 .0f *150 .0f *0 .25f )*float (ne[0 ] * ne[1 ] * ne[2 ] * ne[3 ]);
2476
+ return err_estimate;
2477
+ }
2454
2478
return 1e-6 ;
2455
2479
}
2456
2480
You can’t perform that action at this time.
0 commit comments