Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【PaddlePaddle Hackathon 3】Add Paddle ceil operator #12368

Merged
merged 6 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -105,6 +106,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