> -----Original Message----- > From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of Guo, > Yejun > Sent: Monday, August 3, 2020 10:20 AM > To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH V3 1/2] dnn/native: add native support for > avg_pool > > > > > -----Original Message----- > > From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of Ting > > Fu > > Sent: 2020年7月30日 18:03 > > To: ffmpeg-devel@ffmpeg.org > > Subject: [FFmpeg-devel] [PATCH V3 1/2] dnn/native: add native support > > for avg_pool > > > > Not support pooling strides in channel dimension now. > > 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_odd.jpg') 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') x_pool = tf.nn.avg_pool(x, ksize=[1,2,2,1], > > strides=[1,2,2,1], padding='SAME') > > I don't see input/output channel is set in this function parameter, why we > need > them in struct AvgPoolParams?
Hi Yejun, The in/out_channel in struct AvgPoolParams are for assert() the channel of input image is equal to model params. If read image with rgba then the native will not process correctly, so I think this part is necessary. > [...] > > + if (avgpool_params->padding_method == SAME) { > > + height_end = height; > > + width_end = width; > > + height_radius = avgpool_params->kernel_size - ((height - 1) % > > kernel_strides + 1); > > + width_radius = avgpool_params->kernel_size - ((width - 1) % > > kernel_strides + 1); > > + height_radius = height_radius < 0 ? 0 : height_radius >> 1; > > + width_radius = width_radius < 0 ? 0 : width_radius >> 1; > > + output_height = ceil(height / (kernel_strides * 1.0)); > > + output_width = ceil(width / (kernel_strides * 1.0)); > > + } else { > [] > add an assert here, since avg_pool only accepts 'VALID' or 'SAME', while > padding_method has three enum. > avassert0(padding_method==VALID) > Sure, will add in patch V4. > > + height_end = height - avgpool_params->kernel_size + 1; [...] > > diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.h > > b/libavfilter/dnn/dnn_backend_native_layer_avgpool.h > > new file mode 100644 > > index 0000000000..0b37a8f64b > > --- /dev/null > > +++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.h > > @@ -0,0 +1,35 @@ > > +/* > > + * Copyright (c) 2018 Sergey Lavrushkin > [] > remove name here Sorry, will modify in next patch version. Thank you for your review. Ting FU > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org > with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".