remove adaptive pool2d shape check in ngraph paddle frontend (#7074)

* remove adaptive pool2d shape check in ngraph paddle frontend

* add ngraph paddle frontend dynamic pool2d test
This commit is contained in:
mei, yang authored and GitHub committed 2021-08-25 06:39:59 +03:00
1 parent 9228200ce5
commit 192cb26c5b
3 files changed
+34 -3

No files matched your search

@@ -100,8 +100,6 @@ NamedOutputs pool2d(const NodeContext& node) {
{"Out"});
}
} else if (adaptive) {
PDPD_ASSERT(input_shape[2].is_static() && input_shape[3].is_static(),
"pool2d: spatial dim must be static when using adaptive pool");
auto pool_size = std::vector<int64_t>(2, 0);
if (kernel_shape.size() == 1) {
@@ -187,4 +185,4 @@ NamedOutputs pool2d(const NodeContext& node) {
} // namespace op
} // namespace pdpd
} // namespace frontend
} // namespace ngraph
} // namespace ngraph
@@ -18,6 +18,7 @@ static const std::vector<std::string> models{
std::string("2in_2out/2in_2out.pdmodel"),
std::string("multi_tensor_split/multi_tensor_split.pdmodel"),
std::string("2in_2out_dynbatch/2in_2out_dynbatch.pdmodel"),
std::string("pool2d_dyn_hw/pool2d_dyn_hw.pdmodel"),
};
INSTANTIATE_TEST_SUITE_P(PDPDConvertModelTest,
@@ -0,0 +1,32 @@
#
# pool2d paddle dynamic model generator
#
import paddle
from paddle import fluid
import numpy as np
import sys
import os
from save_model import saveModel
paddle.enable_static()
inp_blob1 = np.random.randn(1, 1, 224, 224).astype(np.float32)
x1 = fluid.data(name='inputX1', shape=[1, 1, -1, -1], dtype='float32')
adative_pool2d = paddle.fluid.layers.adaptive_pool2d(
input=x1,
pool_size=[3,3],
pool_type='avg',
require_index=False)
cpu = paddle.static.cpu_places(1)
exe = paddle.static.Executor(cpu[0])
# startup program will call initializer to initialize the parameters.
exe.run(paddle.static.default_startup_program())
outs = exe.run(
feed={'inputX1': inp_blob1},
fetch_list=[adative_pool2d])
saveModel("pool2d_dyn_hw", exe, feedkeys=['inputX1'], fetchlist=adative_pool2d, inputs=[inp_blob1], outputs=outs, target_dir=sys.argv[1])