From eb32746a43f3c8c66f61c0ab58f191bd5796c6f3 Mon Sep 17 00:00:00 2001 From: Wang Bojun <105858416+wwbitejotunn@users.noreply.github.com> Date: Fri, 14 Oct 2022 14:37:35 +0800 Subject: [PATCH] TRT pool2d adaptive mode bugfix (#46802) * draft with debug print --- paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.cu | 8 ++++---- paddle/phi/kernels/funcs/pooling.cu | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.cu index 21eb89d135..52959d8f90 100644 --- a/paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.cu @@ -321,16 +321,16 @@ int PoolPluginDynamic::enqueue(const nvinfer1::PluginTensorDesc *input_desc, paddings[1] = 0; output_shape[2] = 1; output_shape[3] = 1; + if (adaptive_) { + output_shape[2] = h; + output_shape[3] = w; + } } else { auto data_dim = CalcOutputSize( {h, w}, ceil_mode_, adaptive_, ksize_, strides_, paddings_); output_shape[2] = data_dim[0]; output_shape[3] = data_dim[1]; } - if (adaptive_) { - output_shape[2] = h; - output_shape[3] = w; - } if (pool_type_ == "max") { phi::funcs::MaxPool pool_process; diff --git a/paddle/phi/kernels/funcs/pooling.cu b/paddle/phi/kernels/funcs/pooling.cu index 875fa92002..a1bb927b73 100644 --- a/paddle/phi/kernels/funcs/pooling.cu +++ b/paddle/phi/kernels/funcs/pooling.cu @@ -460,7 +460,6 @@ void Pool2dDirectCUDAFunctor::operator()( const int stride_width = strides[1]; const int padding_height = paddings[0]; const int padding_width = paddings[1]; - int nthreads = batch_size * output_channels * output_height * output_width; auto pool_divmods = FastDivModForPooling(input_channels, output_width, output_height); @@ -491,6 +490,7 @@ void Pool2dDirectCUDAFunctor::operator()( pool_compute, exclusive, output); + } else { int thread_num = 1024; #ifdef WITH_NV_JETSON -- GitLab