[FFmpeg-devel] [PATCH] tests/dnn/mathunary: fix the issue of NAN
Guo, Yejun
yejun.guo at intel.com
Wed Jul 8 05:39:07 EEST 2020
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of Ting Fu
> Sent: 2020年7月2日 21:51
> To: ffmpeg-devel at 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.fu at 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) )
> 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 at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email ffmpeg-devel-request at ffmpeg.org with
> subject "unsubscribe".
More information about the ffmpeg-devel
mailing list