From patchwork Wed Jul 8 03:39:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20868 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id A12D344BA61 for ; Wed, 8 Jul 2020 06:45:13 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6CC00689F22; Wed, 8 Jul 2020 06:45:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 87574687F1D for ; Wed, 8 Jul 2020 06:45:06 +0300 (EEST) IronPort-SDR: J2iVvEzDU8IXrilOQXNesugrv0dOLGFiqKXTdJtuJI9ONvjhJgf5NNc0sp/l6F29qv/PQtOngH OoIfPKPWU5uA== X-IronPort-AV: E=McAfee;i="6000,8403,9675"; a="145234968" X-IronPort-AV: E=Sophos;i="5.75,326,1589266800"; d="scan'208";a="145234968" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2020 20:45:04 -0700 IronPort-SDR: qCpyht6d3fNgXCTBKQY9DIl0VgGN9f4morLtlLX9wYWzpHw8RV0Uaf7rf93+qIAk9xLX5zePGP kehydNuZHpfw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,326,1589266800"; d="scan'208";a="483282358" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by fmsmga006.fm.intel.com with ESMTP; 07 Jul 2020 20:45:03 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Wed, 8 Jul 2020 11:39:24 +0800 Message-Id: <20200708033924.7506-1-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH V2] tests/dnn/mathunary: fix the issue of NAN X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" When one of output[i] & expected_output is NAN, the unit test will always pass. Signed-off-by: Ting Fu --- 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 683e623d95..70c6a43f95 100644 --- a/tests/dnn/dnn-layer-mathunary-test.c +++ b/tests/dnn/dnn-layer-mathunary-test.c @@ -86,7 +86,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) || + (isnan(output[i]) && !isnan(expected_output)) || (!isnan(output[i]) && isnan(expected_output))) { printf("at index %d, output: %f, expected_output: %f\n", i, output[i], expected_output); av_freep(&output); return 1;