From 0fb6bca45d3d6c879a55d5cd5c388da713eec780 Mon Sep 17 00:00:00 2001 From: Wei Shengyu Date: Mon, 7 Mar 2022 14:11:28 +0800 Subject: [PATCH] fix infer shapes of pool_with_index (#40139) * dbg pool infer shapes * dbg * fix format --- paddle/fluid/operators/pool_with_index_op.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/pool_with_index_op.cc b/paddle/fluid/operators/pool_with_index_op.cc index e0c24935b4..d061f9ae05 100644 --- a/paddle/fluid/operators/pool_with_index_op.cc +++ b/paddle/fluid/operators/pool_with_index_op.cc @@ -81,8 +81,12 @@ class MaxPoolWithIndexOp : public framework::OperatorWithKernel { output_shape.insert(output_shape.end(), ksize.begin(), ksize.end()); } else { for (size_t i = 0; i < ksize.size(); ++i) { - output_shape.push_back(MaxPoolOutputSize(in_x_dims[i + 2], ksize[i], - paddings[i], strides[i])); + if ((!ctx->IsRuntime()) && (in_x_dims[i + 2] < 0)) { + output_shape.push_back(in_x_dims[i + 2]); + } else { + output_shape.push_back(MaxPoolOutputSize(in_x_dims[i + 2], ksize[i], + paddings[i], strides[i])); + } } } ctx->SetOutputDim("Out", phi::make_ddim(output_shape)); -- GitLab