Skip to content

Commit

Permalink
Refactor Round, Square, and unary operation translators
Browse files Browse the repository at this point in the history
Signed-off-by: Kazantsev, Roman <[email protected]>
  • Loading branch information
rkazants committed Nov 12, 2023
1 parent d095f36 commit 8b61e3c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/frontends/tensorflow_common/src/op/round.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "openvino/op/round.hpp"

#include "common_op_table.hpp"
#include "openvino/opsets/opset8.hpp"

using namespace std;
using namespace ov::opset8;
using namespace ov::op;

namespace ov {
namespace frontend {
namespace tensorflow {
namespace op {

OutputVector translate_round_op(const NodeContext& node) {
default_op_checks(node, 1, {"Round", "ROUND"});

auto input = node.get_input(0);
// using default round mode "half_to_even" in openvino,
// as TF has only that mode
auto round_mode = Round::RoundMode::HALF_TO_EVEN;
auto res = make_shared<Round>(input, round_mode);
auto round_mode = v5::Round::RoundMode::HALF_TO_EVEN;
auto res = make_shared<v5::Round>(input, round_mode);
set_node_name(node.get_name(), res);
return res->outputs();
}
Expand Down
8 changes: 5 additions & 3 deletions src/frontends/tensorflow_common/src/op/square.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
//

#include "common_op_table.hpp"
#include "openvino/opsets/opset8.hpp"
#include "openvino/op/multiply.hpp"

using namespace std;
using namespace ov::opset8;
using namespace ov::op;

namespace ov {
namespace frontend {
namespace tensorflow {
namespace op {

OutputVector translate_square_op(const NodeContext& node) {
default_op_checks(node, 1, {"Square", "SQUARE"});

auto n = node.get_input(0);
auto res = make_shared<Multiply>(n, n);
auto res = make_shared<v1::Multiply>(n, n);
set_node_name(node.get_name(), res);
return res->outputs();
}
Expand Down
2 changes: 2 additions & 0 deletions src/frontends/tensorflow_common/src/op/unary_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ namespace op {

OutputVector translate_unary_op(const NodeContext& op,
const function<shared_ptr<Node>(Output<Node>)>& create_unary_op) {
default_op_checks(op, 1, {});

auto input = op.get_input(0);
auto res = create_unary_op(input);
set_node_name(op.get_name(), res);
Expand Down

0 comments on commit 8b61e3c

Please sign in to comment.