From patchwork Sun Jun 28 15:34:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20663 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 8E7AB44B783 for ; Sun, 28 Jun 2020 18:40:34 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6D04D68B751; Sun, 28 Jun 2020 18:40:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7EB4F68B607 for ; Sun, 28 Jun 2020 18:40:27 +0300 (EEST) IronPort-SDR: wDnKlY70yeq+OAGciet+DRfG/iVcYE9NLGS1xugQFq9A7h5voBBGQRaqGll/hr4Vw9Ukf1Ps1M zd3rL8b9upVg== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="230648461" X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="230648461" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2020 08:40:25 -0700 IronPort-SDR: byp3HK401vrTHDfuNXzXdtDRL7KqEVGyXVFdd52ipJ5x3qVw+avMNHO7vPuxADKnVTGJIusxzE LDr4NopRUS5A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="294655899" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2020 08:40:24 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jun 2020 23:34:31 +0800 Message-Id: <20200628153442.29074-1-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 01/12] dnn_backend_native_layer_mathunary: add sinh support 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" Signed-off-by: Ting Fu --- libavfilter/dnn/dnn_backend_native_layer_mathunary.c | 4 ++++ libavfilter/dnn/dnn_backend_native_layer_mathunary.h | 1 + tools/python/convert_from_tensorflow.py | 2 +- tools/python/convert_header.py | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c index 42615c43d5..2630fe07e2 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c @@ -104,6 +104,10 @@ int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_oper for (int i = 0; i < dims_count; ++i) dst[i] = atan(src[i]); return 0; + case DMUO_SINH: + for (int i = 0; i < dims_count; ++i) + dst[i] = sinh(src[i]); + return 0; default: return -1; } diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h index 13fa33178a..760930c60e 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h @@ -37,6 +37,7 @@ typedef enum { DMUO_ASIN = 4, DMUO_ACOS = 5, DMUO_ATAN = 6, + DMUO_SINH = 7, DMUO_COUNT } DNNMathUnaryOperation; diff --git a/tools/python/convert_from_tensorflow.py b/tools/python/convert_from_tensorflow.py index b90c31c495..6f34a71ab4 100644 --- a/tools/python/convert_from_tensorflow.py +++ b/tools/python/convert_from_tensorflow.py @@ -72,7 +72,7 @@ class TFConverter: self.conv2d_scopename_inputname_dict = {} self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 'Maximum':4, 'MathBinary':5, 'MathUnary':6} self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 'Minimum':4} - self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6} + self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6, 'Sinh':7} self.mirrorpad_mode = {'CONSTANT':0, 'REFLECT':1, 'SYMMETRIC':2} self.name_operand_dict = {} diff --git a/tools/python/convert_header.py b/tools/python/convert_header.py index 73cf23bf53..4747f41395 100644 --- a/tools/python/convert_header.py +++ b/tools/python/convert_header.py @@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE' major = 1 # increase minor when we don't have to re-convert the model file -minor = 12 +minor = 13 From patchwork Sun Jun 28 15:34:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20664 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 989C044B783 for ; Sun, 28 Jun 2020 18:40:37 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 82D9C68B76D; Sun, 28 Jun 2020 18:40:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C7AD468B607 for ; Sun, 28 Jun 2020 18:40:28 +0300 (EEST) IronPort-SDR: I0Z3CxuZ9g+wiyxtKoLFF0k+u7q/Ox8TnT2lut5Ow3GSpqC7t+cako3MkcPCJfpWh39UYHAV5c /A9zD+QnOD+g== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="230648465" X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="230648465" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2020 08:40:26 -0700 IronPort-SDR: jUsJjv7wNX3ovCbaBK8jJdQg4xvZUgLJ2EnYjY0pbmpDYhuu+BGGJjbQYXO/BQGCPVClhEFvj1 vzxumnjDf86g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="294655900" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2020 08:40:25 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jun 2020 23:34:32 +0800 Message-Id: <20200628153442.29074-2-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628153442.29074-1-ting.fu@intel.com> References: <20200628153442.29074-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH 02/12] dnn-layer-math-unary-test: add unit test for sinh 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" Signed-off-by: Ting Fu --- tests/dnn/dnn-layer-mathunary-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/dnn/dnn-layer-mathunary-test.c b/tests/dnn/dnn-layer-mathunary-test.c index bf77c44bbe..a1ff05e5fb 100644 --- a/tests/dnn/dnn-layer-mathunary-test.c +++ b/tests/dnn/dnn-layer-mathunary-test.c @@ -44,6 +44,8 @@ static float get_expected(float f, DNNMathUnaryOperation op) return acos(f); case DMUO_ATAN: return atan(f); + case DMUO_SINH: + return sinh(f); default: av_assert0(!"not supported yet"); return 0.f; @@ -101,5 +103,7 @@ int main(int agrc, char **argv) return 1; if (test(DMUO_ATAN)) return 1; + if (test(DMUO_SINH)) + return 1; return 0; } From patchwork Sun Jun 28 15:34:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20665 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 7F1D944B783 for ; Sun, 28 Jun 2020 18:40:38 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 69CC768B78A; Sun, 28 Jun 2020 18:40:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8456A68B723 for ; Sun, 28 Jun 2020 18:40:30 +0300 (EEST) IronPort-SDR: HnLZALOlIbNOdqZ1fliFbxfJkodDlnAdy3WYLPjY3RYKDR5YWOvyTDCwTVqsrzpJKW2ElBvrUr HPwIldCx0XYw== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="230648468" X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="230648468" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2020 08:40:27 -0700 IronPort-SDR: XeYXCll4m2qqf2FdrqarrrPKGSkxiCM9EGeIcXG8bCnLEcJRoeo1H/dhst/GvwFs2e412MYOBZ 4TsSDAtJ94gg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="294655901" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2020 08:40:26 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jun 2020 23:34:33 +0800 Message-Id: <20200628153442.29074-3-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628153442.29074-1-ting.fu@intel.com> References: <20200628153442.29074-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH 03/12] dnn_backend_native_layer_mathunary: add cosh support 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" Signed-off-by: Ting Fu --- libavfilter/dnn/dnn_backend_native_layer_mathunary.c | 4 ++++ libavfilter/dnn/dnn_backend_native_layer_mathunary.h | 1 + tools/python/convert_from_tensorflow.py | 2 +- tools/python/convert_header.py | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c index 2630fe07e2..ddb70996e7 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c @@ -108,6 +108,10 @@ int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_oper for (int i = 0; i < dims_count; ++i) dst[i] = sinh(src[i]); return 0; + case DMUO_COSH: + for (int i = 0; i < dims_count; ++i) + dst[i] = cosh(src[i]); + return 0; default: return -1; } diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h index 760930c60e..5a486b4f5f 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h @@ -38,6 +38,7 @@ typedef enum { DMUO_ACOS = 5, DMUO_ATAN = 6, DMUO_SINH = 7, + DMUO_COSH = 8, DMUO_COUNT } DNNMathUnaryOperation; diff --git a/tools/python/convert_from_tensorflow.py b/tools/python/convert_from_tensorflow.py index 6f34a71ab4..96da44c4a8 100644 --- a/tools/python/convert_from_tensorflow.py +++ b/tools/python/convert_from_tensorflow.py @@ -72,7 +72,7 @@ class TFConverter: self.conv2d_scopename_inputname_dict = {} self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 'Maximum':4, 'MathBinary':5, 'MathUnary':6} self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 'Minimum':4} - self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6, 'Sinh':7} + self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8} self.mirrorpad_mode = {'CONSTANT':0, 'REFLECT':1, 'SYMMETRIC':2} self.name_operand_dict = {} diff --git a/tools/python/convert_header.py b/tools/python/convert_header.py index 4747f41395..a73f51ba48 100644 --- a/tools/python/convert_header.py +++ b/tools/python/convert_header.py @@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE' major = 1 # increase minor when we don't have to re-convert the model file -minor = 13 +minor = 14 From patchwork Sun Jun 28 15:34:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20666 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 6F6D144B783 for ; Sun, 28 Jun 2020 18:40:40 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 58D0668B753; Sun, 28 Jun 2020 18:40:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 72B9D68B78C for ; Sun, 28 Jun 2020 18:40:33 +0300 (EEST) IronPort-SDR: yxn9Teh9jWCHxRhw+F2YzKWQh/KA6ts7XsQcfk8GACQHIkbrVARFNcqiNIffJ8/rYCq/vWKypX bTVM87jP6mUw== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="230648470" X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="230648470" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2020 08:40:28 -0700 IronPort-SDR: 3ea3EZ4u5e4UHY720Sp4Ujg4YN+OYIv/e+PhFgI5Z/ZpL8QTe/Ca0AxE4cHMHGo5f4N6AlhMrB KK6wO+PRLKNw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="294655902" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2020 08:40:27 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jun 2020 23:34:34 +0800 Message-Id: <20200628153442.29074-4-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628153442.29074-1-ting.fu@intel.com> References: <20200628153442.29074-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH 04/12] dnn-layer-math-unary-test: add unit test for cosh 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" Signed-off-by: Ting Fu --- tests/dnn/dnn-layer-mathunary-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/dnn/dnn-layer-mathunary-test.c b/tests/dnn/dnn-layer-mathunary-test.c index a1ff05e5fb..0280debc0b 100644 --- a/tests/dnn/dnn-layer-mathunary-test.c +++ b/tests/dnn/dnn-layer-mathunary-test.c @@ -46,6 +46,8 @@ static float get_expected(float f, DNNMathUnaryOperation op) return atan(f); case DMUO_SINH: return sinh(f); + case DMUO_COSH: + return cosh(f); default: av_assert0(!"not supported yet"); return 0.f; @@ -105,5 +107,7 @@ int main(int agrc, char **argv) return 1; if (test(DMUO_SINH)) return 1; + if (test(DMUO_COSH)) + return 1; return 0; } From patchwork Sun Jun 28 15:34:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20667 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 4BADA44B783 for ; Sun, 28 Jun 2020 18:40:43 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2DFEB68B76C; Sun, 28 Jun 2020 18:40:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AD8E168B753 for ; Sun, 28 Jun 2020 18:40:34 +0300 (EEST) IronPort-SDR: SFOtqgUHtJTeiSasbSgn4ELIczVjh9q3lFfLbcDJa/A8S1crLdZuSjkh5QQ+9r1Qo398r8gt8n ZdA68jOEz5JQ== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="230648471" X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="230648471" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2020 08:40:28 -0700 IronPort-SDR: EOHbSQLjWxpWb3hwxMPs3Kuap72SUocI2bo2p+ifuXZf7swwx9D0+bvb6Q3b4sSxhm4PO6ogxt GUiOpPRa1fLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="294655907" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2020 08:40:28 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jun 2020 23:34:35 +0800 Message-Id: <20200628153442.29074-5-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628153442.29074-1-ting.fu@intel.com> References: <20200628153442.29074-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH 05/12] dnn_backend_native_layer_mathunary: add tanh support 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" Signed-off-by: Ting Fu --- libavfilter/dnn/dnn_backend_native_layer_mathunary.c | 4 ++++ libavfilter/dnn/dnn_backend_native_layer_mathunary.h | 1 + tools/python/convert_from_tensorflow.py | 2 +- tools/python/convert_header.py | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c index ddb70996e7..ccdbcc21e0 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c @@ -112,6 +112,10 @@ int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_oper for (int i = 0; i < dims_count; ++i) dst[i] = cosh(src[i]); return 0; + case DMUO_TANH: + for (int i = 0; i < dims_count; ++i) + dst[i] = tanh(src[i]); + return 0; default: return -1; } diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h index 5a486b4f5f..ae0c1e1cdd 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h @@ -39,6 +39,7 @@ typedef enum { DMUO_ATAN = 6, DMUO_SINH = 7, DMUO_COSH = 8, + DMUO_TANH = 9, DMUO_COUNT } DNNMathUnaryOperation; diff --git a/tools/python/convert_from_tensorflow.py b/tools/python/convert_from_tensorflow.py index 96da44c4a8..f98a3cae3d 100644 --- a/tools/python/convert_from_tensorflow.py +++ b/tools/python/convert_from_tensorflow.py @@ -72,7 +72,7 @@ class TFConverter: self.conv2d_scopename_inputname_dict = {} self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 'Maximum':4, 'MathBinary':5, 'MathUnary':6} self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 'Minimum':4} - self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8} + self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9} self.mirrorpad_mode = {'CONSTANT':0, 'REFLECT':1, 'SYMMETRIC':2} self.name_operand_dict = {} diff --git a/tools/python/convert_header.py b/tools/python/convert_header.py index a73f51ba48..d2753f0af0 100644 --- a/tools/python/convert_header.py +++ b/tools/python/convert_header.py @@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE' major = 1 # increase minor when we don't have to re-convert the model file -minor = 14 +minor = 15 From patchwork Sun Jun 28 15:34:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20669 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 24B1444B783 for ; Sun, 28 Jun 2020 18:40:45 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0915568B7A7; Sun, 28 Jun 2020 18:40:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6AB1368B79F for ; Sun, 28 Jun 2020 18:40:36 +0300 (EEST) IronPort-SDR: zpEoJ1rwy/cVUNFdwrwon67GM9iSEko1sgR/vT9ug7G/3naVI6gJH0/RG+B4g+sgy6PJJfIXdj P08LUgiMZTyA== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="230648473" X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="230648473" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2020 08:40:29 -0700 IronPort-SDR: S9+I+LqpbUjt2ajKc7ouyjt9kTVFQOArlYM0CsTQ8sfcF2bpcRQfLuO0xyg0ge9gTcE2E9RLhM R+wE++6gIYXQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="294655909" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2020 08:40:29 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jun 2020 23:34:36 +0800 Message-Id: <20200628153442.29074-6-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628153442.29074-1-ting.fu@intel.com> References: <20200628153442.29074-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH 06/12] dnn-layer-math-unary-test: add unit test for tanh 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" Signed-off-by: Ting Fu --- tests/dnn/dnn-layer-mathunary-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/dnn/dnn-layer-mathunary-test.c b/tests/dnn/dnn-layer-mathunary-test.c index 0280debc0b..6885b4d318 100644 --- a/tests/dnn/dnn-layer-mathunary-test.c +++ b/tests/dnn/dnn-layer-mathunary-test.c @@ -48,6 +48,8 @@ static float get_expected(float f, DNNMathUnaryOperation op) return sinh(f); case DMUO_COSH: return cosh(f); + case DMUO_TANH: + return tanh(f); default: av_assert0(!"not supported yet"); return 0.f; @@ -109,5 +111,7 @@ int main(int agrc, char **argv) return 1; if (test(DMUO_COSH)) return 1; + if (test(DMUO_TANH)) + return 1; return 0; } From patchwork Sun Jun 28 15:34:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20674 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 6E38944B783 for ; Sun, 28 Jun 2020 18:40:52 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4F07568B7DF; Sun, 28 Jun 2020 18:40:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 565DA68B7BE for ; Sun, 28 Jun 2020 18:40:39 +0300 (EEST) IronPort-SDR: fcjD+JnazvxJ6nMfITevA9dgkGAU3EMis4kBysLHmlvfd45Norj1yWfnD/ga/afXiwadJO2Vw+ PfQdsEBBwJcg== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="230648474" X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="230648474" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2020 08:40:30 -0700 IronPort-SDR: SSd+dty8WdfAit06qAISMDzOZ5yomnuXCBDp1Id1WfLyTDQsVwp3wFgYr1t0E4lkOr32FNHGSW 5gSktm5tO/PA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="294655913" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2020 08:40:29 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jun 2020 23:34:37 +0800 Message-Id: <20200628153442.29074-7-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628153442.29074-1-ting.fu@intel.com> References: <20200628153442.29074-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH 07/12] dnn_backend_native_layer_mathunary: add asinh support 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" Signed-off-by: Ting Fu --- libavfilter/dnn/dnn_backend_native_layer_mathunary.c | 4 ++++ libavfilter/dnn/dnn_backend_native_layer_mathunary.h | 1 + tools/python/convert_from_tensorflow.py | 2 +- tools/python/convert_header.py | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c index ccdbcc21e0..83df98d0f8 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c @@ -116,6 +116,10 @@ int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_oper for (int i = 0; i < dims_count; ++i) dst[i] = tanh(src[i]); return 0; + case DMUO_ASINH: + for (int i = 0; i < dims_count; ++i) + dst[i] = asinh(src[i]); + return 0; default: return -1; } diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h index ae0c1e1cdd..fbe9af5c7d 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h @@ -40,6 +40,7 @@ typedef enum { DMUO_SINH = 7, DMUO_COSH = 8, DMUO_TANH = 9, + DMUO_ASINH = 10, DMUO_COUNT } DNNMathUnaryOperation; diff --git a/tools/python/convert_from_tensorflow.py b/tools/python/convert_from_tensorflow.py index f98a3cae3d..0d756c8109 100644 --- a/tools/python/convert_from_tensorflow.py +++ b/tools/python/convert_from_tensorflow.py @@ -72,7 +72,7 @@ class TFConverter: self.conv2d_scopename_inputname_dict = {} self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 'Maximum':4, 'MathBinary':5, 'MathUnary':6} self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 'Minimum':4} - self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9} + self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9, 'Asinh':10} self.mirrorpad_mode = {'CONSTANT':0, 'REFLECT':1, 'SYMMETRIC':2} self.name_operand_dict = {} diff --git a/tools/python/convert_header.py b/tools/python/convert_header.py index d2753f0af0..3211c13f6d 100644 --- a/tools/python/convert_header.py +++ b/tools/python/convert_header.py @@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE' major = 1 # increase minor when we don't have to re-convert the model file -minor = 15 +minor = 16 From patchwork Sun Jun 28 15:34:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20668 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 2AE7E44B783 for ; Sun, 28 Jun 2020 18:40:44 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 162E068B7B6; Sun, 28 Jun 2020 18:40:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B85E68B79F for ; Sun, 28 Jun 2020 18:40:40 +0300 (EEST) IronPort-SDR: FTqe4ZduPAqv0W9D0CpjaJO5acyYES2b/y+e/VhzCzsCkH2iZaLmovU92B7xRPYG2qayb69vsw BT3kQH0RPp1g== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="230648478" X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="230648478" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2020 08:40:31 -0700 IronPort-SDR: S7c7LkFZ1hqvnMPr8DhUFG/zljPXc7BR6Tl5Xbmw57qVjnGvkyinuwoT5j3N1cgNHVh5J9R7NK ISJLYmH2KcWg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="294655917" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2020 08:40:30 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jun 2020 23:34:38 +0800 Message-Id: <20200628153442.29074-8-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628153442.29074-1-ting.fu@intel.com> References: <20200628153442.29074-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH 08/12] dnn-layer-math-unary-test: add unit test for asinh 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" Signed-off-by: Ting Fu --- tests/dnn/dnn-layer-mathunary-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/dnn/dnn-layer-mathunary-test.c b/tests/dnn/dnn-layer-mathunary-test.c index 6885b4d318..90fce71a0c 100644 --- a/tests/dnn/dnn-layer-mathunary-test.c +++ b/tests/dnn/dnn-layer-mathunary-test.c @@ -50,6 +50,8 @@ static float get_expected(float f, DNNMathUnaryOperation op) return cosh(f); case DMUO_TANH: return tanh(f); + case DMUO_ASINH: + return asinh(f); default: av_assert0(!"not supported yet"); return 0.f; @@ -113,5 +115,7 @@ int main(int agrc, char **argv) return 1; if (test(DMUO_TANH)) return 1; + if (test(DMUO_ASINH)) + return 1; return 0; } From patchwork Sun Jun 28 15:34:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20670 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 E780B44B783 for ; Sun, 28 Jun 2020 18:40:45 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D328C68B7C8; Sun, 28 Jun 2020 18:40:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8B77A68B7A1 for ; Sun, 28 Jun 2020 18:40:41 +0300 (EEST) IronPort-SDR: X9JMLUI7ubcOPT9dvzW9zuOVXJJkwSw3YOpD0O80c7kl2j8dDG++XbCFU1Y8gqkEvN9e0trfsk spWaSfe5VZdA== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="230648479" X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="230648479" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2020 08:40:32 -0700 IronPort-SDR: dQki20kdL3eQBKr4qLPBf2LqcBqEPwvcWWT7Ch1kU1wHglt2g+zYnU0YYmcaFnPA3cVvzPsrbL qLpnhKJ5udcw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="294655924" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2020 08:40:31 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jun 2020 23:34:39 +0800 Message-Id: <20200628153442.29074-9-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628153442.29074-1-ting.fu@intel.com> References: <20200628153442.29074-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH 09/12] dnn_backend_native_layer_mathunary: add acosh support 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" Signed-off-by: Ting Fu --- libavfilter/dnn/dnn_backend_native_layer_mathunary.c | 4 ++++ libavfilter/dnn/dnn_backend_native_layer_mathunary.h | 1 + tools/python/convert_from_tensorflow.py | 2 +- tools/python/convert_header.py | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c index 83df98d0f8..b77b84a794 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c @@ -120,6 +120,10 @@ int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_oper for (int i = 0; i < dims_count; ++i) dst[i] = asinh(src[i]); return 0; + case DMUO_ACOSH: + for (int i = 0; i < dims_count; ++i) + dst[i] = acosh(src[i]); + return 0; default: return -1; } diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h index fbe9af5c7d..eb30231549 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h @@ -41,6 +41,7 @@ typedef enum { DMUO_COSH = 8, DMUO_TANH = 9, DMUO_ASINH = 10, + DMUO_ACOSH = 11, DMUO_COUNT } DNNMathUnaryOperation; diff --git a/tools/python/convert_from_tensorflow.py b/tools/python/convert_from_tensorflow.py index 0d756c8109..1e73e3aefe 100644 --- a/tools/python/convert_from_tensorflow.py +++ b/tools/python/convert_from_tensorflow.py @@ -72,7 +72,7 @@ class TFConverter: self.conv2d_scopename_inputname_dict = {} self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 'Maximum':4, 'MathBinary':5, 'MathUnary':6} self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 'Minimum':4} - self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9, 'Asinh':10} + self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9, 'Asinh':10, 'Acosh':11} self.mirrorpad_mode = {'CONSTANT':0, 'REFLECT':1, 'SYMMETRIC':2} self.name_operand_dict = {} diff --git a/tools/python/convert_header.py b/tools/python/convert_header.py index 3211c13f6d..8fc3438552 100644 --- a/tools/python/convert_header.py +++ b/tools/python/convert_header.py @@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE' major = 1 # increase minor when we don't have to re-convert the model file -minor = 16 +minor = 17 From patchwork Sun Jun 28 15:34:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20671 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 AD88F44B783 for ; Sun, 28 Jun 2020 18:40:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 92FA768B7CE; Sun, 28 Jun 2020 18:40:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 611DD68B7A1 for ; Sun, 28 Jun 2020 18:40:42 +0300 (EEST) IronPort-SDR: 5isAGZp4911XLik64yfBaYrF5KT7lBrzpy5/zbpK18KrL4mV7o2ACXQUorCxAg7d/YtGDOHxqp 8msfRTBtKg2w== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="230648483" X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="230648483" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2020 08:40:33 -0700 IronPort-SDR: OOCwNHJZzF4GwnXxGNQ9ypCaEKuQuWZKrfJt1M8Pper5iYm25kqPZt8Ev1DH8driovduUPnQDC OiDAOqXH6/eA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="294655931" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2020 08:40:32 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jun 2020 23:34:40 +0800 Message-Id: <20200628153442.29074-10-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628153442.29074-1-ting.fu@intel.com> References: <20200628153442.29074-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH 10/12] dnn-layer-math-unary-test: add unit test for acosh 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" Signed-off-by: Ting Fu --- tests/dnn/dnn-layer-mathunary-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/dnn/dnn-layer-mathunary-test.c b/tests/dnn/dnn-layer-mathunary-test.c index 90fce71a0c..5587e47ad5 100644 --- a/tests/dnn/dnn-layer-mathunary-test.c +++ b/tests/dnn/dnn-layer-mathunary-test.c @@ -52,6 +52,8 @@ static float get_expected(float f, DNNMathUnaryOperation op) return tanh(f); case DMUO_ASINH: return asinh(f); + case DMUO_ACOSH: + return acosh(f); default: av_assert0(!"not supported yet"); return 0.f; @@ -117,5 +119,7 @@ int main(int agrc, char **argv) return 1; if (test(DMUO_ASINH)) return 1; + if (test(DMUO_ACOSH)) + return 1; return 0; } From patchwork Sun Jun 28 15:34:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20672 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 85C8044B783 for ; Sun, 28 Jun 2020 18:40:47 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6A48A68B7D2; Sun, 28 Jun 2020 18:40:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7BA8568B729 for ; Sun, 28 Jun 2020 18:40:42 +0300 (EEST) IronPort-SDR: +Cg0Xi/9z/8c0hWER38uR2+q16nXvEaxKXmFj3tkfsfmHp4gSJ0pTjJs+HqbP3HpVOcn1wkmF/ o303/tmXe01g== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="230648489" X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="230648489" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2020 08:40:34 -0700 IronPort-SDR: Q40EpoXlllmKEDHF1fuukw3KcGeaD1nK9coEtE3MX2beLhdhXbwqnlF4Dywb0ZdwQXU5YLQBoa plqA+1WTmOow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="294655933" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2020 08:40:33 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jun 2020 23:34:41 +0800 Message-Id: <20200628153442.29074-11-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628153442.29074-1-ting.fu@intel.com> References: <20200628153442.29074-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH 11/12] dnn_backend_native_layer_mathunary: add atanh support 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" It can be tested with the model generated with below python script: import tensorflow as tf import numpy as np import imageio in_img = imageio.imread('input.jpeg') in_img = in_img.astype(np.float32)/255.0 in_data = in_img[np.newaxis, :] x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in') please uncomment the part you want to test x_sinh_1 = tf.sinh(x) x_out = tf.divide(x_sinh_1, 1.176) # sinh(1.0) x_cosh_1 = tf.cosh(x) x_out = tf.divide(x_cosh_1, 1.55) # cosh(1.0) x_tanh_1 = tf.tanh(x) x__out = tf.divide(x_tanh_1, 0.77) # tanh(1.0) x_asinh_1 = tf.asinh(x) x_out = tf.divide(x_asinh_1, 0.89) # asinh(1.0/1.1) x_acosh_1 = tf.add(x, 1.1) x_acosh_2 = tf.acosh(x_acosh_1) # accept (1, inf) x_out = tf.divide(x_acosh_2, 1.4) # acosh(2.1) x_atanh_1 = tf.divide(x, 1.1) x_atanh_2 = tf.atanh(x_atanh_1) # accept (-1, 1) x_out = tf.divide(x_atanh_2, 1.55) # atanhh(1.0/1.1) y = tf.identity(x_out, name='dnn_out') #please only preserve the x_out you want to test sess=tf.Session() sess.run(tf.global_variables_initializer()) graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, ['dnn_out']) tf.train.write_graph(graph_def, '.', 'image_process.pb', as_text=False) print("image_process.pb generated, please use \ path_to_ffmpeg/tools/python/convert.py to generate image_process.model\n") output = sess.run(y, feed_dict={x: in_data}) imageio.imsave("out.jpg", np.squeeze(output)) Signed-off-by: Ting Fu --- libavfilter/dnn/dnn_backend_native_layer_mathunary.c | 4 ++++ libavfilter/dnn/dnn_backend_native_layer_mathunary.h | 1 + tools/python/convert_from_tensorflow.py | 2 +- tools/python/convert_header.py | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c index b77b84a794..c83d50db64 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c @@ -124,6 +124,10 @@ int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_oper for (int i = 0; i < dims_count; ++i) dst[i] = acosh(src[i]); return 0; + case DMUO_ATANH: + for (int i = 0; i < dims_count; ++i) + dst[i] = atanh(src[i]); + return 0; default: return -1; } diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h index eb30231549..8076356ba4 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h @@ -42,6 +42,7 @@ typedef enum { DMUO_TANH = 9, DMUO_ASINH = 10, DMUO_ACOSH = 11, + DMUO_ATANH = 12, DMUO_COUNT } DNNMathUnaryOperation; diff --git a/tools/python/convert_from_tensorflow.py b/tools/python/convert_from_tensorflow.py index 1e73e3aefe..85db7bf710 100644 --- a/tools/python/convert_from_tensorflow.py +++ b/tools/python/convert_from_tensorflow.py @@ -72,7 +72,7 @@ class TFConverter: self.conv2d_scopename_inputname_dict = {} self.op2code = {'Conv2D':1, 'DepthToSpace':2, 'MirrorPad':3, 'Maximum':4, 'MathBinary':5, 'MathUnary':6} self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 'Minimum':4} - self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9, 'Asinh':10, 'Acosh':11} + self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4, 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9, 'Asinh':10, 'Acosh':11, 'Atanh':12} self.mirrorpad_mode = {'CONSTANT':0, 'REFLECT':1, 'SYMMETRIC':2} self.name_operand_dict = {} diff --git a/tools/python/convert_header.py b/tools/python/convert_header.py index 8fc3438552..9851d84144 100644 --- a/tools/python/convert_header.py +++ b/tools/python/convert_header.py @@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE' major = 1 # increase minor when we don't have to re-convert the model file -minor = 17 +minor = 18 From patchwork Sun Jun 28 15:34:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Ting" X-Patchwork-Id: 20673 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 7723644B783 for ; Sun, 28 Jun 2020 18:40:51 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5BABD68B7B7; Sun, 28 Jun 2020 18:40:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 503D668B7B6 for ; Sun, 28 Jun 2020 18:40:43 +0300 (EEST) IronPort-SDR: JOK7Vq3xfJvsF3UuZQe9spFr4mlQayc9haOterppVwDRmiTqR4Mdi3cIRDQrwd4UTeWOs8DIjl 2DmsTP5ryokg== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="230648492" X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="230648492" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2020 08:40:35 -0700 IronPort-SDR: epbf1rpQIP/GVB4PY8szyPG17x4ZUucmLXe8BYJYb3w/NqTsHX4PrHQRmG/wzcp3K5wUyBqh48 ItFGyi/F4Agg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,291,1589266800"; d="scan'208";a="294655943" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.54]) by orsmga002.jf.intel.com with ESMTP; 28 Jun 2020 08:40:34 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jun 2020 23:34:42 +0800 Message-Id: <20200628153442.29074-12-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200628153442.29074-1-ting.fu@intel.com> References: <20200628153442.29074-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH 12/12] dnn-layer-math-unary-test: add unit test for atanh 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" Signed-off-by: Ting Fu --- tests/dnn/dnn-layer-mathunary-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/dnn/dnn-layer-mathunary-test.c b/tests/dnn/dnn-layer-mathunary-test.c index 5587e47ad5..1815f79f34 100644 --- a/tests/dnn/dnn-layer-mathunary-test.c +++ b/tests/dnn/dnn-layer-mathunary-test.c @@ -54,6 +54,8 @@ static float get_expected(float f, DNNMathUnaryOperation op) return asinh(f); case DMUO_ACOSH: return acosh(f); + case DMUO_ATANH: + return acosh(f); default: av_assert0(!"not supported yet"); return 0.f; @@ -121,5 +123,7 @@ int main(int agrc, char **argv) return 1; if (test(DMUO_ACOSH)) return 1; + if (test(DMUO_ATANH)) + return 1; return 0; }