diff --git a/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp b/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp index dcd068434d5..a2c22983f01 100644 --- a/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp +++ b/ngraph/frontend/paddlepaddle/src/op/pool2d.cpp @@ -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(2, 0); if (kernel_shape.size() == 1) { @@ -187,4 +185,4 @@ NamedOutputs pool2d(const NodeContext& node) { } // namespace op } // namespace pdpd } // namespace frontend -} // namespace ngraph \ No newline at end of file +} // namespace ngraph diff --git a/ngraph/test/frontend/paddlepaddle/convert_model.cpp b/ngraph/test/frontend/paddlepaddle/convert_model.cpp index b7b207b755f..d3a68116e39 100644 --- a/ngraph/test/frontend/paddlepaddle/convert_model.cpp +++ b/ngraph/test/frontend/paddlepaddle/convert_model.cpp @@ -18,6 +18,7 @@ static const std::vector 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, diff --git a/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_dynamic_pool2d.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_dynamic_pool2d.py new file mode 100644 index 00000000000..7a10194599b --- /dev/null +++ b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_dynamic_pool2d.py @@ -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])