]> git.sesse.net Git - ffmpeg/commitdiff
tests/dnn/mathunary: fix the issue of NAN
authorTing Fu <ting.fu@intel.com>
Wed, 8 Jul 2020 06:09:51 +0000 (14:09 +0800)
committerGuo, Yejun <yejun.guo@intel.com>
Thu, 9 Jul 2020 01:34:44 +0000 (09:34 +0800)
When one of output[i] & expected_output is NAN, the unit test will always pass.

Signed-off-by: Ting Fu <ting.fu@intel.com>
Reviewed-by: Guo, Yejun <yejun.guo@intel.com>
tests/dnn/dnn-layer-mathunary-test.c

index 683e623d9512ec076eef412229594ef3a843684f..5afc5c157e4be3f01e24fab05e0fd6fd6a26cfb3 100644 (file)
@@ -86,7 +86,10 @@ static int test(DNNMathUnaryOperation op)
     output = operands[1].data;
     for (int i = 0; i < sizeof(input) / sizeof(float); ++i) {
         float expected_output = get_expected(input[i], op);
-        if(fabs(output[i] - expected_output) > EPS) {
+        int output_nan = isnan(output[i]);
+        int expected_nan = isnan(expected_output);
+        if ((!output_nan && !expected_nan && fabs(output[i] - expected_output) > EPS) ||
+            (output_nan && !expected_nan) || (!output_nan && expected_nan)) {
             printf("at index %d, output: %f, expected_output: %f\n", i, output[i], expected_output);
             av_freep(&output);
             return 1;