enable sin/cos && fix top_k_v2 (#17525)
This commit is contained in:
parent
49c4c922ff
commit
36b9de1f25
19
src/frontends/paddle/src/op/cos.cpp
Normal file
19
src/frontends/paddle/src/op/cos.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (C) 2018-2023 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 cos(const NodeContext& node) {
|
||||||
|
return node.default_single_output_mapping({std::make_shared<default_opset::Cos>(node.get_input("X"))}, {"Out"});
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace op
|
||||||
|
} // namespace paddle
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace ov
|
19
src/frontends/paddle/src/op/sin.cpp
Normal file
19
src/frontends/paddle/src/op/sin.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (C) 2018-2023 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 sin(const NodeContext& node) {
|
||||||
|
return node.default_single_output_mapping({std::make_shared<default_opset::Sin>(node.get_input("X"))}, {"Out"});
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace op
|
||||||
|
} // namespace paddle
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace ov
|
@ -27,7 +27,7 @@ NamedOutputs top_k_v2(const NodeContext& node) {
|
|||||||
std::string sort_type = sorted ? "value" : "none";
|
std::string sort_type = sorted ? "value" : "none";
|
||||||
std::string mode = largest ? "max" : "min";
|
std::string mode = largest ? "max" : "min";
|
||||||
|
|
||||||
auto node_topk = std::make_shared<default_opset::TopK>(x, k_expected_node, axis, mode, sort_type);
|
auto node_topk = std::make_shared<default_opset::TopK>(x, k_expected_node, axis, mode, sort_type, element::i64);
|
||||||
|
|
||||||
NamedOutputs named_outputs;
|
NamedOutputs named_outputs;
|
||||||
named_outputs["Out"] = OutputVector{node_topk->output(0)};
|
named_outputs["Out"] = OutputVector{node_topk->output(0)};
|
||||||
|
@ -22,6 +22,7 @@ OP_CONVERTER(concat);
|
|||||||
OP_CONVERTER(conditional_block);
|
OP_CONVERTER(conditional_block);
|
||||||
OP_CONVERTER(conv2d);
|
OP_CONVERTER(conv2d);
|
||||||
OP_CONVERTER(conv2d_transpose);
|
OP_CONVERTER(conv2d_transpose);
|
||||||
|
OP_CONVERTER(cos);
|
||||||
OP_CONVERTER(cumsum);
|
OP_CONVERTER(cumsum);
|
||||||
OP_CONVERTER(deformable_conv);
|
OP_CONVERTER(deformable_conv);
|
||||||
OP_CONVERTER(dequantize_linear);
|
OP_CONVERTER(dequantize_linear);
|
||||||
@ -100,6 +101,7 @@ OP_CONVERTER(shape);
|
|||||||
OP_CONVERTER(share_data);
|
OP_CONVERTER(share_data);
|
||||||
OP_CONVERTER(sigmoid);
|
OP_CONVERTER(sigmoid);
|
||||||
OP_CONVERTER(silu);
|
OP_CONVERTER(silu);
|
||||||
|
OP_CONVERTER(sin);
|
||||||
OP_CONVERTER(slice);
|
OP_CONVERTER(slice);
|
||||||
OP_CONVERTER(softmax);
|
OP_CONVERTER(softmax);
|
||||||
OP_CONVERTER(softplus);
|
OP_CONVERTER(softplus);
|
||||||
@ -142,6 +144,7 @@ std::map<std::string, CreatorFunction> get_supported_ops() {
|
|||||||
{"conditional_block", op::conditional_block},
|
{"conditional_block", op::conditional_block},
|
||||||
{"conv2d", op::conv2d},
|
{"conv2d", op::conv2d},
|
||||||
{"conv2d_transpose", op::conv2d_transpose},
|
{"conv2d_transpose", op::conv2d_transpose},
|
||||||
|
{"cos", op::cos},
|
||||||
{"cumsum", op::cumsum},
|
{"cumsum", op::cumsum},
|
||||||
{"deformable_conv", op::deformable_conv},
|
{"deformable_conv", op::deformable_conv},
|
||||||
{"deformable_conv_v1", op::deformable_conv},
|
{"deformable_conv_v1", op::deformable_conv},
|
||||||
@ -226,6 +229,7 @@ std::map<std::string, CreatorFunction> get_supported_ops() {
|
|||||||
{"share_data", op::share_data},
|
{"share_data", op::share_data},
|
||||||
{"sigmoid", op::sigmoid},
|
{"sigmoid", op::sigmoid},
|
||||||
{"silu", op::silu},
|
{"silu", op::silu},
|
||||||
|
{"sin", op::sin},
|
||||||
{"slice", op::slice},
|
{"slice", op::slice},
|
||||||
{"softmax", op::softmax},
|
{"softmax", op::softmax},
|
||||||
{"softplus", op::softplus},
|
{"softplus", op::softplus},
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "common_test_utils/ngraph_test_utils.hpp"
|
#include "common_test_utils/ngraph_test_utils.hpp"
|
||||||
#include "paddle_utils.hpp"
|
#include "paddle_utils.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
#include "openvino/opsets/opset6.hpp"
|
||||||
|
|
||||||
using namespace ngraph;
|
using namespace ngraph;
|
||||||
using namespace ov::frontend;
|
using namespace ov::frontend;
|
||||||
@ -32,7 +33,7 @@ TEST(FrontEndConvertModelTest, test_unsupported_op) {
|
|||||||
|
|
||||||
for (auto& node : function->get_ordered_ops()) {
|
for (auto& node : function->get_ordered_ops()) {
|
||||||
if (node->get_friendly_name() == "rxyz_0.tmp_0") {
|
if (node->get_friendly_name() == "rxyz_0.tmp_0") {
|
||||||
function->replace_node(node, std::make_shared<opset6::Relu>(node->input(0).get_source_output()));
|
function->replace_node(node, std::make_shared<ov::opset6::Relu>(node->input(0).get_source_output()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSERT_NO_THROW(frontEnd->convert(function));
|
ASSERT_NO_THROW(frontEnd->convert(function));
|
||||||
|
@ -111,6 +111,7 @@ static const std::vector<std::string> models{
|
|||||||
std::string("conv2d_transpose_strides_padding/conv2d_transpose_strides_padding.pdmodel"),
|
std::string("conv2d_transpose_strides_padding/conv2d_transpose_strides_padding.pdmodel"),
|
||||||
std::string("conv2d_transpose_VALID_padding/conv2d_transpose_VALID_padding.pdmodel"),
|
std::string("conv2d_transpose_VALID_padding/conv2d_transpose_VALID_padding.pdmodel"),
|
||||||
std::string("conv2d_VALID_padding/conv2d_VALID_padding.pdmodel"),
|
std::string("conv2d_VALID_padding/conv2d_VALID_padding.pdmodel"),
|
||||||
|
std::string("cos"),
|
||||||
std::string("cumsum"),
|
std::string("cumsum"),
|
||||||
std::string("cumsum_i32"),
|
std::string("cumsum_i32"),
|
||||||
std::string("cumsum_i64"),
|
std::string("cumsum_i64"),
|
||||||
@ -493,6 +494,7 @@ static const std::vector<std::string> models{
|
|||||||
std::string("silu_dynamic_test2"),
|
std::string("silu_dynamic_test2"),
|
||||||
std::string("silu_dynamic_test3"),
|
std::string("silu_dynamic_test3"),
|
||||||
std::string("silu_dynamic_test4"),
|
std::string("silu_dynamic_test4"),
|
||||||
|
std::string("sin"),
|
||||||
std::string("slice"),
|
std::string("slice"),
|
||||||
std::string("slice_1d"),
|
std::string("slice_1d"),
|
||||||
std::string("slice_decrease_axis/slice_decrease_axis.pdmodel"),
|
std::string("slice_decrease_axis/slice_decrease_axis.pdmodel"),
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
# Copyright (C) 2018-2023 Intel Corporation
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
#
|
||||||
|
# tanh paddle model generator
|
||||||
|
#
|
||||||
|
import numpy as np
|
||||||
|
from save_model import saveModel
|
||||||
|
import paddle
|
||||||
|
import sys
|
||||||
|
|
||||||
|
data_type = 'float32'
|
||||||
|
|
||||||
|
def cos(name:str, x):
|
||||||
|
paddle.enable_static()
|
||||||
|
|
||||||
|
with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()):
|
||||||
|
data = paddle.static.data(name='x', shape=x.shape, dtype = data_type)
|
||||||
|
out = paddle.sin(data)
|
||||||
|
|
||||||
|
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():
|
||||||
|
x = np.random.uniform(-1000,1000, (8, 24, 32)).astype(data_type)
|
||||||
|
|
||||||
|
cos("cos", x)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -0,0 +1,40 @@
|
|||||||
|
# Copyright (C) 2018-2023 Intel Corporation
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
#
|
||||||
|
# tanh paddle model generator
|
||||||
|
#
|
||||||
|
import numpy as np
|
||||||
|
from save_model import saveModel
|
||||||
|
import paddle
|
||||||
|
import sys
|
||||||
|
|
||||||
|
data_type = 'float32'
|
||||||
|
|
||||||
|
def sin(name:str, x):
|
||||||
|
paddle.enable_static()
|
||||||
|
|
||||||
|
with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()):
|
||||||
|
data = paddle.static.data(name='x', shape=x.shape, dtype = data_type)
|
||||||
|
out = paddle.sin(data)
|
||||||
|
|
||||||
|
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():
|
||||||
|
x = np.random.uniform(-1000,1000, (8, 24, 32)).astype(data_type)
|
||||||
|
|
||||||
|
sin("sin", x)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user