未验证 提交 d1ab323f 编写于 作者: F feng_shuai 提交者: GitHub

fix: when ceil_model==true && Padding_algo!=SAME, (x-size)/stride != int, this...

fix: when ceil_model==true && Padding_algo!=SAME, (x-size)/stride != int, this convert is wrong (#37929)
上级 52f63cd2
...@@ -162,20 +162,6 @@ class Pool2dOpConverter : public OpConverter { ...@@ -162,20 +162,6 @@ class Pool2dOpConverter : public OpConverter {
} }
layer = pool_layer; layer = pool_layer;
} else if (!adaptive && !global_pooling && ceil_mode) { } else if (!adaptive && !global_pooling && ceil_mode) {
nvinfer1::DimsHW pre_pad(0, 0);
nvinfer1::DimsHW post_pad(0, 0);
// If ceil mode is true, we will pad the appropriate size to the input.
DealCeilMode(input_shape, ksize, strides, paddings, &pre_pad, &post_pad,
input_dims);
auto *pad_layer = TRT_ENGINE_ADD_LAYER(
engine_, Padding, *const_cast<nvinfer1::ITensor *>(input1), pre_pad,
post_pad);
PADDLE_ENFORCE_NOT_NULL(
pad_layer, platform::errors::Fatal(
"Pad layer in poolOp converter could not be "
"created. The pointer to pad layer is `NULL`."));
input1 = pad_layer->getOutput(0);
auto *pool_layer = TRT_ENGINE_ADD_LAYER(engine_, Pooling, *input1, auto *pool_layer = TRT_ENGINE_ADD_LAYER(engine_, Pooling, *input1,
nv_pool_type, nv_ksize); nv_pool_type, nv_ksize);
pool_layer->setStride(nv_strides); pool_layer->setStride(nv_strides);
...@@ -183,6 +169,8 @@ class Pool2dOpConverter : public OpConverter { ...@@ -183,6 +169,8 @@ class Pool2dOpConverter : public OpConverter {
pool_layer->setAverageCountExcludesPadding(exclusive); pool_layer->setAverageCountExcludesPadding(exclusive);
if (padding_algorithm == "SAME") { if (padding_algorithm == "SAME") {
pool_layer->setPaddingMode(nvinfer1::PaddingMode::kSAME_UPPER); pool_layer->setPaddingMode(nvinfer1::PaddingMode::kSAME_UPPER);
} else {
pool_layer->setPaddingMode(nvinfer1::PaddingMode::kEXPLICIT_ROUND_UP);
} }
layer = pool_layer; layer = pool_layer;
} else if (global_pooling) { } else if (global_pooling) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册