[FFmpeg-devel] [PATCH 2/2] libavfilter/dnn/dnn_backend_tf: add tf.pad support for tensorflow backend with native model.

Guo, Yejun yejun.guo at intel.com
Fri Aug 16 05:24:11 EEST 2019



> -----Original Message-----
> From: Guo, Yejun
> Sent: Wednesday, August 14, 2019 3:06 PM
> To: ffmpeg-devel at ffmpeg.org
> Cc: Guo, Yejun <yejun.guo at intel.com>
> Subject: [PATCH 2/2] libavfilter/dnn/dnn_backend_tf: add tf.pad support for
> tensorflow backend with native model.
> 
> Signed-off-by: Guo, Yejun <yejun.guo at intel.com>
> ---
>  libavfilter/dnn/dnn_backend_tf.c | 47 ++++++++++++++++------------------------
>  1 file changed, 19 insertions(+), 28 deletions(-)
> 
> diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c
> index ca7434a..75dbe5e 100644
> --- a/libavfilter/dnn/dnn_backend_tf.c
> +++ b/libavfilter/dnn/dnn_backend_tf.c
> @@ -27,6 +27,7 @@
>  #include "dnn_backend_native.h"
>  #include "libavformat/avio.h"
>  #include "libavutil/avassert.h"
> +#include "dnn_backend_native_layer_pad.h"
> 
>  #include <tensorflow/c/c_api.h>
> 
> @@ -347,23 +348,8 @@ static DNNReturnType
> add_depth_to_space_layer(TFModel *tf_model, TF_Operation **
>      return DNN_SUCCESS;
>  }
> 
> -static int calculate_pad(const ConvolutionalNetwork *conv_network)
> -{
> -    ConvolutionalParams *params;
> -    int32_t layer;
> -    int pad = 0;
> -
> -    for (layer = 0; layer < conv_network->layers_num; ++layer){
> -        if (conv_network->layers[layer].type == CONV){
> -            params = (ConvolutionalParams
> *)conv_network->layers[layer].params;
> -            pad += params->kernel_size >> 1;
> -        }
> -    }
> -
> -    return pad;
> -}
> -
> -static DNNReturnType add_pad_op(TFModel *tf_model, TF_Operation
> **cur_op, const int32_t pad)
> +static DNNReturnType add_pad_layer(TFModel *tf_model, TF_Operation
> **cur_op,
> +                                              LayerPadParams
> *params, const int layer)
>  {
>      TF_Operation *op;
>      TF_Tensor *tensor;
> @@ -374,14 +360,21 @@ static DNNReturnType add_pad_op(TFModel
> *tf_model, TF_Operation **cur_op, const
> 
>      input.index = 0;
> 
> -    op_desc = TF_NewOperation(tf_model->graph, "Const", "pads");
> +    char name_buffer[NAME_BUFFER_SIZE];

just found there is a compile warning for this variable, will fix it and send out v2 patch, thanks.

> +    snprintf(name_buffer, NAME_BUFFER_SIZE, "pad%d", layer);


More information about the ffmpeg-devel mailing list