> -----Original Message----- > From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of Guo, > Yejun > Sent: Wednesday, July 8, 2020 10:39 AM > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] tests/dnn/mathunary: fix the issue of NAN > > > > > -----Original Message----- > > From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of Ting > > Fu > > Sent: 2020年7月2日 21:51 > > To: ffmpeg-devel@ffmpeg.org > > Subject: [FFmpeg-devel] [PATCH] tests/dnn/mathunary: fix the issue of > > NAN > > > > When one of output[i] & expected_output is NAN, the unit test will always > pass. > > > > Signed-off-by: Ting Fu <ting...@intel.com> > > --- > > tests/dnn/dnn-layer-mathunary-test.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/tests/dnn/dnn-layer-mathunary-test.c > > b/tests/dnn/dnn-layer-mathunary-test.c > > index bf77c44bbe..f251447771 100644 > > --- a/tests/dnn/dnn-layer-mathunary-test.c > > +++ b/tests/dnn/dnn-layer-mathunary-test.c > > @@ -74,7 +74,8 @@ 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) { > > + if ((isnan(output[i]) ^ isnan(expected_output)) || > > + fabs(output[i] - expected_output) > EPS) { > > it's possible that different platform handles NaN slightly different. > my suggestion is to describe it simply/clearly to avoid possible issue. > > for example. > A: isnan(output[i]); > B: isnan(expected_output); > C: fabs(output[i] - expected_output) > EPS if ( (A&&!B) || (!A&&B) || (!A && > !B > && C) ) > Hi Yejun,
Thank you for your review. Modified in PATCH V2. The verify logic is as below: If ( (!A && !B && (ABS_SUB> EPS)) || (A && !B) || (!A && B)). Thank you Ting FU > > > printf("at index %d, output: %f, expected_output: %f\n", > > i, output[i], expected_output); > > av_freep(&output); > > return 1; > > -- > > 2.17.1 > > > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org > with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".