debug: print NaN positions in test

This commit is contained in:
2026-05-28 07:46:57 +00:00
parent b50f6a8512
commit 146e4f0282

View File

@@ -104,7 +104,10 @@ int test_kernel(const char* name, int HD_val, int sk, float scale,
float max_diff = 0;
int nan_count = 0;
for(int i=0;i<B*H*HD_val;i++) {
if(!isfinite(ho_gpu[i]) || !isfinite(ho_ref[i])) nan_count++;
if(!isfinite(ho_gpu[i]) || !isfinite(ho_ref[i])) {
if(nan_count < 8) printf(" nan at [%d]: gpu=%f ref=%f\n", i, ho_gpu[i], ho_ref[i]);
nan_count++;
}
else max_diff = fmaxf(max_diff, fabsf(ho_gpu[i]-ho_ref[i]));
}
// BF16 output has ~0.1% relative error from quantization.