[FFmpeg-devel] [PATCH v1] [libavfiler/dnn] :[To improve efficiency, the exponential operation is changed to single precision]

Qiang.Zhang zqhy_0929 at 163.com
Tue Nov 30 16:02:48 EET 2021


Signed-off-by: Qiang.Zhang <zqhy_0929 at 163.com>
---
 libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 4 ++--
 libavfilter/dnn/dnn_backend_native_layer_dense.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index 7a60aa6a4b..6bf4080a68 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -166,10 +166,10 @@ static void * dnn_execute_layer_conv2d_thread(void *threadarg)
                     output[n_filter] = FFMAX(output[n_filter], 0.0);
                     break;
                 case TANH:
-                    output[n_filter] = 2.0f  / (1.0f + exp(-2.0f * output[n_filter])) - 1.0f;
+                    output[n_filter] = 2.0f  / (1.0f + expf(-2.0f * output[n_filter])) - 1.0f;
                     break;
                 case SIGMOID:
-                    output[n_filter] = 1.0f / (1.0f + exp(-output[n_filter]));
+                    output[n_filter] = 1.0f / (1.0f + expf(-output[n_filter]));
                     break;
                 case NONE:
                     break;
diff --git a/libavfilter/dnn/dnn_backend_native_layer_dense.c b/libavfilter/dnn/dnn_backend_native_layer_dense.c
index 117590d7bb..274d9150ec 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_dense.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_dense.c
@@ -133,10 +133,10 @@ int ff_dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operan
                     output[n_filter] = FFMAX(output[n_filter], 0.0);
                     break;
                 case TANH:
-                    output[n_filter] = 2.0f  / (1.0f + exp(-2.0f * output[n_filter])) - 1.0f;
+                    output[n_filter] = 2.0f  / (1.0f + expf(-2.0f * output[n_filter])) - 1.0f;
                     break;
                 case SIGMOID:
-                    output[n_filter] = 1.0f / (1.0f + exp(-output[n_filter]));
+                    output[n_filter] = 1.0f / (1.0f + expf(-output[n_filter]));
                     break;
                 case NONE:
                     break;
-- 
2.25.1




More information about the ffmpeg-devel mailing list