Skip to content

Commit

Permalink
add paddle op ceil (#12368)
Browse files Browse the repository at this point in the history
Co-authored-by: cecilia peng <cecilia.peng@intel.com>
  • Loading branch information
Patrick-Star125 and ceciliapeng2011 authored Sep 29, 2022
1 parent df62404 commit fbd53ec
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/tests/frontend/paddle/op_fuzzy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static const std::vector<std::string> models{
std::string("bilinear_upsample_scales2"),
std::string("bilinear_upsample_true_0"),
std::string("bmm"),
std::string("ceil"),
std::string("clip"),
std::string("conv2d_dilation_assymetric_pads_strides"),
std::string("conv2d_SAME_padding"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (C) 2018-2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

#
# ceil paddle model generator
#
import numpy as np
from save_model import saveModel
import sys

def ceil(name: str, x, dtype="float32"):
import paddle
paddle.enable_static()

with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()):
node_x = paddle.static.data(name='x', shape=x.shape, dtype=dtype)
out = paddle.ceil(node_x)

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={'x': x},
fetch_list=[out])

saveModel(name, exe, feedkeys=['x'], fetchlist=[out], inputs=[x], outputs=[outs[0]], target_dir=sys.argv[1])

return outs[0]


def main():
dtype = "float32"
data = np.random.random([2, 3]).astype("float32")
ceil("ceil", data, dtype)


if __name__ == "__main__":
main()
19 changes: 19 additions & 0 deletions src/frontends/paddle/src/op/ceil.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "default_opset.hpp"
#include "openvino/frontend/paddle/node_context.hpp"

namespace ov {
namespace frontend {
namespace paddle {
namespace op {
NamedOutputs ceil(const NodeContext& node) {
return node.default_single_output_mapping({std::make_shared<default_opset::Ceiling>(node.get_input("X"))}, {"Out"});
}

} // namespace op
} // namespace paddle
} // namespace frontend
} // namespace ov
2 changes: 2 additions & 0 deletions src/frontends/paddle/src/op_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ OP_CONVERTER(batch_norm);
OP_CONVERTER(bicubic_interp_v2);
OP_CONVERTER(bilinear_interp_v2);
OP_CONVERTER(cast);
OP_CONVERTER(ceil);
OP_CONVERTER(clip);
OP_CONVERTER(concat);
OP_CONVERTER(conv2d);
Expand Down Expand Up @@ -111,6 +112,7 @@ std::map<std::string, CreatorFunction> get_supported_ops() {
{"bilinear_interp", op::bilinear_interp_v2},
{"bmm", op::matmul},
{"cast", op::cast},
{"ceil", op::ceil},
{"clip", op::clip},
{"concat", op::concat},
{"conv2d", op::conv2d},
Expand Down

0 comments on commit fbd53ec

Please sign in to comment.