From 9334f34ff07a8a139f4dfc90abac3e17d710c1cc Mon Sep 17 00:00:00 2001 From: Ivan Tikhonov Date: Tue, 21 Dec 2021 14:35:58 +0300 Subject: [PATCH] TensorFlow FrontEnd Refactoring (#9173) * Move tensorflow fe to openvino subfolder; renaming; refactoring * codestyle * delete redundant file * fix Win build * fix missprint --- .../frontend/tensorflow/transpose_sinking.cpp | 26 ++-- .../frontend/tensorflow}/decoder.hpp | 10 +- .../frontend/tensorflow}/frontend.hpp | 18 ++- .../frontend/tensorflow}/graph_iterator.hpp | 10 +- .../frontend/tensorflow/visibility.hpp} | 12 +- .../tensorflow/src/decoder_proto.cpp | 20 +-- .../tensorflow/src/decoder_proto.hpp | 10 +- src/frontends/tensorflow/src/exceptions.cpp | 6 +- src/frontends/tensorflow/src/exceptions.hpp | 16 +-- src/frontends/tensorflow/src/frontend.cpp | 88 ++++++------- .../tensorflow/src/graph_iterator_proto.hpp | 13 +- .../src/{model.cpp => input_model.cpp} | 115 ++++++++--------- .../src/{model.hpp => input_model.hpp} | 21 ++-- src/frontends/tensorflow/src/node_context.hpp | 6 +- src/frontends/tensorflow/src/op/addN.cpp | 4 +- .../tensorflow/src/op/arg_min_max.cpp | 8 +- src/frontends/tensorflow/src/op/avg_pool.cpp | 10 +- src/frontends/tensorflow/src/op/bias_add.cpp | 12 +- src/frontends/tensorflow/src/op/binary_op.cpp | 4 +- src/frontends/tensorflow/src/op/cast.cpp | 4 +- src/frontends/tensorflow/src/op/concat.cpp | 8 +- src/frontends/tensorflow/src/op/const.cpp | 6 +- src/frontends/tensorflow/src/op/conv_2d.cpp | 16 +-- .../tensorflow/src/op/conv_2d_backprop.cpp | 10 +- src/frontends/tensorflow/src/op/conv_3d.cpp | 10 +- .../tensorflow/src/op/crop_and_resize.cpp | 18 +-- src/frontends/tensorflow/src/op/cumsum.cpp | 4 +- .../tensorflow/src/op/depth_to_space.cpp | 10 +- .../tensorflow/src/op/depthwise_conv_2d.cpp | 10 +- src/frontends/tensorflow/src/op/elu.cpp | 4 +- .../tensorflow/src/op/expand_dims.cpp | 4 +- .../src/op/fake_quant_min_max_vars.cpp | 4 +- src/frontends/tensorflow/src/op/fill.cpp | 4 +- .../tensorflow/src/op/fused_batch_norm.cpp | 6 +- src/frontends/tensorflow/src/op/gather.cpp | 4 +- src/frontends/tensorflow/src/op/identity.cpp | 4 +- .../tensorflow/src/op/interpolate.cpp | 4 +- src/frontends/tensorflow/src/op/is_finite.cpp | 4 +- src/frontends/tensorflow/src/op/l2_loss.cpp | 4 +- .../tensorflow/src/op/leaky_relu.cpp | 4 +- src/frontends/tensorflow/src/op/log1p.cpp | 4 +- .../tensorflow/src/op/log_softmax.cpp | 4 +- src/frontends/tensorflow/src/op/lrn.cpp | 4 +- src/frontends/tensorflow/src/op/matmul.cpp | 4 +- src/frontends/tensorflow/src/op/max_pool.cpp | 6 +- src/frontends/tensorflow/src/op/no_op.cpp | 10 +- .../tensorflow/src/op/non_max_suppression.cpp | 6 +- src/frontends/tensorflow/src/op/one_hot.cpp | 4 +- src/frontends/tensorflow/src/op/pack.cpp | 4 +- src/frontends/tensorflow/src/op/pad.cpp | 16 +-- .../tensorflow/src/op/placeholder.cpp | 4 +- .../tensorflow/src/op/random_uniform.cpp | 4 +- src/frontends/tensorflow/src/op/range.cpp | 4 +- src/frontends/tensorflow/src/op/rank.cpp | 4 +- .../tensorflow/src/op/reciprocal.cpp | 4 +- src/frontends/tensorflow/src/op/reduce.cpp | 12 +- src/frontends/tensorflow/src/op/relu_6.cpp | 4 +- src/frontends/tensorflow/src/op/reshape.cpp | 4 +- src/frontends/tensorflow/src/op/reverse.cpp | 10 +- src/frontends/tensorflow/src/op/roll.cpp | 6 +- src/frontends/tensorflow/src/op/round.cpp | 4 +- src/frontends/tensorflow/src/op/rsqrt.cpp | 4 +- src/frontends/tensorflow/src/op/select.cpp | 6 +- src/frontends/tensorflow/src/op/shape.cpp | 4 +- src/frontends/tensorflow/src/op/size.cpp | 4 +- src/frontends/tensorflow/src/op/slice.cpp | 4 +- src/frontends/tensorflow/src/op/softmax.cpp | 6 +- .../tensorflow/src/op/space_to_batch_nd.cpp | 8 +- .../tensorflow/src/op/space_to_depth.cpp | 6 +- src/frontends/tensorflow/src/op/split.cpp | 4 +- src/frontends/tensorflow/src/op/sqrt.cpp | 4 +- src/frontends/tensorflow/src/op/square.cpp | 4 +- src/frontends/tensorflow/src/op/squeeze.cpp | 4 +- .../tensorflow/src/op/strided_slice.cpp | 4 +- src/frontends/tensorflow/src/op/tile.cpp | 4 +- src/frontends/tensorflow/src/op/top_k.cpp | 12 +- src/frontends/tensorflow/src/op/transpose.cpp | 4 +- src/frontends/tensorflow/src/op/unary_op.cpp | 4 +- src/frontends/tensorflow/src/op/unpack.cpp | 4 +- src/frontends/tensorflow/src/op/where.cpp | 4 +- src/frontends/tensorflow/src/op/xdivy.cpp | 4 +- .../tensorflow/src/op/zeros_like.cpp | 4 +- src/frontends/tensorflow/src/op_table.cpp | 6 +- src/frontends/tensorflow/src/op_table.hpp | 6 +- .../tensorflow/src/openvino_conversions.cpp | 4 +- .../tensorflow/src/openvino_conversions.hpp | 5 +- .../tensorflow/src/pass/transpose_sinking.cpp | 2 +- .../tensorflow/src/pass/transpose_sinking.hpp | 12 +- src/frontends/tensorflow/src/place.cpp | 118 +++++++++--------- src/frontends/tensorflow/src/place.hpp | 83 ++++++------ src/frontends/tensorflow/src/tensorflow.cpp | 9 +- .../tensorflow/src/tf_framework_node.cpp | 6 +- .../tensorflow/src/tf_framework_node.hpp | 16 +-- src/frontends/tensorflow/src/utils.cpp | 7 +- src/frontends/tensorflow/src/utils.hpp | 28 ++--- 95 files changed, 549 insertions(+), 528 deletions(-) rename src/frontends/tensorflow/include/{tensorflow_frontend => openvino/frontend/tensorflow}/decoder.hpp (88%) rename src/frontends/tensorflow/include/{tensorflow_frontend => openvino/frontend/tensorflow}/frontend.hpp (92%) rename src/frontends/tensorflow/include/{tensorflow_frontend => openvino/frontend/tensorflow}/graph_iterator.hpp (82%) rename src/frontends/tensorflow/include/{tensorflow_frontend/utility.hpp => openvino/frontend/tensorflow/visibility.hpp} (50%) rename src/frontends/tensorflow/src/{model.cpp => input_model.cpp} (73%) rename src/frontends/tensorflow/src/{model.hpp => input_model.hpp} (73%) diff --git a/src/core/tests/frontend/tensorflow/transpose_sinking.cpp b/src/core/tests/frontend/tensorflow/transpose_sinking.cpp index 44f50d2c80beb9..40d5765a2ee754 100644 --- a/src/core/tests/frontend/tensorflow/transpose_sinking.cpp +++ b/src/core/tests/frontend/tensorflow/transpose_sinking.cpp @@ -15,7 +15,7 @@ using namespace std; using namespace ov; using namespace opset8; -using namespace frontend::tf::pass; +using namespace frontend::tensorflow::pass; template int64_t count_ops_of_type(const shared_ptr& f) { @@ -27,7 +27,7 @@ int64_t count_ops_of_type(const shared_ptr& f) { } TEST(TransposeSinkingTest, PassProperty) { - auto pass = std::make_shared(); + auto pass = std::make_shared(); ASSERT_TRUE(pass->get_property(ov::pass::PassProperty::REQUIRE_STATIC_SHAPE)); ASSERT_FALSE(pass->get_property(ov::pass::PassProperty::CHANGE_DYNAMIC_STATE)); } @@ -51,7 +51,7 @@ TEST(TransposeSinkingTest, EdgeSplitting) { size_t before_count = count_ops_of_type(func); ov::pass::Manager pass_manager; - pass_manager.register_pass(); + pass_manager.register_pass(); pass_manager.run_passes(func); ASSERT_EQ(before_count, 1); @@ -107,7 +107,7 @@ TEST(TransposeSinkingTest, PoolAdd1) { ov::pass::Manager pass_manager; size_t before_count = count_ops_of_type(func); - pass_manager.register_pass(); + pass_manager.register_pass(); pass_manager.run_passes(func); size_t after_count = count_ops_of_type(func); @@ -159,7 +159,7 @@ TEST(TransposeSinkingTest, PoolAdd2) { ov::pass::Manager pass_manager; size_t before_count = count_ops_of_type(func); // 3 - pass_manager.register_pass(); + pass_manager.register_pass(); pass_manager.run_passes(func); size_t after_count = count_ops_of_type(func); // 4 @@ -171,7 +171,7 @@ TEST(TransposeSinkingTest, PoolAdd2) { ASSERT_EQ(new_transpose->get_output_shape(0), (ngraph::Shape{1, 3, 3, 1})); } -// Different rank constant input to Add1. After TransposeSinkingOVTF the const +// Different rank constant input to Add1. After TransposeSinking the const // would need a Reshape to have the same order as the other input to // Add1. TEST(TransposeSinkingTest, PoolAdd3) { @@ -203,7 +203,7 @@ TEST(TransposeSinkingTest, PoolAdd3) { ov::pass::Manager pass_manager; size_t before_count = count_ops_of_type(func); - pass_manager.register_pass(); + pass_manager.register_pass(); pass_manager.run_passes(func); size_t after_count = count_ops_of_type(func); @@ -228,7 +228,7 @@ TEST(TransposeSinkingTest, Concat) { auto func = make_shared(ngraph::OutputVector{c}, ngraph::ParameterVector{a, b}); ov::pass::Manager pass_manager; - pass_manager.register_pass(); + pass_manager.register_pass(); pass_manager.run_passes(func); size_t transpose_count = count_ops_of_type(func); @@ -260,7 +260,7 @@ TEST(TransposeSinkingTest, Concat_DummyShape) { auto func = make_shared(ngraph::OutputVector{out}, ngraph::ParameterVector{a1, a2, a3, a4}); ov::pass::Manager pass_manager; - pass_manager.register_pass(); + pass_manager.register_pass(); pass_manager.run_passes(func); size_t transpose_count = count_ops_of_type(func); // 1 @@ -306,7 +306,7 @@ TEST(TransposeSinkingTest, Pad) { ov::pass::Manager pass_manager; size_t before_count = count_ops_of_type(func); // 2 - pass_manager.register_pass(); + pass_manager.register_pass(); pass_manager.run_passes(func); size_t after_count = count_ops_of_type(func); // 2 @@ -337,7 +337,7 @@ TEST(TransposeSinkingTest, SimpleUnary) { size_t before_count = count_ops_of_type(func); // 2 ov::pass::Manager pass_manager; - pass_manager.register_pass(); + pass_manager.register_pass(); pass_manager.run_passes(func); size_t after_count = count_ops_of_type(func); // 0 @@ -396,7 +396,7 @@ TEST(TransposeSinkingTest, MultiOutput) { ov::pass::Manager pass_manager; size_t before_count = count_ops_of_type(func); // 3 - pass_manager.register_pass(); + pass_manager.register_pass(); pass_manager.run_passes(func); size_t after_count = count_ops_of_type(func); // 4 @@ -503,7 +503,7 @@ TEST(TransposeSinkingTest, AlexnetPattern) { ov::pass::Manager pass_manager; size_t before_count = count_ops_of_type(func); - pass_manager.register_pass(); + pass_manager.register_pass(); pass_manager.run_passes(func); size_t after_count = count_ops_of_type(func); diff --git a/src/frontends/tensorflow/include/tensorflow_frontend/decoder.hpp b/src/frontends/tensorflow/include/openvino/frontend/tensorflow/decoder.hpp similarity index 88% rename from src/frontends/tensorflow/include/tensorflow_frontend/decoder.hpp rename to src/frontends/tensorflow/include/openvino/frontend/tensorflow/decoder.hpp index 423f030934ca6c..7377f551ad5314 100644 --- a/src/frontends/tensorflow/include/tensorflow_frontend/decoder.hpp +++ b/src/frontends/tensorflow/include/openvino/frontend/tensorflow/decoder.hpp @@ -4,14 +4,14 @@ #pragma once -#include - -#include "tensorflow_frontend/utility.hpp" +#include "openvino/core/any.hpp" +#include "openvino/frontend/tensorflow/visibility.hpp" namespace ov { namespace frontend { +namespace tensorflow { -class TF_API DecoderBase { +class TENSORFLOW_API DecoderBase { public: /// \brief Get attribute value by name and requested type /// @@ -41,5 +41,7 @@ class TF_API DecoderBase { /// \brief Destructor virtual ~DecoderBase() = default; }; + +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/include/tensorflow_frontend/frontend.hpp b/src/frontends/tensorflow/include/openvino/frontend/tensorflow/frontend.hpp similarity index 92% rename from src/frontends/tensorflow/include/tensorflow_frontend/frontend.hpp rename to src/frontends/tensorflow/include/openvino/frontend/tensorflow/frontend.hpp index 274f47bd041072..d1d9d50ee36159 100644 --- a/src/frontends/tensorflow/include/tensorflow_frontend/frontend.hpp +++ b/src/frontends/tensorflow/include/openvino/frontend/tensorflow/frontend.hpp @@ -13,28 +13,24 @@ #include "openvino/frontend/extension/telemetry.hpp" #include "openvino/frontend/frontend.hpp" #include "openvino/frontend/input_model.hpp" -#include "tensorflow_frontend/utility.hpp" +#include "openvino/frontend/tensorflow/visibility.hpp" namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { + class NodeContext; -} -} // namespace frontend -} // namespace ov -namespace ov { -namespace frontend { -class TF_API FrontEndTF : public ov::frontend::FrontEnd { +class TENSORFLOW_API FrontEnd : public ov::frontend::FrontEnd { public: - using CreatorFunction = std::function<::ov::OutputVector(const ::ov::frontend::tf::NodeContext&)>; + using CreatorFunction = std::function<::ov::OutputVector(const ::ov::frontend::tensorflow::NodeContext&)>; using TranslatorDictionaryType = std::map; private: TranslatorDictionaryType m_op_translators; public: - FrontEndTF(); + FrontEnd(); /// \brief Completely convert the model /// \return fully converted ov Model @@ -86,5 +82,7 @@ class TF_API FrontEndTF : public ov::frontend::FrontEnd { std::shared_ptr m_telemetry; std::vector> m_transformation_extensions; }; + +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/include/tensorflow_frontend/graph_iterator.hpp b/src/frontends/tensorflow/include/openvino/frontend/tensorflow/graph_iterator.hpp similarity index 82% rename from src/frontends/tensorflow/include/tensorflow_frontend/graph_iterator.hpp rename to src/frontends/tensorflow/include/openvino/frontend/tensorflow/graph_iterator.hpp index de8a548fd14014..0c2f0628fb4555 100644 --- a/src/frontends/tensorflow/include/tensorflow_frontend/graph_iterator.hpp +++ b/src/frontends/tensorflow/include/openvino/frontend/tensorflow/graph_iterator.hpp @@ -5,13 +5,15 @@ #pragma once #include "openvino/core/any.hpp" -#include "tensorflow_frontend/decoder.hpp" -#include "tensorflow_frontend/utility.hpp" +#include "openvino/frontend/tensorflow/decoder.hpp" +#include "openvino/frontend/visibility.hpp" namespace ov { namespace frontend { +namespace tensorflow { + /// Abstract representation for an input model graph that gives nodes in topologically sorted order -class TF_API GraphIterator : ov::RuntimeAttribute { +class TENSORFLOW_API GraphIterator : ov::RuntimeAttribute { public: OPENVINO_RTTI("Variant::GraphIterator"); @@ -35,5 +37,7 @@ class TF_API GraphIterator : ov::RuntimeAttribute { /// \brief Destructor virtual ~GraphIterator() = default; }; + +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/include/tensorflow_frontend/utility.hpp b/src/frontends/tensorflow/include/openvino/frontend/tensorflow/visibility.hpp similarity index 50% rename from src/frontends/tensorflow/include/tensorflow_frontend/utility.hpp rename to src/frontends/tensorflow/include/openvino/frontend/tensorflow/visibility.hpp index ed07e8fe4a234f..578e7b7748093c 100644 --- a/src/frontends/tensorflow/include/tensorflow_frontend/utility.hpp +++ b/src/frontends/tensorflow/include/openvino/frontend/tensorflow/visibility.hpp @@ -7,14 +7,14 @@ #include "openvino/frontend/exception.hpp" #ifdef OPENVINO_STATIC_LIBRARY -# define TF_API -# define TF_C_API +# define TENSORFLOW_API +# define TENSORFLOW_C_API #else # ifdef ov_tensorflow_frontend_EXPORTS -# define TF_API OPENVINO_CORE_EXPORTS -# define TF_C_API OPENVINO_EXTERN_C OPENVINO_CORE_EXPORTS +# define TENSORFLOW_API OPENVINO_CORE_EXPORTS +# define TENSORFLOW_C_API OPENVINO_EXTERN_C OPENVINO_CORE_EXPORTS # else -# define TF_API OPENVINO_CORE_IMPORTS -# define TF_C_API OPENVINO_EXTERN_C OPENVINO_CORE_IMPORTS +# define TENSORFLOW_API OPENVINO_CORE_IMPORTS +# define TENSORFLOW_C_API OPENVINO_EXTERN_C OPENVINO_CORE_IMPORTS # endif // ov_tensorflow_frontend_EXPORTS #endif // OPENVINO_STATIC_LIBRARY diff --git a/src/frontends/tensorflow/src/decoder_proto.cpp b/src/frontends/tensorflow/src/decoder_proto.cpp index 5a7a26c435631b..c51c21382dbdd1 100644 --- a/src/frontends/tensorflow/src/decoder_proto.cpp +++ b/src/frontends/tensorflow/src/decoder_proto.cpp @@ -8,7 +8,7 @@ namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace { const std::map<::tensorflow::DataType, ov::element::Type>& TYPE_MAP() { @@ -27,7 +27,7 @@ const std::map<::tensorflow::DataType, ov::element::Type>& TYPE_MAP() { } } // namespace -ov::Any DecoderTFProto::get_attribute(const std::string& name, const std::type_info& type_info) const { +ov::Any DecoderProto::get_attribute(const std::string& name, const std::type_info& type_info) const { auto attrs = decode_attribute_helper(name); if (attrs.empty()) { return {}; @@ -85,13 +85,13 @@ ov::Any DecoderTFProto::get_attribute(const std::string& name, const std::type_i return {}; } -size_t DecoderTFProto::get_input_size() const { +size_t DecoderProto::get_input_size() const { return m_node_def->input_size(); } -void DecoderTFProto::get_input_node(size_t input_port_idx, - std::string& producer_name, - size_t& producer_output_port_index) const { +void DecoderProto::get_input_node(size_t input_port_idx, + std::string& producer_name, + size_t& producer_output_port_index) const { // TODO: handle body graph nodes with a couple of columns std::string producer_port_name = m_node_def->input(input_port_idx); auto delim_pos = producer_port_name.find(':'); @@ -104,15 +104,15 @@ void DecoderTFProto::get_input_node(size_t input_port_idx, producer_output_port_index = 0; } -const std::string& DecoderTFProto::get_op_type() const { +const std::string& DecoderProto::get_op_type() const { return m_node_def->op(); } -const std::string& DecoderTFProto::get_op_name() const { +const std::string& DecoderProto::get_op_name() const { return m_node_def->name(); } -std::vector<::tensorflow::AttrValue> DecoderTFProto::decode_attribute_helper(const std::string& name) const { +std::vector<::tensorflow::AttrValue> DecoderProto::decode_attribute_helper(const std::string& name) const { auto attr_map = m_node_def->attr(); FRONT_END_GENERAL_CHECK(attr_map.contains(name), "An error occurred while parsing the ", @@ -123,6 +123,6 @@ std::vector<::tensorflow::AttrValue> DecoderTFProto::decode_attribute_helper(con auto value = m_node_def->attr().at(name); return {value}; } -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/decoder_proto.hpp b/src/frontends/tensorflow/src/decoder_proto.hpp index a0871b20aa7dd2..f5e664185a9112 100644 --- a/src/frontends/tensorflow/src/decoder_proto.hpp +++ b/src/frontends/tensorflow/src/decoder_proto.hpp @@ -9,16 +9,16 @@ #include "attr_value.pb.h" #include "node_def.pb.h" -#include "tensorflow_frontend/decoder.hpp" +#include "openvino/frontend/tensorflow/decoder.hpp" #include "types.pb.h" namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { -class DecoderTFProto : public DecoderBase { +class DecoderProto : public ov::frontend::tensorflow::DecoderBase { public: - explicit DecoderTFProto(const ::tensorflow::NodeDef* node_def) : m_node_def(node_def) {} + explicit DecoderProto(const ::tensorflow::NodeDef* node_def) : m_node_def(node_def) {} ov::Any get_attribute(const std::string& name, const std::type_info& type_info) const override; @@ -36,6 +36,6 @@ class DecoderTFProto : public DecoderBase { std::vector<::tensorflow::AttrValue> decode_attribute_helper(const std::string& name) const; const ::tensorflow::NodeDef* m_node_def; }; -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/exceptions.cpp b/src/frontends/tensorflow/src/exceptions.cpp index 83b7c5716db9a8..1b786df7aada8c 100644 --- a/src/frontends/tensorflow/src/exceptions.cpp +++ b/src/frontends/tensorflow/src/exceptions.cpp @@ -8,12 +8,12 @@ namespace ov { namespace frontend { -namespace tf { -std::string OpValidationFailureTF::get_error_msg_prefix_tf(const tf::NodeContext& node) { +namespace tensorflow { +std::string OpValidationFailure::get_error_msg_prefix_tf(const tensorflow::NodeContext& node) { std::stringstream ss; ss << "While validating node '" << node.get_op_type() << '\''; return ss.str(); } -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/exceptions.hpp b/src/frontends/tensorflow/src/exceptions.hpp index d43995a765d0d5..e44b4229057bee 100644 --- a/src/frontends/tensorflow/src/exceptions.hpp +++ b/src/frontends/tensorflow/src/exceptions.hpp @@ -7,19 +7,19 @@ namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { class NodeContext; -class OpValidationFailureTF : public ov::frontend::OpValidationFailure { +class OpValidationFailure : public ov::frontend::OpValidationFailure { public: - OpValidationFailureTF(const CheckLocInfo& check_loc_info, const NodeContext& node, const std::string& explanation) - : OpValidationFailure(check_loc_info, get_error_msg_prefix_tf(node), explanation) {} + OpValidationFailure(const CheckLocInfo& check_loc_info, const NodeContext& node, const std::string& explanation) + : ov::frontend::OpValidationFailure(check_loc_info, get_error_msg_prefix_tf(node), explanation) {} private: static std::string get_error_msg_prefix_tf(const NodeContext& node); }; -} // namespace tf +} // namespace tensorflow } // namespace frontend /// \brief Macro to check whether a boolean condition holds. @@ -28,7 +28,7 @@ class OpValidationFailureTF : public ov::frontend::OpValidationFailure { /// \param ... Additional error message info to be added to the error message via the `<<` /// stream-insertion operator. Note that the expressions here will be evaluated lazily, /// i.e., only if the `cond` evalutes to `false`. -/// \throws ::ov::OpValidationFailureTF if `cond` is false. -#define TF_OP_VALIDATION_CHECK(node_context, ...) \ - OPENVINO_ASSERT_HELPER(::ov::frontend::tf::OpValidationFailureTF, (node_context), __VA_ARGS__) +/// \throws ::ov::OpValidationFailure if `cond` is false. +#define TENSORFLOW_OP_VALIDATION(node_context, ...) \ + OPENVINO_ASSERT_HELPER(::ov::frontend::tensorflow::OpValidationFailure, (node_context), __VA_ARGS__) } // namespace ov diff --git a/src/frontends/tensorflow/src/frontend.cpp b/src/frontends/tensorflow/src/frontend.cpp index 51ee27fcc1227d..604f87523b254e 100644 --- a/src/frontends/tensorflow/src/frontend.cpp +++ b/src/frontends/tensorflow/src/frontend.cpp @@ -2,23 +2,22 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "tensorflow_frontend/frontend.hpp" +#include "openvino/frontend/tensorflow/frontend.hpp" -#include "model.hpp" +#include "input_model.hpp" #include "op_table.hpp" +#include "openvino/frontend/tensorflow/graph_iterator.hpp" #include "openvino/pass/manager.hpp" #include "openvino/util/common_util.hpp" #include "pass/transpose_sinking.hpp" -#include "tensorflow_frontend/graph_iterator.hpp" #include "tf_framework_node.hpp" #include "utils.hpp" -using namespace ::ov::frontend; -using namespace ::ov::frontend::tf; +using namespace ov::frontend::tensorflow; namespace { -void translate_framework_node(const std::shared_ptr& node, - const FrontEndTF::TranslatorDictionaryType& op_translators) { +void translate_framework_node(const std::shared_ptr& node, + const FrontEnd::TranslatorDictionaryType& op_translators) { auto type = node->get_op_type(); const auto& TRANSLATE_OP_MAP = op_translators; @@ -46,19 +45,19 @@ void translate_framework_node(const std::shared_ptr& node, } } // namespace -FrontEndTF::FrontEndTF() : m_op_translators(tf::op::get_supported_ops()) {} +FrontEnd::FrontEnd() : m_op_translators(tensorflow::op::get_supported_ops()) {} -void FrontEndTF::translate_graph(const ov::frontend::InputModel::Ptr& model, - const std::string& model_name, - bool fail_fast, - bool no_conversion, - std::shared_ptr& ng_function) const { +void FrontEnd::translate_graph(const ov::frontend::InputModel::Ptr& model, + const std::string& model_name, + bool fail_fast, + bool no_conversion, + std::shared_ptr& ng_function) const { // a map from operation names to generated OV Output - tf::OpMap ng_op_map; + tensorflow::OpMap ng_op_map; ov::ParameterVector params; ov::ResultVector results; - const auto& model_tf = std::dynamic_pointer_cast(model); + const auto& model_tf = std::dynamic_pointer_cast(model); FRONT_END_GENERAL_CHECK(model_tf, "nullptr for InputModel is given for translation into OV function"); const auto& operation_places = model_tf->get_op_places(); const auto& model_inputs = model_tf->get_inputs(); @@ -92,7 +91,7 @@ void FrontEndTF::translate_graph(const ov::frontend::InputModel::Ptr& model, // probably this input is frozen continue; } - const auto& input_tensor_place = std::dynamic_pointer_cast(input_place); + const auto& input_tensor_place = std::dynamic_pointer_cast(input_place); auto input_shape = input_tensor_place->get_partial_shape(); auto input_type = input_tensor_place->get_element_type(); @@ -113,7 +112,7 @@ void FrontEndTF::translate_graph(const ov::frontend::InputModel::Ptr& model, // prepare a list of OV node inputs for each node ov::OutputVector ng_inputs; - ::ov::frontend::tf::NamedInputs named_inputs; + ::ov::frontend::tensorflow::NamedInputs named_inputs; for (size_t input_port_idx = 0; input_port_idx < operation_decoder->get_input_size(); ++input_port_idx) { std::string producer_name; size_t producer_port_idx; @@ -166,7 +165,7 @@ void FrontEndTF::translate_graph(const ov::frontend::InputModel::Ptr& model, auto op_fun = &(translate_map[operation_decoder->get_op_type()]); // NodeContext node_context(ng_inputs, operation_decoder, model_inputs); // TODO: Check why NodeContextNew doesn't have ngOutputVector ng_inputs input in constructor - ::ov::frontend::tf::NodeContext node_context(*operation_decoder, named_inputs); + ::ov::frontend::tensorflow::NodeContext node_context(*operation_decoder, named_inputs); // generate OV node output vector using translator for given operation type ng_outputs = (*op_fun)(node_context); } catch (...) { @@ -174,9 +173,9 @@ void FrontEndTF::translate_graph(const ov::frontend::InputModel::Ptr& model, // re-throw any exception throw; } else { - auto ng_node = std::make_shared(operation_decoder, - ng_inputs, - operation_place->get_output_ports().size()); + auto ng_node = std::make_shared(operation_decoder, + ng_inputs, + operation_place->get_output_ports().size()); set_node_name(operation_name, ng_node); ng_outputs = ng_node->outputs(); } @@ -199,12 +198,15 @@ void FrontEndTF::translate_graph(const ov::frontend::InputModel::Ptr& model, // create Result nodes for all model outputs for (const auto& model_output : model_outputs) { - auto model_output_tensor_place = std::dynamic_pointer_cast(model_output); + auto model_output_tensor_place = std::dynamic_pointer_cast(model_output); auto model_output_name = model_output_tensor_place->get_names()[0]; std::string operation_name; std::string port_type; size_t port_index; - ov::frontend::tf::extract_operation_name_and_port(model_output_name, operation_name, port_index, port_type); + ov::frontend::tensorflow::extract_operation_name_and_port(model_output_name, + operation_name, + port_index, + port_type); if (port_type == "none") { for (const auto& node_output : ng_op_map[operation_name]) { @@ -218,7 +220,7 @@ void FrontEndTF::translate_graph(const ov::frontend::InputModel::Ptr& model, results.push_back(std::make_shared(node_outputs[port_index])); } else if (port_type == "in") { // TODO: avoid this traversing by having a map for OpPlace objects, for example - std::shared_ptr operation_place = nullptr; + std::shared_ptr operation_place = nullptr; for (const auto& op_place : operation_places) { FRONT_END_GENERAL_CHECK(!op_place->get_names().empty(), "No names for OpPlace found."); if (op_place->get_names()[0] == operation_name) { @@ -268,7 +270,7 @@ void FrontEndTF::translate_graph(const ov::frontend::InputModel::Ptr& model, } /// \brief Check if FrontEndTensorflow can recognize model from given parts -bool FrontEndTF::supported_impl(const std::vector& variants) const { +bool FrontEnd::supported_impl(const std::vector& variants) const { // TODO: Support other TensorFlow formats: SavedModel, .meta, checkpoint, pbtxt if (variants.size() != 1) return false; @@ -286,7 +288,7 @@ bool FrontEndTF::supported_impl(const std::vector& variants) const { return false; } -ov::frontend::InputModel::Ptr FrontEndTF::load_impl(const std::vector& variants) const { +ov::frontend::InputModel::Ptr FrontEnd::load_impl(const std::vector& variants) const { // TODO: Support other TensorFlow formats: SavedModel, .meta, checkpoint, pbtxt if (variants.size() == 1) { // a case when binary protobuf format is provided @@ -294,26 +296,26 @@ ov::frontend::InputModel::Ptr FrontEndTF::load_impl(const std::vector& std::string suffix = ".pb"; std::string model_path = variants[0].as(); if (ov::util::ends_with(model_path, suffix.c_str())) { - return std::make_shared( - std::make_shared<::ov::frontend::tf::GraphIteratorProto>(model_path), + return std::make_shared( + std::make_shared<::ov::frontend::tensorflow::GraphIteratorProto>(model_path), m_telemetry); } } else if (variants[0].is()) { auto graph_iterator = variants[0].as(); - return std::make_shared(graph_iterator, m_telemetry); + return std::make_shared(graph_iterator, m_telemetry); } } return nullptr; } -std::shared_ptr FrontEndTF::convert(const ov::frontend::InputModel::Ptr& model) const { - auto model_tf = std::dynamic_pointer_cast(model); +std::shared_ptr FrontEnd::convert(const ov::frontend::InputModel::Ptr& model) const { + auto model_tf = std::dynamic_pointer_cast(model); FRONT_END_GENERAL_CHECK(model_tf != nullptr, "Invalid input model"); if (!m_transformation_extensions.empty()) { auto function = decode(model); - pass::Manager manager; + ov::pass::Manager manager; for (const auto& transformation : m_transformation_extensions) { transformation->register_pass(manager); } @@ -330,14 +332,14 @@ std::shared_ptr FrontEndTF::convert(const ov::frontend::InputModel::P return f; } -std::shared_ptr FrontEndTF::convert_partially(const ov::frontend::InputModel::Ptr& model) const { - auto model_tf = std::dynamic_pointer_cast(model); +std::shared_ptr FrontEnd::convert_partially(const ov::frontend::InputModel::Ptr& model) const { + auto model_tf = std::dynamic_pointer_cast(model); FRONT_END_GENERAL_CHECK(model_tf != nullptr, "Invalid input model"); if (!m_transformation_extensions.empty()) { auto function = decode(model); - pass::Manager manager; + ov::pass::Manager manager; for (const auto& transformation : m_transformation_extensions) { transformation->register_pass(manager); } @@ -352,17 +354,17 @@ std::shared_ptr FrontEndTF::convert_partially(const ov::frontend::Inp return f; } -std::shared_ptr FrontEndTF::decode(const ov::frontend::InputModel::Ptr& model) const { - auto model_tf = std::dynamic_pointer_cast(model); +std::shared_ptr FrontEnd::decode(const ov::frontend::InputModel::Ptr& model) const { + auto model_tf = std::dynamic_pointer_cast(model); std::shared_ptr f; translate_graph(model_tf, "here_should_be_a_graph_name", false, true, f); return f; } -void FrontEndTF::convert(const std::shared_ptr& partiallyConverted) const { +void FrontEnd::convert(const std::shared_ptr& partiallyConverted) const { for (const auto& node : partiallyConverted->get_ordered_ops()) { - if (ov::is_type(node)) { - translate_framework_node(std::dynamic_pointer_cast(node), m_op_translators); + if (ov::is_type(node)) { + translate_framework_node(std::dynamic_pointer_cast(node), m_op_translators); } } for (const auto& result : partiallyConverted->get_results()) { @@ -372,13 +374,13 @@ void FrontEndTF::convert(const std::shared_ptr& partiallyConverted) c normalize(partiallyConverted); } -void FrontEndTF::normalize(const std::shared_ptr& function) const { +void FrontEnd::normalize(const std::shared_ptr& function) const { ov::pass::Manager manager; - manager.register_pass(); + manager.register_pass(); manager.run_passes(function); } -void FrontEndTF::add_extension(const std::shared_ptr& extension) { +void FrontEnd::add_extension(const std::shared_ptr& extension) { if (auto telemetry = std::dynamic_pointer_cast(extension)) { m_telemetry = telemetry; } else if (auto transformation = std::dynamic_pointer_cast(extension)) { diff --git a/src/frontends/tensorflow/src/graph_iterator_proto.hpp b/src/frontends/tensorflow/src/graph_iterator_proto.hpp index 50b0796ff6a3e4..e1390265cb3a32 100644 --- a/src/frontends/tensorflow/src/graph_iterator_proto.hpp +++ b/src/frontends/tensorflow/src/graph_iterator_proto.hpp @@ -9,12 +9,14 @@ #include "decoder_proto.hpp" #include "graph.pb.h" #include "node_def.pb.h" -#include "tensorflow_frontend/decoder.hpp" -#include "tensorflow_frontend/graph_iterator.hpp" +#include "openvino/frontend/exception.hpp" +#include "openvino/frontend/tensorflow/decoder.hpp" +#include "openvino/frontend/tensorflow/graph_iterator.hpp" namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { + class GraphIteratorProto : public GraphIterator { std::vector m_nodes; size_t node_index = 0; @@ -53,9 +55,10 @@ class GraphIteratorProto : public GraphIterator { /// Return NodeContext for the current node that iterator points to std::shared_ptr get_decoder() const override { - return std::make_shared(m_nodes[node_index]); + return std::make_shared(m_nodes[node_index]); } }; -} // namespace tf + +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/model.cpp b/src/frontends/tensorflow/src/input_model.cpp similarity index 73% rename from src/frontends/tensorflow/src/model.cpp rename to src/frontends/tensorflow/src/input_model.cpp index 4c502eef5e6e01..964392aea5ca90 100644 --- a/src/frontends/tensorflow/src/model.cpp +++ b/src/frontends/tensorflow/src/input_model.cpp @@ -2,23 +2,23 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "model.hpp" +#include "input_model.hpp" #include #include #include "node_context.hpp" #include "openvino/frontend/exception.hpp" +#include "openvino/frontend/tensorflow/graph_iterator.hpp" #include "openvino/opsets/opset7.hpp" #include "place.hpp" -#include "tensorflow_frontend/graph_iterator.hpp" #include "utils.hpp" using namespace google; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { void extract_operation_name_and_port(const std::string& port_name, std::string& operation_name, size_t& port_index, @@ -49,8 +49,8 @@ void extract_operation_name_and_port(const std::string& port_name, FRONT_END_GENERAL_CHECK(false, "Incorrect port name specified: " + port_name); } } -} // namespace tf -class InputModelTF::InputModelTFImpl { + +class InputModel::InputModelTFImpl { public: InputModelTFImpl(const GraphIterator::Ptr& graph_iterator, const ov::frontend::InputModel& input_model); InputModelTFImpl(const GraphIterator::Ptr& graph_iterator, @@ -68,8 +68,8 @@ class InputModelTF::InputModelTFImpl { void setElementType(ov::frontend::Place::Ptr place, const ov::element::Type&); void setTensorValue(ov::frontend::Place::Ptr place, const void* value); - std::vector> get_op_places() const; - std::map> get_tensor_places() const { + std::vector> get_op_places() const; + std::map> get_tensor_places() const { return m_tensor_places; } std::map> get_tensor_values() const { @@ -78,11 +78,11 @@ class InputModelTF::InputModelTFImpl { private: void loadPlaces(); - std::vector> determine_cut_nodes() const; + std::vector> determine_cut_nodes() const; - std::vector> m_op_places; - std::map> m_op_places_map; - mutable std::map> m_tensor_places; + std::vector> m_op_places; + std::map> m_op_places_map; + mutable std::map> m_tensor_places; std::vector m_inputs; std::vector m_outputs; std::map> m_tensor_values; @@ -96,7 +96,7 @@ class InputModelTF::InputModelTFImpl { bool m_graph_changed = false; }; -void InputModelTF::InputModelTFImpl::loadPlaces() { +void InputModel::InputModelTFImpl::loadPlaces() { std::set all_op_names; std::set op_names_with_consumers; std::map op_statistics; @@ -111,7 +111,7 @@ void InputModelTF::InputModelTFImpl::loadPlaces() { op_statistics[op_type]++; } - auto op_place = std::make_shared(m_input_model, node_decoder); + auto op_place = std::make_shared(m_input_model, node_decoder); all_op_names.insert(op_name); m_op_places.push_back(op_place); m_op_places_map[op_name] = op_place; @@ -119,7 +119,7 @@ void InputModelTF::InputModelTFImpl::loadPlaces() { auto pshape = node_decoder->get_attribute("shape", typeid(ov::PartialShape)).as(); auto type = node_decoder->get_attribute("dtype", typeid(ov::element::Type)).as(); std::vector names = {op_name}; - auto tensor_place = std::make_shared(m_input_model, pshape, type, names); + auto tensor_place = std::make_shared(m_input_model, pshape, type, names); m_tensor_places[op_name] = tensor_place; m_inputs.push_back(tensor_place); } @@ -156,30 +156,30 @@ void InputModelTF::InputModelTFImpl::loadPlaces() { for (auto& output_name : op_names_without_consumers) { std::vector output_names = {output_name}; auto output_place = - std::make_shared(m_input_model, ov::PartialShape({}), ov::element::undefined, output_names); + std::make_shared(m_input_model, ov::PartialShape({}), ov::element::undefined, output_names); m_tensor_places[output_name] = output_place; m_outputs.push_back(output_place); } } -std::vector> InputModelTF::InputModelTFImpl::get_op_places() const { +std::vector> InputModel::InputModelTFImpl::get_op_places() const { if (m_graph_changed) { return determine_cut_nodes(); } return m_op_places; } -std::vector> InputModelTF::InputModelTFImpl::determine_cut_nodes() const { +std::vector> InputModel::InputModelTFImpl::determine_cut_nodes() const { std::queue> decoders_queue; std::unordered_set visited; - std::vector> new_ops; + std::vector> new_ops; for (const auto& output_place : m_outputs) { FRONT_END_GENERAL_CHECK(output_place->get_names().size() > 0, "TensorPlace must have at least one name."); auto output_place_name = output_place->get_names()[0]; std::string operation_name; size_t port_idx; std::string port_type; - tf::extract_operation_name_and_port(output_place_name, operation_name, port_idx, port_type); + tensorflow::extract_operation_name_and_port(output_place_name, operation_name, port_idx, port_type); if (!visited.count(operation_name)) { visited.insert(operation_name); FRONT_END_GENERAL_CHECK(m_op_places_map.count(operation_name), @@ -248,17 +248,17 @@ std::vector> InputModelTF::InputModelTFImpl::determin return new_ops; } -InputModelTF::InputModelTFImpl::InputModelTFImpl(const GraphIterator::Ptr& graph_iterator, - const ov::frontend::InputModel& input_model) +InputModel::InputModelTFImpl::InputModelTFImpl(const GraphIterator::Ptr& graph_iterator, + const ov::frontend::InputModel& input_model) : m_input_model(input_model), m_graph_iterator(graph_iterator) { FRONT_END_GENERAL_CHECK(m_graph_iterator, "Null pointer specified for GraphIterator"); loadPlaces(); } -InputModelTF::InputModelTFImpl::InputModelTFImpl(const GraphIterator::Ptr& graph_iterator, - const InputModel& input_model, - const std::shared_ptr& telemetry) +InputModel::InputModelTFImpl::InputModelTFImpl(const GraphIterator::Ptr& graph_iterator, + const ov::frontend::InputModel& input_model, + const std::shared_ptr& telemetry) : m_input_model(input_model), m_graph_iterator(graph_iterator), m_telemetry(telemetry) { @@ -266,15 +266,15 @@ InputModelTF::InputModelTFImpl::InputModelTFImpl(const GraphIterator::Ptr& graph loadPlaces(); } -std::vector InputModelTF::InputModelTFImpl::getInputs() const { +std::vector InputModel::InputModelTFImpl::getInputs() const { return m_inputs; } -std::vector InputModelTF::InputModelTFImpl::getOutputs() const { +std::vector InputModel::InputModelTFImpl::getOutputs() const { return m_outputs; } -ov::frontend::Place::Ptr InputModelTF::InputModelTFImpl::getPlaceByTensorName(const std::string& tensorName) const { +ov::frontend::Place::Ptr InputModel::InputModelTFImpl::getPlaceByTensorName(const std::string& tensorName) const { if (m_tensor_places.find(tensorName) != m_tensor_places.end()) return m_tensor_places.at(tensorName); @@ -282,11 +282,11 @@ ov::frontend::Place::Ptr InputModelTF::InputModelTFImpl::getPlaceByTensorName(co std::string operation_name; size_t port_idx; std::string port_type; - tf::extract_operation_name_and_port(tensorName, operation_name, port_idx, port_type); + tensorflow::extract_operation_name_and_port(tensorName, operation_name, port_idx, port_type); if (m_op_places_map.find(operation_name) != m_op_places_map.end()) { std::vector names = {tensorName}; auto m_var_place = - std::make_shared(m_input_model, ov::PartialShape(), ov::element::undefined, names); + std::make_shared(m_input_model, ov::PartialShape(), ov::element::undefined, names); m_tensor_places[tensorName] = m_var_place; return m_var_place; } @@ -294,18 +294,18 @@ ov::frontend::Place::Ptr InputModelTF::InputModelTFImpl::getPlaceByTensorName(co return nullptr; } -std::shared_ptr castToTensorPlace(const ov::frontend::Place::Ptr& place) { - if (auto var_place = std::dynamic_pointer_cast(place)) { +std::shared_ptr castToTensorPlace(const ov::frontend::Place::Ptr& place) { + if (auto var_place = std::dynamic_pointer_cast(place)) { return var_place; - } else if (auto in_port_place = std::dynamic_pointer_cast(place)) { + } else if (auto in_port_place = std::dynamic_pointer_cast(place)) { return in_port_place->get_source_tensor_tf(); - } else if (auto out_port_place = std::dynamic_pointer_cast(place)) { + } else if (auto out_port_place = std::dynamic_pointer_cast(place)) { return out_port_place->get_target_tensor_tf(); } FRONT_END_GENERAL_CHECK(false, "Cannot cast this Place to TensorPlaceTF."); } -void InputModelTF::InputModelTFImpl::overrideAllInputs(const std::vector& inputs) { +void InputModel::InputModelTFImpl::overrideAllInputs(const std::vector& inputs) { m_graph_changed = true; m_inputs.clear(); for (const auto& input_place : inputs) { @@ -313,7 +313,7 @@ void InputModelTF::InputModelTFImpl::overrideAllInputs(const std::vector& outputs) { +void InputModel::InputModelTFImpl::overrideAllOutputs(const std::vector& outputs) { m_graph_changed = true; m_outputs.clear(); for (const auto& output_place : outputs) { @@ -321,26 +321,26 @@ void InputModelTF::InputModelTFImpl::overrideAllOutputs(const std::vector& inputs, - const std::vector& outputs) { +void InputModel::InputModelTFImpl::extractSubgraph(const std::vector& inputs, + const std::vector& outputs) { m_graph_changed = true; overrideAllInputs(inputs); overrideAllOutputs(outputs); } -void InputModelTF::InputModelTFImpl::setPartialShape(ov::frontend::Place::Ptr place, const ov::PartialShape& p_shape) { +void InputModel::InputModelTFImpl::setPartialShape(ov::frontend::Place::Ptr place, const ov::PartialShape& p_shape) { castToTensorPlace(place)->set_partial_shape(p_shape); } -ov::PartialShape InputModelTF::InputModelTFImpl::getPartialShape(ov::frontend::Place::Ptr place) const { +ov::PartialShape InputModel::InputModelTFImpl::getPartialShape(ov::frontend::Place::Ptr place) const { return castToTensorPlace(place)->get_partial_shape(); } -void InputModelTF::InputModelTFImpl::setElementType(ov::frontend::Place::Ptr place, const ov::element::Type& type) { +void InputModel::InputModelTFImpl::setElementType(ov::frontend::Place::Ptr place, const ov::element::Type& type) { castToTensorPlace(place)->set_element_type(type); } -void InputModelTF::InputModelTFImpl::setTensorValue(ov::frontend::Place::Ptr place, const void* value) { +void InputModel::InputModelTFImpl::setTensorValue(ov::frontend::Place::Ptr place, const void* value) { m_graph_changed = true; auto tensor_place = castToTensorPlace(place); auto p_shape = tensor_place->get_partial_shape(); @@ -351,61 +351,62 @@ void InputModelTF::InputModelTFImpl::setTensorValue(ov::frontend::Place::Ptr pla m_tensor_values[name] = constant; } -InputModelTF::InputModelTF(const GraphIterator::Ptr& graph_iterator, - const std::shared_ptr& telemetry) +InputModel::InputModel(const GraphIterator::Ptr& graph_iterator, const std::shared_ptr& telemetry) : _impl{std::make_shared(graph_iterator, *this, telemetry)} {} -std::vector> InputModelTF::get_op_places() const { +std::vector> InputModel::get_op_places() const { return _impl->get_op_places(); } -std::map> InputModelTF::get_tensor_places() const { +std::map> InputModel::get_tensor_places() const { return _impl->get_tensor_places(); } -std::map> InputModelTF::get_tensor_values() const { +std::map> InputModel::get_tensor_values() const { return _impl->get_tensor_values(); } -std::vector InputModelTF::get_inputs() const { +std::vector InputModel::get_inputs() const { return _impl->getInputs(); } -std::vector InputModelTF::get_outputs() const { +std::vector InputModel::get_outputs() const { return _impl->getOutputs(); } -ov::frontend::Place::Ptr InputModelTF::get_place_by_tensor_name(const std::string& tensorName) const { +ov::frontend::Place::Ptr InputModel::get_place_by_tensor_name(const std::string& tensorName) const { return _impl->getPlaceByTensorName(tensorName); } -void InputModelTF::override_all_outputs(const std::vector& outputs) { +void InputModel::override_all_outputs(const std::vector& outputs) { _impl->overrideAllOutputs(outputs); } -void InputModelTF::override_all_inputs(const std::vector& inputs) { +void InputModel::override_all_inputs(const std::vector& inputs) { _impl->overrideAllInputs(inputs); } -void InputModelTF::extract_subgraph(const std::vector& inputs, - const std::vector& outputs) { +void InputModel::extract_subgraph(const std::vector& inputs, + const std::vector& outputs) { _impl->extractSubgraph(inputs, outputs); } -void InputModelTF::set_partial_shape(const ov::frontend::Place::Ptr& place, const ov::PartialShape& p_shape) { +void InputModel::set_partial_shape(const ov::frontend::Place::Ptr& place, const ov::PartialShape& p_shape) { _impl->setPartialShape(place, p_shape); } -ov::PartialShape InputModelTF::get_partial_shape(const ov::frontend::Place::Ptr& place) const { +ov::PartialShape InputModel::get_partial_shape(const ov::frontend::Place::Ptr& place) const { return _impl->getPartialShape(place); } -void InputModelTF::set_element_type(const ov::frontend::Place::Ptr& place, const ov::element::Type& type) { +void InputModel::set_element_type(const ov::frontend::Place::Ptr& place, const ov::element::Type& type) { _impl->setElementType(place, type); } -void InputModelTF::set_tensor_value(const ov::frontend::Place::Ptr& place, const void* value) { +void InputModel::set_tensor_value(const ov::frontend::Place::Ptr& place, const void* value) { _impl->setTensorValue(place, value); } + +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/model.hpp b/src/frontends/tensorflow/src/input_model.hpp similarity index 73% rename from src/frontends/tensorflow/src/model.hpp rename to src/frontends/tensorflow/src/input_model.hpp index 2ff9d73706ceca..1e4b4a4d452e21 100644 --- a/src/frontends/tensorflow/src/model.hpp +++ b/src/frontends/tensorflow/src/input_model.hpp @@ -7,26 +7,27 @@ #include "openvino/frontend/extension/telemetry.hpp" #include "openvino/frontend/input_model.hpp" #include "openvino/frontend/place.hpp" -#include "tensorflow_frontend/graph_iterator.hpp" +#include "openvino/frontend/tensorflow/graph_iterator.hpp" namespace ov { namespace frontend { +namespace tensorflow { -class OpPlaceTF; -class TensorPlaceTF; +class OpPlace; +class TensorPlace; -class InputModelTF : public ov::frontend::InputModel { - friend class FrontEndTF; +class InputModel : public ov::frontend::InputModel { + friend class FrontEnd; class InputModelTFImpl; std::shared_ptr _impl; - std::vector> get_op_places() const; - std::map> get_tensor_places() const; + std::vector> get_op_places() const; + std::map> get_tensor_places() const; std::map> get_tensor_values() const; public: - explicit InputModelTF(const GraphIterator::Ptr& graph_iterator, - const std::shared_ptr& telemetry = {}); + explicit InputModel(const GraphIterator::Ptr& graph_iterator, + const std::shared_ptr& telemetry = {}); std::vector get_inputs() const override; std::vector get_outputs() const override; @@ -40,5 +41,7 @@ class InputModelTF : public ov::frontend::InputModel { void set_element_type(const ov::frontend::Place::Ptr& place, const ov::element::Type&) override; void set_tensor_value(const ov::frontend::Place::Ptr& place, const void* value) override; }; + +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/node_context.hpp b/src/frontends/tensorflow/src/node_context.hpp index 2913a2fa79950c..b34cb068aa0ed3 100644 --- a/src/frontends/tensorflow/src/node_context.hpp +++ b/src/frontends/tensorflow/src/node_context.hpp @@ -8,12 +8,12 @@ #include "exceptions.hpp" #include "place.hpp" #include "tensor.pb.h" -#include "tensorflow_frontend/utility.hpp" #include "types.pb.h" namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { + using InPortName = size_t; using OutPortName = size_t; using NamedOutputs = std::map; @@ -103,6 +103,6 @@ class NodeContext { } }; -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/addN.cpp b/src/frontends/tensorflow/src/op/addN.cpp index 7b08abde1773e1..3a613d335d0745 100644 --- a/src/frontends/tensorflow/src/op/addN.cpp +++ b/src/frontends/tensorflow/src/op/addN.cpp @@ -12,7 +12,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_add_n_op(const NodeContext& node) { @@ -27,6 +27,6 @@ OutputVector translate_add_n_op(const NodeContext& node) { return {res}; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/arg_min_max.cpp b/src/frontends/tensorflow/src/op/arg_min_max.cpp index ed88729ea8a775..b8b11b093a3f22 100644 --- a/src/frontends/tensorflow/src/op/arg_min_max.cpp +++ b/src/frontends/tensorflow/src/op/arg_min_max.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_arg_min_max(const NodeContext& node, std::string mode) { @@ -22,7 +22,9 @@ OutputVector translate_arg_min_max(const NodeContext& node, std::string mode) { Shape input_shape = ng_input.get_shape(); size_t input_rank = input_shape.size(); - TF_OP_VALIDATION_CHECK(node, tf_dim.size() == 1, "ArgMax Op: dimension must be scalar, operates on a single axis"); + TENSORFLOW_OP_VALIDATION(node, + tf_dim.size() == 1, + "ArgMax Op: dimension must be scalar, operates on a single axis"); // If input dimension is negative, make it positive if (tf_dim[0] < 0) { @@ -54,6 +56,6 @@ OutputVector translate_arg_min_op(const NodeContext& node) { return (translate_arg_min_max(node, "min")); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/avg_pool.cpp b/src/frontends/tensorflow/src/op/avg_pool.cpp index 9430f6d90cba8a..395d409e176d95 100644 --- a/src/frontends/tensorflow/src/op/avg_pool.cpp +++ b/src/frontends/tensorflow/src/op/avg_pool.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_avg_pool_op(const NodeContext& node) { @@ -21,9 +21,9 @@ OutputVector translate_avg_pool_op(const NodeContext& node) { auto tf_padding_type = node.get_attribute("padding"); auto tf_data_format = node.get_attribute("data_format"); - TF_OP_VALIDATION_CHECK(node, - tf_data_format == "NHWC" || tf_data_format == "NCHW", - "AvgPool data format is neither NHWC nor NCHW"); + TENSORFLOW_OP_VALIDATION(node, + tf_data_format == "NHWC" || tf_data_format == "NCHW", + "AvgPool data format is neither NHWC nor NCHW"); bool is_nhwc = (tf_data_format == "NHWC"); @@ -65,6 +65,6 @@ OutputVector translate_avg_pool_op(const NodeContext& node) { return {res}; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/bias_add.cpp b/src/frontends/tensorflow/src/op/bias_add.cpp index 518116c86c857e..e4f1aeadc09f18 100644 --- a/src/frontends/tensorflow/src/op/bias_add.cpp +++ b/src/frontends/tensorflow/src/op/bias_add.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_bias_add_op(const NodeContext& node) { @@ -18,13 +18,13 @@ OutputVector translate_bias_add_op(const NodeContext& node) { std::string tf_data_format = node.get_attribute("data_format", "NHWC"); - TF_OP_VALIDATION_CHECK(node, - tf_data_format == "NHWC" || tf_data_format == "NCHW", - "BiasAdd data format is neither NHWC nor NCHW"); + TENSORFLOW_OP_VALIDATION(node, + tf_data_format == "NHWC" || tf_data_format == "NCHW", + "BiasAdd data format is neither NHWC nor NCHW"); auto ng_input_shape = ng_input.get_shape(); auto ng_bias_shape = ng_bias.get_shape(); - TF_OP_VALIDATION_CHECK(node, ng_bias_shape.size() == 1, "Bias argument to BiasAdd does not have one dimension"); + TENSORFLOW_OP_VALIDATION(node, ng_bias_shape.size() == 1, "Bias argument to BiasAdd does not have one dimension"); // We'll choose reshape over broadcast // Reshape the bias to (1, C, 1, ...) if input is channels-first. @@ -48,6 +48,6 @@ OutputVector translate_bias_add_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/binary_op.cpp b/src/frontends/tensorflow/src/op/binary_op.cpp index 97c824aac504c2..5e260b45728e53 100644 --- a/src/frontends/tensorflow/src/op/binary_op.cpp +++ b/src/frontends/tensorflow/src/op/binary_op.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_binary_op(const NodeContext& node, @@ -57,6 +57,6 @@ template OutputVector translate_binary_op(const NodeContext& template OutputVector translate_binary_op(const NodeContext& node); } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/cast.cpp b/src/frontends/tensorflow/src/op/cast.cpp index 9fe2b177c0fe98..ceefab1c4f07bc 100644 --- a/src/frontends/tensorflow/src/op/cast.cpp +++ b/src/frontends/tensorflow/src/op/cast.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_cast_op(const NodeContext& node) { @@ -23,6 +23,6 @@ OutputVector translate_cast_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/concat.cpp b/src/frontends/tensorflow/src/op/concat.cpp index 4e2bbe26039e89..8324a801f26bf4 100644 --- a/src/frontends/tensorflow/src/op/concat.cpp +++ b/src/frontends/tensorflow/src/op/concat.cpp @@ -9,11 +9,11 @@ using namespace std; using namespace ov; using namespace opset8; using namespace ov::frontend; -using namespace frontend::tf::detail; +using namespace frontend::tensorflow::detail; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_concat_op(const NodeContext& node) { @@ -27,7 +27,7 @@ OutputVector translate_concat_op(const NodeContext& node) { concat_idx_start = 1; concat_idx_stop = node.get_input_size(); } else { - TF_OP_VALIDATION_CHECK(node, false, "Incorrect operation type."); + TENSORFLOW_OP_VALIDATION(node, false, "Incorrect operation type."); } std::vector tf_concat_axis_vec; @@ -45,6 +45,6 @@ OutputVector translate_concat_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/const.cpp b/src/frontends/tensorflow/src/op/const.cpp index 054f2e44eb8c14..ea0b9af4bb94f6 100644 --- a/src/frontends/tensorflow/src/op/const.cpp +++ b/src/frontends/tensorflow/src/op/const.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { namespace { @@ -49,12 +49,12 @@ OutputVector translate_const_op(const NodeContext& node) { const auto& func_param = TF_OPENVINO_CONST_MAP().at(dt); func_param.first(node, func_param.second, res); } catch (const std::out_of_range&) { - TF_OP_VALIDATION_CHECK(node, false, "Failed to translate Constant with target OV type:" + dt.get_type_name()); + TENSORFLOW_OP_VALIDATION(node, false, "Failed to translate Constant with target OV type:" + dt.get_type_name()); } set_node_name(node.get_name(), res.get_node_shared_ptr()); return {res}; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/conv_2d.cpp b/src/frontends/tensorflow/src/op/conv_2d.cpp index 53f132415b06d9..d85af6e86be236 100644 --- a/src/frontends/tensorflow/src/op/conv_2d.cpp +++ b/src/frontends/tensorflow/src/op/conv_2d.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_conv_2d_op(const NodeContext& node) { @@ -21,18 +21,18 @@ OutputVector translate_conv_2d_op(const NodeContext& node) { auto tf_padding_type = node.get_attribute("padding"); auto tf_data_format = node.get_attribute("data_format"); - TF_OP_VALIDATION_CHECK(node, - tf_data_format == "NHWC" || tf_data_format == "NCHW", - "Conv2D data format is neither NHWC nor NCHW"); + TENSORFLOW_OP_VALIDATION(node, + tf_data_format == "NHWC" || tf_data_format == "NCHW", + "Conv2D data format is neither NHWC nor NCHW"); bool is_nhwc = (tf_data_format == "NHWC"); // TF Kernel Test Checks // Strides in the batch and depth dimension is not supported if (tf_strides[0] != 1 || tf_strides[is_nhwc ? 3 : 1] != 1) { - TF_OP_VALIDATION_CHECK(node, - false, - "Strides in batch and depth dimensions is not supported: " + node.get_op_type()); + TENSORFLOW_OP_VALIDATION(node, + false, + "Strides in batch and depth dimensions is not supported: " + node.get_op_type()); } Strides ng_strides(2); @@ -68,6 +68,6 @@ OutputVector translate_conv_2d_op(const NodeContext& node) { return {res}; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/conv_2d_backprop.cpp b/src/frontends/tensorflow/src/op/conv_2d_backprop.cpp index 59ba2346bead28..129d2f9840dc3a 100644 --- a/src/frontends/tensorflow/src/op/conv_2d_backprop.cpp +++ b/src/frontends/tensorflow/src/op/conv_2d_backprop.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_conv_2d_backprop_input_op(const NodeContext& node) { @@ -22,9 +22,9 @@ OutputVector translate_conv_2d_backprop_input_op(const NodeContext& node) { auto tf_padding_type = node.get_attribute("padding"); auto tf_data_format = node.get_attribute("data_format"); - TF_OP_VALIDATION_CHECK(node, - tf_data_format == "NHWC" || tf_data_format == "NCHW", - "Conv2DBackpropInput data format is neither NHWC nor NCHW"); + TENSORFLOW_OP_VALIDATION(node, + tf_data_format == "NHWC" || tf_data_format == "NCHW", + "Conv2DBackpropInput data format is neither NHWC nor NCHW"); std::vector tf_input_sizes; get_const_input(node, 0, &tf_input_sizes); @@ -92,6 +92,6 @@ OutputVector translate_conv_2d_backprop_input_op(const NodeContext& node) { return {res}; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/conv_3d.cpp b/src/frontends/tensorflow/src/op/conv_3d.cpp index a8c008e2abbe63..41901d10591663 100644 --- a/src/frontends/tensorflow/src/op/conv_3d.cpp +++ b/src/frontends/tensorflow/src/op/conv_3d.cpp @@ -11,7 +11,7 @@ using namespace ov::opset8; // Translate Conv3D Op namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_conv_3d_op(const NodeContext& node) { @@ -22,9 +22,9 @@ OutputVector translate_conv_3d_op(const NodeContext& node) { auto tf_padding_type = node.get_attribute("padding"); auto tf_data_format = node.get_attribute("data_format"); - TF_OP_VALIDATION_CHECK(node, - tf_data_format == "NHWC" || tf_data_format == "NCHW", - "Conv3D data format is neither NHWC nor NCHW"); + TENSORFLOW_OP_VALIDATION(node, + tf_data_format == "NHWC" || tf_data_format == "NCHW", + "Conv3D data format is neither NHWC nor NCHW"); bool is_ndhwc = (tf_data_format == "NDHWC"); @@ -72,6 +72,6 @@ OutputVector translate_conv_3d_op(const NodeContext& node) { return {res}; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/crop_and_resize.cpp b/src/frontends/tensorflow/src/op/crop_and_resize.cpp index 57578f3f7ea914..941254285313cf 100644 --- a/src/frontends/tensorflow/src/op/crop_and_resize.cpp +++ b/src/frontends/tensorflow/src/op/crop_and_resize.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_crop_and_resize_op(const NodeContext& node) { @@ -33,10 +33,10 @@ OutputVector translate_crop_and_resize_op(const NodeContext& node) { auto resize_method = node.get_attribute("method"); - TF_OP_VALIDATION_CHECK(node, - ng_input.get_partial_shape().is_static() && ng_boxes.get_partial_shape().is_static() && - ng_box_ind.get_partial_shape().is_static() && ng_size.get_partial_shape().is_static(), - "Dynamic shapes are not supported."); + TENSORFLOW_OP_VALIDATION(node, + ng_input.get_partial_shape().is_static() && ng_boxes.get_partial_shape().is_static() && + ng_box_ind.get_partial_shape().is_static() && ng_size.get_partial_shape().is_static(), + "Dynamic shapes are not supported."); auto spatial_shape = ng_input.get_shape(); auto image_height = spatial_shape[1]; @@ -47,9 +47,9 @@ OutputVector translate_crop_and_resize_op(const NodeContext& node) { auto const_box_ind = dynamic_pointer_cast(ng_boxes.get_node_shared_ptr()); auto const_crop_size = dynamic_pointer_cast(ng_boxes.get_node_shared_ptr()); - TF_OP_VALIDATION_CHECK(node, - const_boxes && const_box_ind && const_crop_size, - "Boxes, BoxIndexes, CropSize inputs must be constant."); + TENSORFLOW_OP_VALIDATION(node, + const_boxes && const_box_ind && const_crop_size, + "Boxes, BoxIndexes, CropSize inputs must be constant."); auto boxes = const_boxes->cast_vector(); auto box_ind = const_box_ind->cast_vector(); @@ -137,6 +137,6 @@ OutputVector translate_crop_and_resize_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/cumsum.cpp b/src/frontends/tensorflow/src/op/cumsum.cpp index 92738c0ef24039..b2106354980fdb 100644 --- a/src/frontends/tensorflow/src/op/cumsum.cpp +++ b/src/frontends/tensorflow/src/op/cumsum.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_cumsum_op(const NodeContext& node) { @@ -24,6 +24,6 @@ OutputVector translate_cumsum_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/depth_to_space.cpp b/src/frontends/tensorflow/src/op/depth_to_space.cpp index 5a5757ea0c7bb2..3b2c0e1c0cec06 100644 --- a/src/frontends/tensorflow/src/op/depth_to_space.cpp +++ b/src/frontends/tensorflow/src/op/depth_to_space.cpp @@ -11,7 +11,7 @@ using namespace ov::opset8; // Translate DepthToSpace op namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_depth_to_space_op(const NodeContext& node) { @@ -21,9 +21,9 @@ OutputVector translate_depth_to_space_op(const NodeContext& node) { auto block_size = node.get_attribute("block_size"); std::string tf_data_format = node.get_attribute("data_format"); - TF_OP_VALIDATION_CHECK(node, - tf_data_format == "NHWC" || tf_data_format == "NCHW", - "DepthToSpace data format is neither NHWC nor NCHW"); + TENSORFLOW_OP_VALIDATION(node, + tf_data_format == "NHWC" || tf_data_format == "NCHW", + "DepthToSpace data format is neither NHWC nor NCHW"); bool is_nhwc = (tf_data_format == "NHWC"); @@ -35,6 +35,6 @@ OutputVector translate_depth_to_space_op(const NodeContext& node) { return {res}; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/depthwise_conv_2d.cpp b/src/frontends/tensorflow/src/op/depthwise_conv_2d.cpp index 6506b3c5ff8740..c951010abed151 100644 --- a/src/frontends/tensorflow/src/op/depthwise_conv_2d.cpp +++ b/src/frontends/tensorflow/src/op/depthwise_conv_2d.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_depthwise_conv_2d_native_op(const NodeContext& node) { @@ -22,9 +22,9 @@ OutputVector translate_depthwise_conv_2d_native_op(const NodeContext& node) { auto tf_padding_type = node.get_attribute("padding"); auto tf_data_format = node.get_attribute("data_format"); - TF_OP_VALIDATION_CHECK(node, - tf_data_format == "NHWC" || tf_data_format == "NCHW", - "DepthwiseConv2D data format is neither NHWC nor NCHW"); + TENSORFLOW_OP_VALIDATION(node, + tf_data_format == "NHWC" || tf_data_format == "NCHW", + "DepthwiseConv2D data format is neither NHWC nor NCHW"); bool is_nhwc = (tf_data_format == "NHWC"); @@ -76,6 +76,6 @@ OutputVector translate_depthwise_conv_2d_native_op(const NodeContext& node) { return {ng_conv}; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/elu.cpp b/src/frontends/tensorflow/src/op/elu.cpp index 7241c1549f165c..971a54c5c05f84 100644 --- a/src/frontends/tensorflow/src/op/elu.cpp +++ b/src/frontends/tensorflow/src/op/elu.cpp @@ -12,7 +12,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_elu_op(const NodeContext& node) { @@ -23,6 +23,6 @@ OutputVector translate_elu_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/expand_dims.cpp b/src/frontends/tensorflow/src/op/expand_dims.cpp index 11d1a0efd1a64a..7156a65020894a 100644 --- a/src/frontends/tensorflow/src/op/expand_dims.cpp +++ b/src/frontends/tensorflow/src/op/expand_dims.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_expand_dims_op(const NodeContext& node) { @@ -21,6 +21,6 @@ OutputVector translate_expand_dims_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/fake_quant_min_max_vars.cpp b/src/frontends/tensorflow/src/op/fake_quant_min_max_vars.cpp index 526a6fd172262c..53fb62ef0388de 100644 --- a/src/frontends/tensorflow/src/op/fake_quant_min_max_vars.cpp +++ b/src/frontends/tensorflow/src/op/fake_quant_min_max_vars.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_fake_quant_op(const NodeContext& node) { @@ -61,6 +61,6 @@ OutputVector translate_fake_quant_op(const NodeContext& node) { return {res}; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/fill.cpp b/src/frontends/tensorflow/src/op/fill.cpp index 28e9ed65cf3c55..a58f306bbb6d97 100644 --- a/src/frontends/tensorflow/src/op/fill.cpp +++ b/src/frontends/tensorflow/src/op/fill.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_fill_op(const NodeContext& node) { @@ -21,6 +21,6 @@ OutputVector translate_fill_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/fused_batch_norm.cpp b/src/frontends/tensorflow/src/op/fused_batch_norm.cpp index b5a7b6016d4a8c..fe94545dee2f6b 100644 --- a/src/frontends/tensorflow/src/op/fused_batch_norm.cpp +++ b/src/frontends/tensorflow/src/op/fused_batch_norm.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_fused_batch_norm_op(const NodeContext& node) { @@ -23,7 +23,7 @@ OutputVector translate_fused_batch_norm_op(const NodeContext& node) { bool is_v3 = node.get_op_type() == "FusedBatchNormV3"; auto data_format = node.get_attribute("data_format"); - TF_OP_VALIDATION_CHECK(node, data_format == "NHWC" || data_format == "NCHW", "Unsupported data format"); + TENSORFLOW_OP_VALIDATION(node, data_format == "NHWC" || data_format == "NCHW", "Unsupported data format"); bool is_nhwc = (data_format == "NHWC"); @@ -50,6 +50,6 @@ OutputVector translate_fused_batch_norm_op(const NodeContext& node) { return result; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/gather.cpp b/src/frontends/tensorflow/src/op/gather.cpp index c26cef15c08b26..b791915f3b471d 100644 --- a/src/frontends/tensorflow/src/op/gather.cpp +++ b/src/frontends/tensorflow/src/op/gather.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_gather_op(const NodeContext& node) { @@ -42,6 +42,6 @@ OutputVector translate_gather_nd_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/identity.cpp b/src/frontends/tensorflow/src/op/identity.cpp index 285f9da8db5685..ecc92644c3bc63 100644 --- a/src/frontends/tensorflow/src/op/identity.cpp +++ b/src/frontends/tensorflow/src/op/identity.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_identity_op(const NodeContext& node) { @@ -27,6 +27,6 @@ OutputVector translate_identity_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/interpolate.cpp b/src/frontends/tensorflow/src/op/interpolate.cpp index cf6bf93e85d55c..011dbb17991d24 100644 --- a/src/frontends/tensorflow/src/op/interpolate.cpp +++ b/src/frontends/tensorflow/src/op/interpolate.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { ov::OutputVector translate_interpolate_op(const NodeContext& node) { auto input = node.get_input(0); @@ -43,6 +43,6 @@ ov::OutputVector translate_interpolate_op(const NodeContext& node) { return {res}; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/is_finite.cpp b/src/frontends/tensorflow/src/op/is_finite.cpp index 626d3aec9bc24f..ebd96fa2b95782 100644 --- a/src/frontends/tensorflow/src/op/is_finite.cpp +++ b/src/frontends/tensorflow/src/op/is_finite.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_is_finite_op(const NodeContext& node) { @@ -35,6 +35,6 @@ OutputVector translate_is_finite_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/l2_loss.cpp b/src/frontends/tensorflow/src/op/l2_loss.cpp index 8cad1e58958241..371ea117e93054 100644 --- a/src/frontends/tensorflow/src/op/l2_loss.cpp +++ b/src/frontends/tensorflow/src/op/l2_loss.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_l2_loss_op(const NodeContext& node) { @@ -42,6 +42,6 @@ OutputVector translate_l2_loss_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/leaky_relu.cpp b/src/frontends/tensorflow/src/op/leaky_relu.cpp index ecba626e8550d9..36752fe5469e7d 100644 --- a/src/frontends/tensorflow/src/op/leaky_relu.cpp +++ b/src/frontends/tensorflow/src/op/leaky_relu.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { ov::OutputVector translate_leaky_relu_op(const NodeContext& node) { auto in = node.get_input(0); @@ -21,6 +21,6 @@ ov::OutputVector translate_leaky_relu_op(const NodeContext& node) { return leaky_relu->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/log1p.cpp b/src/frontends/tensorflow/src/op/log1p.cpp index 84d15a4d45ec58..ca270a7c8894be 100644 --- a/src/frontends/tensorflow/src/op/log1p.cpp +++ b/src/frontends/tensorflow/src/op/log1p.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_log_1p_op(const NodeContext& node) { @@ -22,6 +22,6 @@ OutputVector translate_log_1p_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/log_softmax.cpp b/src/frontends/tensorflow/src/op/log_softmax.cpp index eaf6ed06869129..52e04cd2f5aadc 100644 --- a/src/frontends/tensorflow/src/op/log_softmax.cpp +++ b/src/frontends/tensorflow/src/op/log_softmax.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_log_softmax_op(const NodeContext& node) { @@ -20,6 +20,6 @@ OutputVector translate_log_softmax_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/lrn.cpp b/src/frontends/tensorflow/src/op/lrn.cpp index ea4005e761e5db..ba3cd959153a42 100644 --- a/src/frontends/tensorflow/src/op/lrn.cpp +++ b/src/frontends/tensorflow/src/op/lrn.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_lrn_op(const NodeContext& node) { @@ -34,6 +34,6 @@ OutputVector translate_lrn_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/matmul.cpp b/src/frontends/tensorflow/src/op/matmul.cpp index f05c95d64b4c15..f1fea472cccbd4 100644 --- a/src/frontends/tensorflow/src/op/matmul.cpp +++ b/src/frontends/tensorflow/src/op/matmul.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_mat_mul_op(const NodeContext& node) { @@ -24,6 +24,6 @@ OutputVector translate_mat_mul_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/max_pool.cpp b/src/frontends/tensorflow/src/op/max_pool.cpp index 54585f1af0a0ef..a945a003ec55f4 100644 --- a/src/frontends/tensorflow/src/op/max_pool.cpp +++ b/src/frontends/tensorflow/src/op/max_pool.cpp @@ -8,11 +8,11 @@ using namespace std; using namespace ov; -using namespace ov::frontend::tf::detail; +using namespace ov::frontend::tensorflow::detail; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_max_pool_op(const NodeContext& node) { @@ -68,6 +68,6 @@ OutputVector translate_max_pool_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/no_op.cpp b/src/frontends/tensorflow/src/op/no_op.cpp index 135b7c3a323ca8..ff2593eafe4a19 100644 --- a/src/frontends/tensorflow/src/op/no_op.cpp +++ b/src/frontends/tensorflow/src/op/no_op.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_no_op(const NodeContext& node) { @@ -18,9 +18,9 @@ OutputVector translate_no_op(const NodeContext& node) { return OutputVector{}; } - TF_OP_VALIDATION_CHECK(node, - node.get_input_size() == 1, - "NoOp has " + to_string(node.get_input_size()) + " inputs, should have 1"); + TENSORFLOW_OP_VALIDATION(node, + node.get_input_size() == 1, + "NoOp has " + to_string(node.get_input_size()) + " inputs, should have 1"); auto input = node.get_input(0); set_out_name(node.get_name(), input); @@ -28,6 +28,6 @@ OutputVector translate_no_op(const NodeContext& node) { return {input}; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/non_max_suppression.cpp b/src/frontends/tensorflow/src/op/non_max_suppression.cpp index 4f527cce2a958a..7d7626ab16a1af 100644 --- a/src/frontends/tensorflow/src/op/non_max_suppression.cpp +++ b/src/frontends/tensorflow/src/op/non_max_suppression.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_non_max_suppression_op(const NodeContext& node) { @@ -77,9 +77,9 @@ OutputVector translate_non_max_suppression_op(const NodeContext& node) { set_node_name(node.get_name(), res); return {res->output(0)}; } - TF_OP_VALIDATION_CHECK(node, false, "No translator found."); + TENSORFLOW_OP_VALIDATION(node, false, "No translator found."); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/one_hot.cpp b/src/frontends/tensorflow/src/op/one_hot.cpp index 79f4806941431d..fe7f70c293378f 100644 --- a/src/frontends/tensorflow/src/op/one_hot.cpp +++ b/src/frontends/tensorflow/src/op/one_hot.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_one_hot_op(const NodeContext& node) { @@ -25,6 +25,6 @@ OutputVector translate_one_hot_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/pack.cpp b/src/frontends/tensorflow/src/op/pack.cpp index 16624d8efeaf88..559e94e71acd9c 100644 --- a/src/frontends/tensorflow/src/op/pack.cpp +++ b/src/frontends/tensorflow/src/op/pack.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_pack_op(const NodeContext& node) { @@ -28,6 +28,6 @@ OutputVector translate_pack_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/pad.cpp b/src/frontends/tensorflow/src/op/pad.cpp index fec2fbd3854077..399c9421efb904 100644 --- a/src/frontends/tensorflow/src/op/pad.cpp +++ b/src/frontends/tensorflow/src/op/pad.cpp @@ -14,7 +14,7 @@ using namespace ov::opset8; // See https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/mirror-pad namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_pad_op(const NodeContext& node) { @@ -28,7 +28,7 @@ OutputVector translate_pad_op(const NodeContext& node) { } else if (op_type == "PadV2") { pad_val_op = node.get_input(2); } else { - TF_OP_VALIDATION_CHECK(node, false, "Incorrect TF Pad OpType: " + node.get_op_type()); + TENSORFLOW_OP_VALIDATION(node, false, "Incorrect TF Pad OpType: " + node.get_op_type()); } // Set pad_mode @@ -40,7 +40,7 @@ OutputVector translate_pad_op(const NodeContext& node) { } else if (pad_mode_str == "SYMMETRIC") { pad_mode = ov::op::PadMode::SYMMETRIC; } else { - TF_OP_VALIDATION_CHECK(node, false, pad_mode_str + " is not an allowed padding mode."); + TENSORFLOW_OP_VALIDATION(node, false, pad_mode_str + " is not an allowed padding mode."); } } @@ -48,10 +48,10 @@ OutputVector translate_pad_op(const NodeContext& node) { std::vector paddings; get_const_input(node, 1, &paddings); if (paddings.size() % 2 != 0) { - TF_OP_VALIDATION_CHECK(node, - false, - "Constant node for paddings does not have an even number of " - "elements"); + TENSORFLOW_OP_VALIDATION(node, + false, + "Constant node for paddings does not have an even number of " + "elements"); } std::vector pad_begin(paddings.size() / 2); std::vector pad_end(paddings.size() / 2); @@ -68,6 +68,6 @@ OutputVector translate_pad_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/placeholder.cpp b/src/frontends/tensorflow/src/op/placeholder.cpp index 0277d5e7e3a14b..bb0e3a8305dcdf 100644 --- a/src/frontends/tensorflow/src/op/placeholder.cpp +++ b/src/frontends/tensorflow/src/op/placeholder.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_placeholder_op(const NodeContext& node) { @@ -22,6 +22,6 @@ OutputVector translate_placeholder_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/random_uniform.cpp b/src/frontends/tensorflow/src/op/random_uniform.cpp index 9c1a050a411fed..71aaeae0bba2ca 100644 --- a/src/frontends/tensorflow/src/op/random_uniform.cpp +++ b/src/frontends/tensorflow/src/op/random_uniform.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { ov::OutputVector translate_random_uniform_op(const NodeContext& node) { auto shape = node.get_input(0); @@ -36,6 +36,6 @@ ov::OutputVector translate_random_uniform_int_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/range.cpp b/src/frontends/tensorflow/src/op/range.cpp index 544af501e0dac0..b7fd9c8d6e424d 100644 --- a/src/frontends/tensorflow/src/op/range.cpp +++ b/src/frontends/tensorflow/src/op/range.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_range_op(const NodeContext& node) { @@ -25,6 +25,6 @@ OutputVector translate_range_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/rank.cpp b/src/frontends/tensorflow/src/op/rank.cpp index e4fc655706cd89..aae9c12c53b9ed 100644 --- a/src/frontends/tensorflow/src/op/rank.cpp +++ b/src/frontends/tensorflow/src/op/rank.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { ov::OutputVector translate_rank_op(const NodeContext& node) { @@ -22,6 +22,6 @@ ov::OutputVector translate_rank_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/reciprocal.cpp b/src/frontends/tensorflow/src/op/reciprocal.cpp index 017bbddbb4c68e..ad6d0cc18f1918 100644 --- a/src/frontends/tensorflow/src/op/reciprocal.cpp +++ b/src/frontends/tensorflow/src/op/reciprocal.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_reciprocal_op(const NodeContext& node) { @@ -21,6 +21,6 @@ OutputVector translate_reciprocal_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/reduce.cpp b/src/frontends/tensorflow/src/op/reduce.cpp index 11c9e7f6c1b20e..f00d1612364603 100644 --- a/src/frontends/tensorflow/src/op/reduce.cpp +++ b/src/frontends/tensorflow/src/op/reduce.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector TranslateReduceOp(const NodeContext& node, @@ -28,10 +28,10 @@ OutputVector translate_direct_reduce_op(const NodeContext& node) { // ensure its either an arithmetic or a logical reduction if (!(std::is_base_of::value || std::is_base_of::value)) { - TF_OP_VALIDATION_CHECK(node, - false, - "Expected node to be either a valid logical or arithmetic reduction " - "type"); + TENSORFLOW_OP_VALIDATION(node, + false, + "Expected node to be either a valid logical or arithmetic reduction " + "type"); } return TranslateReduceOp(node, [](Output ng_input, Output ng_reduction_axes, const bool keep_dims) { return make_shared(ng_input, ng_reduction_axes, keep_dims); @@ -46,6 +46,6 @@ template OutputVector translate_direct_reduce_op(const NodeContext& n template OutputVector translate_direct_reduce_op(const NodeContext& node); template OutputVector translate_direct_reduce_op(const NodeContext& node); } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/relu_6.cpp b/src/frontends/tensorflow/src/op/relu_6.cpp index 83692a56312b58..64bf4cea004acd 100644 --- a/src/frontends/tensorflow/src/op/relu_6.cpp +++ b/src/frontends/tensorflow/src/op/relu_6.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { ov::OutputVector translate_relu_6_op(const NodeContext& node) { auto data = node.get_input(0); @@ -19,6 +19,6 @@ ov::OutputVector translate_relu_6_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/reshape.cpp b/src/frontends/tensorflow/src/op/reshape.cpp index b14c02b6879a5d..6f7ad327e85394 100644 --- a/src/frontends/tensorflow/src/op/reshape.cpp +++ b/src/frontends/tensorflow/src/op/reshape.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_reshape_op(const NodeContext& node) { @@ -21,6 +21,6 @@ OutputVector translate_reshape_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/reverse.cpp b/src/frontends/tensorflow/src/op/reverse.cpp index 768e1ad8f27546..fd511fd2b2dcbe 100644 --- a/src/frontends/tensorflow/src/op/reverse.cpp +++ b/src/frontends/tensorflow/src/op/reverse.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_reverse_op(const NodeContext& node) { @@ -18,9 +18,9 @@ OutputVector translate_reverse_op(const NodeContext& node) { auto axes = node.get_input(1); auto axes_const = dynamic_pointer_cast(axes.get_node_shared_ptr()); - TF_OP_VALIDATION_CHECK(node, axes_const != nullptr, "Axes input must be constant."); - TF_OP_VALIDATION_CHECK(node, axes_const->get_shape().size() == 1, "Axes input must be 1D."); - TF_OP_VALIDATION_CHECK(node, axes_const->get_shape()[0] == 1, "Axes input must have only one value."); + TENSORFLOW_OP_VALIDATION(node, axes_const != nullptr, "Axes input must be constant."); + TENSORFLOW_OP_VALIDATION(node, axes_const->get_shape().size() == 1, "Axes input must be 1D."); + TENSORFLOW_OP_VALIDATION(node, axes_const->get_shape()[0] == 1, "Axes input must have only one value."); auto seq_axis = axes_const->cast_vector().at(0); int64_t batch_axis = !seq_axis; @@ -46,6 +46,6 @@ OutputVector translate_reverse_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/roll.cpp b/src/frontends/tensorflow/src/op/roll.cpp index a004436b9afbcf..1be6e9a716eaf7 100644 --- a/src/frontends/tensorflow/src/op/roll.cpp +++ b/src/frontends/tensorflow/src/op/roll.cpp @@ -8,11 +8,11 @@ using namespace std; using namespace ov; using namespace ov::opset8; -using namespace ov::frontend::tf; +using namespace ov::frontend::tensorflow; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { ov::OutputVector translate_roll_op(const NodeContext& node) { auto data = node.get_input(0); @@ -23,6 +23,6 @@ ov::OutputVector translate_roll_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/round.cpp b/src/frontends/tensorflow/src/op/round.cpp index 8c2d64bc951f7f..f0b41d74a0e890 100644 --- a/src/frontends/tensorflow/src/op/round.cpp +++ b/src/frontends/tensorflow/src/op/round.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_round_op(const NodeContext& node) { @@ -23,6 +23,6 @@ OutputVector translate_round_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/rsqrt.cpp b/src/frontends/tensorflow/src/op/rsqrt.cpp index a67fa255767d31..6161d5f9fa33d5 100644 --- a/src/frontends/tensorflow/src/op/rsqrt.cpp +++ b/src/frontends/tensorflow/src/op/rsqrt.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_rsqrt_op(const NodeContext& node) { @@ -21,6 +21,6 @@ OutputVector translate_rsqrt_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/select.cpp b/src/frontends/tensorflow/src/op/select.cpp index 9f3d9771ff06cc..7a314114c8a27c 100644 --- a/src/frontends/tensorflow/src/op/select.cpp +++ b/src/frontends/tensorflow/src/op/select.cpp @@ -10,10 +10,10 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_select_op(const NodeContext& node) { - TF_OP_VALIDATION_CHECK(node, node.get_all_inputs().size() == 3, "Select op cannot be converted"); + TENSORFLOW_OP_VALIDATION(node, node.get_all_inputs().size() == 3, "Select op cannot be converted"); auto in_1 = node.get_input(0); auto in_2 = node.get_input(1); auto in_3 = node.get_input(2); @@ -34,6 +34,6 @@ OutputVector translate_select_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/shape.cpp b/src/frontends/tensorflow/src/op/shape.cpp index 511bb65bbab3af..c39be021e92cbc 100644 --- a/src/frontends/tensorflow/src/op/shape.cpp +++ b/src/frontends/tensorflow/src/op/shape.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { ov::OutputVector translate_shape_op(const NodeContext& node) { @@ -22,6 +22,6 @@ ov::OutputVector translate_shape_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/size.cpp b/src/frontends/tensorflow/src/op/size.cpp index 79855e0991380e..675230584b5be8 100644 --- a/src/frontends/tensorflow/src/op/size.cpp +++ b/src/frontends/tensorflow/src/op/size.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { ov::OutputVector translate_size_op(const NodeContext& node) { @@ -24,6 +24,6 @@ ov::OutputVector translate_size_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/slice.cpp b/src/frontends/tensorflow/src/op/slice.cpp index 89376e9955e3cb..b26ec01d0727fe 100644 --- a/src/frontends/tensorflow/src/op/slice.cpp +++ b/src/frontends/tensorflow/src/op/slice.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_slice_op(const NodeContext& node) { @@ -29,6 +29,6 @@ OutputVector translate_slice_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/softmax.cpp b/src/frontends/tensorflow/src/op/softmax.cpp index 24fc5620858ab9..9a520be0293215 100644 --- a/src/frontends/tensorflow/src/op/softmax.cpp +++ b/src/frontends/tensorflow/src/op/softmax.cpp @@ -11,12 +11,12 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_softmax_op(const NodeContext& node) { auto ng_inp = node.get_input(0); // todo: switch to opset8::Softmax when is ready and delete Dynamic rank limitation - TF_OP_VALIDATION_CHECK(node, ng_inp.get_partial_shape().rank().is_static(), "Dynamic rank is not supported."); + TENSORFLOW_OP_VALIDATION(node, ng_inp.get_partial_shape().rank().is_static(), "Dynamic rank is not supported."); size_t axis = ng_inp.get_partial_shape().rank().get_length() - 1; auto res = make_shared(ng_inp, axis); set_node_name(node.get_name(), res); @@ -24,6 +24,6 @@ OutputVector translate_softmax_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/space_to_batch_nd.cpp b/src/frontends/tensorflow/src/op/space_to_batch_nd.cpp index 940cc344677b3f..902f1926213427 100644 --- a/src/frontends/tensorflow/src/op/space_to_batch_nd.cpp +++ b/src/frontends/tensorflow/src/op/space_to_batch_nd.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_batch_nd_and_space_nd_op(const NodeContext& node) { auto input = node.get_input(0); @@ -32,7 +32,7 @@ OutputVector translate_batch_nd_and_space_nd_op(const NodeContext& node) { return {input}; } else { // TODO: support dynamic rank - TF_OP_VALIDATION_CHECK(node, false, "Dynamic rank is not supported."); + TENSORFLOW_OP_VALIDATION(node, false, "Dynamic rank is not supported."); } auto N = input_pshape.rank().get_length(); @@ -72,10 +72,10 @@ OutputVector translate_batch_nd_and_space_nd_op(const NodeContext& node) { set_node_name(node.get_name(), res); return res->outputs(); } - TF_OP_VALIDATION_CHECK(node, false, "No translator found."); + TENSORFLOW_OP_VALIDATION(node, false, "No translator found."); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/space_to_depth.cpp b/src/frontends/tensorflow/src/op/space_to_depth.cpp index ac173f6120c3e7..9ed6926dcb94d7 100644 --- a/src/frontends/tensorflow/src/op/space_to_depth.cpp +++ b/src/frontends/tensorflow/src/op/space_to_depth.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_space_to_depth_op(const NodeContext& node) { @@ -19,7 +19,7 @@ OutputVector translate_space_to_depth_op(const NodeContext& node) { auto block_size = node.get_attribute("block_size"); auto data_format = node.get_attribute("data_format"); - TF_OP_VALIDATION_CHECK(node, data_format == "NHWC" || data_format == "NCHW", "Unsupported data format."); + TENSORFLOW_OP_VALIDATION(node, data_format == "NHWC" || data_format == "NCHW", "Unsupported data format."); bool is_nhwc = (data_format == "NHWC"); convert_nhwc_to_nchw(node.get_name(), is_nhwc, input); @@ -30,6 +30,6 @@ OutputVector translate_space_to_depth_op(const NodeContext& node) { return {res}; } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/split.cpp b/src/frontends/tensorflow/src/op/split.cpp index 20ea1ad789ee8d..cf6462040b7879 100644 --- a/src/frontends/tensorflow/src/op/split.cpp +++ b/src/frontends/tensorflow/src/op/split.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_split_op(const NodeContext& node) { @@ -34,6 +34,6 @@ OutputVector translate_split_v_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/sqrt.cpp b/src/frontends/tensorflow/src/op/sqrt.cpp index 97490a4bc3c13b..74dd14474f624d 100644 --- a/src/frontends/tensorflow/src/op/sqrt.cpp +++ b/src/frontends/tensorflow/src/op/sqrt.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_sqrt_op(const NodeContext& node) { @@ -21,6 +21,6 @@ OutputVector translate_sqrt_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/square.cpp b/src/frontends/tensorflow/src/op/square.cpp index 9a74550f1f8e4d..7e34cf858aa674 100644 --- a/src/frontends/tensorflow/src/op/square.cpp +++ b/src/frontends/tensorflow/src/op/square.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_square_op(const NodeContext& node) { @@ -21,6 +21,6 @@ OutputVector translate_square_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/squeeze.cpp b/src/frontends/tensorflow/src/op/squeeze.cpp index 1af6b5272b6180..b55d1b3b572da8 100644 --- a/src/frontends/tensorflow/src/op/squeeze.cpp +++ b/src/frontends/tensorflow/src/op/squeeze.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_squeeze_op(const NodeContext& node) { @@ -23,6 +23,6 @@ OutputVector translate_squeeze_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/strided_slice.cpp b/src/frontends/tensorflow/src/op/strided_slice.cpp index 31cc7f63d91b86..ef5273f1f2c621 100644 --- a/src/frontends/tensorflow/src/op/strided_slice.cpp +++ b/src/frontends/tensorflow/src/op/strided_slice.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_strided_slice_op(const NodeContext& node) { @@ -53,6 +53,6 @@ OutputVector translate_strided_slice_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/tile.cpp b/src/frontends/tensorflow/src/op/tile.cpp index b3c63ddad27048..373b27a7c54283 100644 --- a/src/frontends/tensorflow/src/op/tile.cpp +++ b/src/frontends/tensorflow/src/op/tile.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_tile_op(const NodeContext& node) { @@ -23,6 +23,6 @@ OutputVector translate_tile_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/top_k.cpp b/src/frontends/tensorflow/src/op/top_k.cpp index 4826a8efbcdccc..1eed8caac06cf4 100644 --- a/src/frontends/tensorflow/src/op/top_k.cpp +++ b/src/frontends/tensorflow/src/op/top_k.cpp @@ -10,17 +10,17 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_top_k_v2_op(const NodeContext& node) { auto input = node.get_input(0); auto k = node.get_input(1); - TF_OP_VALIDATION_CHECK(node, input.get_partial_shape().rank().is_static(), "Input rank must be static."); - TF_OP_VALIDATION_CHECK(node, - input.get_partial_shape().rank().get_length() >= 1, - "Input rank must be greater than 0."); + TENSORFLOW_OP_VALIDATION(node, input.get_partial_shape().rank().is_static(), "Input rank must be static."); + TENSORFLOW_OP_VALIDATION(node, + input.get_partial_shape().rank().get_length() >= 1, + "Input rank must be greater than 0."); // axis along which to compute top k indices int64_t k_axis = input.get_partial_shape().rank().get_length() - 1; bool sorted = node.get_attribute("sorted", true); @@ -34,6 +34,6 @@ OutputVector translate_top_k_v2_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/transpose.cpp b/src/frontends/tensorflow/src/op/transpose.cpp index 0a07c8e43c3765..5ed01994d497c6 100644 --- a/src/frontends/tensorflow/src/op/transpose.cpp +++ b/src/frontends/tensorflow/src/op/transpose.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_transpose_op(const NodeContext& node) { @@ -22,6 +22,6 @@ OutputVector translate_transpose_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/unary_op.cpp b/src/frontends/tensorflow/src/op/unary_op.cpp index e1d894027620e8..d00f45bf52ee67 100644 --- a/src/frontends/tensorflow/src/op/unary_op.cpp +++ b/src/frontends/tensorflow/src/op/unary_op.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_unary_op(const NodeContext& op, @@ -54,6 +54,6 @@ template OutputVector translate_unary_op(const NodeContext& node); template OutputVector translate_unary_op(const NodeContext& node); } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/unpack.cpp b/src/frontends/tensorflow/src/op/unpack.cpp index 772ee493bae75b..8c27d374331b92 100644 --- a/src/frontends/tensorflow/src/op/unpack.cpp +++ b/src/frontends/tensorflow/src/op/unpack.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_unpack_op(const NodeContext& node) { @@ -24,6 +24,6 @@ OutputVector translate_unpack_op(const NodeContext& node) { return res->outputs(); } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/where.cpp b/src/frontends/tensorflow/src/op/where.cpp index cdddb82f5dc721..8209b52d3d577a 100644 --- a/src/frontends/tensorflow/src/op/where.cpp +++ b/src/frontends/tensorflow/src/op/where.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_where_op(const NodeContext& node) { @@ -23,6 +23,6 @@ OutputVector translate_where_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op/xdivy.cpp b/src/frontends/tensorflow/src/op/xdivy.cpp index 121efbc58ee98d..da87ef80e12727 100644 --- a/src/frontends/tensorflow/src/op/xdivy.cpp +++ b/src/frontends/tensorflow/src/op/xdivy.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_x_div_y_op(const NodeContext& node) { @@ -27,6 +27,6 @@ OutputVector translate_x_div_y_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op/zeros_like.cpp b/src/frontends/tensorflow/src/op/zeros_like.cpp index 0ece26c16c40f9..d4bcfd2aea3474 100644 --- a/src/frontends/tensorflow/src/op/zeros_like.cpp +++ b/src/frontends/tensorflow/src/op/zeros_like.cpp @@ -10,7 +10,7 @@ using namespace ov::opset8; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { OutputVector translate_zeros_like_op(const NodeContext& node) { @@ -23,6 +23,6 @@ OutputVector translate_zeros_like_op(const NodeContext& node) { } } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/op_table.cpp b/src/frontends/tensorflow/src/op_table.cpp index 2220fd7b1d8157..14ca5bd8973a62 100644 --- a/src/frontends/tensorflow/src/op_table.cpp +++ b/src/frontends/tensorflow/src/op_table.cpp @@ -6,11 +6,11 @@ using namespace std; using namespace ov; -using namespace ov::frontend::tf; +using namespace ov::frontend::tensorflow; namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { #define OP_CONVERTER(op) OutputVector op(const NodeContext& node) #define OP_T_CONVERTER(op) \ @@ -244,6 +244,6 @@ const std::map get_supported_ops() { }; }; } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov \ No newline at end of file diff --git a/src/frontends/tensorflow/src/op_table.hpp b/src/frontends/tensorflow/src/op_table.hpp index f1785cd9956cb3..9f9ee4fe82613a 100644 --- a/src/frontends/tensorflow/src/op_table.hpp +++ b/src/frontends/tensorflow/src/op_table.hpp @@ -15,12 +15,12 @@ namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace op { -using CreatorFunction = std::function<::ov::OutputVector(const ::ov::frontend::tf::NodeContext&)>; +using CreatorFunction = std::function<::ov::OutputVector(const ::ov::frontend::tensorflow::NodeContext&)>; const std::map get_supported_ops(); } // namespace op -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/openvino_conversions.cpp b/src/frontends/tensorflow/src/openvino_conversions.cpp index 6f98ae472a72af..39f9ca05107fc8 100644 --- a/src/frontends/tensorflow/src/openvino_conversions.cpp +++ b/src/frontends/tensorflow/src/openvino_conversions.cpp @@ -8,7 +8,7 @@ namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { void convert_nhwc_to_nchw(const std::string& op_name, bool need_convert, ov::Output& node) { if (need_convert) { @@ -32,6 +32,6 @@ void convert_nchw_to_nhwc(const std::string& op_name, bool need_convert, ov::Out } } -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/openvino_conversions.hpp b/src/frontends/tensorflow/src/openvino_conversions.hpp index bf8d6d589a00a6..d56971530bf9bf 100644 --- a/src/frontends/tensorflow/src/openvino_conversions.hpp +++ b/src/frontends/tensorflow/src/openvino_conversions.hpp @@ -8,12 +8,11 @@ #include "graph.pb.h" #include "openvino/opsets/opset8.hpp" -#include "tensorflow_frontend/utility.hpp" #include "types.pb.h" namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { using ::tensorflow::DataType; @@ -85,6 +84,6 @@ void convert_nhwc_to_hw(bool is_nhwc, const std::vector& src, std::vector& n, // For each op type we support we can either combine // two transposes by replacing the existing Transpose, // materialize pending transposes if they can't be propagated through op -bool ov::frontend::tf::pass::TransposeSinkingOVTF::run_on_model(const shared_ptr& f) { +bool ov::frontend::tensorflow::pass::TransposeSinking::run_on_model(const shared_ptr& f) { TransposeMap reorders; set> transposes_to_delete; unordered_map orig_result_out_shape; diff --git a/src/frontends/tensorflow/src/pass/transpose_sinking.hpp b/src/frontends/tensorflow/src/pass/transpose_sinking.hpp index c23bcf888e8a45..4d88adcbd1454c 100644 --- a/src/frontends/tensorflow/src/pass/transpose_sinking.hpp +++ b/src/frontends/tensorflow/src/pass/transpose_sinking.hpp @@ -4,24 +4,24 @@ #pragma once +#include "openvino/frontend/tensorflow/visibility.hpp" #include "openvino/pass/pass.hpp" -#include "tensorflow_frontend/utility.hpp" namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { namespace pass { -class TF_API TransposeSinkingOVTF : public ov::pass::ModelPass { +class TENSORFLOW_API TransposeSinking : public ov::pass::ModelPass { public: - OPENVINO_RTTI("ov::frontend::tf::pass::TransposeSinkingOVTF"); - TransposeSinkingOVTF() { + OPENVINO_RTTI("ov::frontend::tensorflow::pass::TransposeSinking"); + TransposeSinking() { set_property(ov::pass::PassProperty::REQUIRE_STATIC_SHAPE, true); } bool run_on_model(const std::shared_ptr& function) override; }; } // namespace pass -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/place.cpp b/src/frontends/tensorflow/src/place.cpp index 5a933f1432003c..43c0e54aa2679c 100644 --- a/src/frontends/tensorflow/src/place.cpp +++ b/src/frontends/tensorflow/src/place.cpp @@ -12,8 +12,8 @@ namespace ov { namespace frontend { - -bool PlaceTF::is_input() const { +namespace tensorflow { +bool Place::is_input() const { const auto& model_ins = m_input_model.get_inputs(); const auto cmp = [this](const ov::frontend::Place::Ptr& p) { @@ -22,7 +22,7 @@ bool PlaceTF::is_input() const { return std::find_if(model_ins.begin(), model_ins.end(), cmp) != model_ins.end(); } -bool PlaceTF::is_output() const { +bool Place::is_output() const { const auto& model_outs = m_input_model.get_outputs(); const auto cmp = [this](const ov::frontend::Place::Ptr& p) { return p.get() == this; @@ -30,65 +30,65 @@ bool PlaceTF::is_output() const { return std::find_if(model_outs.begin(), model_outs.end(), cmp) != model_outs.end(); } -OpPlaceTF::OpPlaceTF(const ov::frontend::InputModel& input_model, std::shared_ptr op_decoder) - : PlaceTF(input_model, {op_decoder->get_op_name()}), +OpPlace::OpPlace(const ov::frontend::InputModel& input_model, std::shared_ptr op_decoder) + : Place(input_model, {op_decoder->get_op_name()}), m_op_decoder(op_decoder) {} -const std::vector>& OpPlaceTF::get_output_ports() const { +const std::vector>& OpPlace::get_output_ports() const { return m_output_ports; } -const std::map>>& OpPlaceTF::get_input_ports() const { +const std::map>>& OpPlace::get_input_ports() const { return m_input_ports; } -std::shared_ptr OpPlaceTF::get_input_port_tf(const std::string& inputName, int inputPortIndex) const { +std::shared_ptr OpPlace::get_input_port_tf(const std::string& inputName, int inputPortIndex) const { FRONT_END_GENERAL_CHECK(inputPortIndex <= m_input_ports.at(inputName).size(), "inputPortIndex is out of bounds."); return m_input_ports.at(inputName)[inputPortIndex]; } -std::shared_ptr OpPlaceTF::get_decoder() const { +std::shared_ptr OpPlace::get_decoder() const { return m_op_decoder; } -void OpPlaceTF::add_out_port(const std::shared_ptr& output, int idx) { +void OpPlace::add_out_port(const std::shared_ptr& output, int idx) { while (idx >= m_output_ports.size()) { - m_output_ports.push_back(std::shared_ptr()); + m_output_ports.push_back(std::shared_ptr()); } m_output_ports[idx] = output; } -void OpPlaceTF::add_in_port(const std::shared_ptr& input, const std::string& name) { +void OpPlace::add_in_port(const std::shared_ptr& input, const std::string& name) { m_input_ports[name].push_back(input); } -ov::frontend::Place::Ptr OpPlaceTF::get_input_port(const std::string& name) const { +ov::frontend::Place::Ptr OpPlace::get_input_port(const std::string& name) const { FRONT_END_GENERAL_CHECK(m_input_ports.at(name).size() == 1, "Only one input port should exist."); return m_input_ports.at(name)[0]; } -ov::frontend::Place::Ptr OpPlaceTF::get_input_port(int outputPortIndex) const { +ov::frontend::Place::Ptr OpPlace::get_input_port(int outputPortIndex) const { FRONT_END_GENERAL_CHECK(m_input_ports.size() == 1, "Only one named input port should exist."); return m_input_ports.begin()->second[outputPortIndex]; } -ov::frontend::Place::Ptr OpPlaceTF::get_output_port(int outputPortIndex) const { +ov::frontend::Place::Ptr OpPlace::get_output_port(int outputPortIndex) const { FRONT_END_GENERAL_CHECK(m_output_ports.size() > outputPortIndex, "No port with index: ", outputPortIndex); return m_output_ports[outputPortIndex]; } -ov::frontend::Place::Ptr OpPlaceTF::get_output_port() const { +ov::frontend::Place::Ptr OpPlace::get_output_port() const { FRONT_END_GENERAL_CHECK(m_output_ports.size() == 1, "Only one output port should exist."); return m_output_ports[0]; } -ov::frontend::Place::Ptr OpPlaceTF::get_input_port() const { +ov::frontend::Place::Ptr OpPlace::get_input_port() const { FRONT_END_GENERAL_CHECK(m_input_ports.size() == 1 && m_input_ports.begin()->second.size() == 1, "Only one input port should exist."); return m_input_ports.begin()->second[0]; } -std::vector OpPlaceTF::get_consuming_operations() const { +std::vector OpPlace::get_consuming_operations() const { std::vector consuming_ops; for (const auto& out_port : m_output_ports) { auto consuming_ops_out = out_port->get_consuming_operations(); @@ -97,11 +97,11 @@ std::vector OpPlaceTF::get_consuming_operations() cons return consuming_ops; } -std::vector OpPlaceTF::get_consuming_operations(int outputPortIndex) const { +std::vector OpPlace::get_consuming_operations(int outputPortIndex) const { return get_output_port(outputPortIndex)->get_consuming_operations(); } -std::vector OpPlaceTF::get_consuming_ports() const { +std::vector OpPlace::get_consuming_ports() const { std::vector consuming_ports; for (const auto& out_port : m_output_ports) { auto consuming_ops_out = out_port->get_consuming_ports(); @@ -110,60 +110,60 @@ std::vector OpPlaceTF::get_consuming_ports() const { return consuming_ports; } -ov::frontend::Place::Ptr OpPlaceTF::get_input_port(const std::string& inputName, int inputPortIndex) const { +ov::frontend::Place::Ptr OpPlace::get_input_port(const std::string& inputName, int inputPortIndex) const { FRONT_END_GENERAL_CHECK(inputPortIndex <= m_input_ports.at(inputName).size(), "inputPortIndex is out of bounds."); return m_input_ports.at(inputName)[inputPortIndex]; } -ov::frontend::Place::Ptr OpPlaceTF::get_source_tensor() const { +ov::frontend::Place::Ptr OpPlace::get_source_tensor() const { return get_input_port()->get_source_tensor(); } -ov::frontend::Place::Ptr OpPlaceTF::get_source_tensor(const std::string& inputName) const { +ov::frontend::Place::Ptr OpPlace::get_source_tensor(const std::string& inputName) const { return get_input_port(inputName)->get_source_tensor(); } -ov::frontend::Place::Ptr OpPlaceTF::get_source_tensor(int inputPortIndex) const { +ov::frontend::Place::Ptr OpPlace::get_source_tensor(int inputPortIndex) const { return get_input_port(inputPortIndex)->get_source_tensor(); } -ov::frontend::Place::Ptr OpPlaceTF::get_source_tensor(const std::string& inputName, int inputPortIndex) const { +ov::frontend::Place::Ptr OpPlace::get_source_tensor(const std::string& inputName, int inputPortIndex) const { return get_input_port(inputName, inputPortIndex)->get_source_tensor(); } -ov::frontend::Place::Ptr OpPlaceTF::get_target_tensor() const { +ov::frontend::Place::Ptr OpPlace::get_target_tensor() const { return get_output_port()->get_target_tensor(); } -ov::frontend::Place::Ptr OpPlaceTF::get_producing_operation(const std::string& inputName) const { +ov::frontend::Place::Ptr OpPlace::get_producing_operation(const std::string& inputName) const { return get_input_port(inputName)->get_producing_operation(); } -ov::frontend::Place::Ptr OpPlaceTF::get_producing_operation(const std::string& inputName, int inputPortIndex) const { +ov::frontend::Place::Ptr OpPlace::get_producing_operation(const std::string& inputName, int inputPortIndex) const { return get_input_port(inputName, inputPortIndex)->get_producing_operation(); } -ov::frontend::Place::Ptr OpPlaceTF::get_producing_operation() const { +ov::frontend::Place::Ptr OpPlace::get_producing_operation() const { return get_input_port()->get_producing_operation(); } -ov::frontend::Place::Ptr OpPlaceTF::get_producing_operation(int inputPortIndex) const { +ov::frontend::Place::Ptr OpPlace::get_producing_operation(int inputPortIndex) const { return get_input_port(inputPortIndex)->get_producing_operation(); } -ov::frontend::Place::Ptr OpPlaceTF::get_target_tensor(int outputPortIndex) const { +ov::frontend::Place::Ptr OpPlace::get_target_tensor(int outputPortIndex) const { return get_output_port(outputPortIndex)->get_target_tensor(); } -TensorPlaceTF::TensorPlaceTF(const ov::frontend::InputModel& input_model, - const ov::PartialShape& pshape, - ov::element::Type type, - const std::vector& names) - : PlaceTF(input_model, names), +TensorPlace::TensorPlace(const ov::frontend::InputModel& input_model, + const ov::PartialShape& pshape, + ov::element::Type type, + const std::vector& names) + : Place(input_model, names), m_pshape(pshape), m_type(type) {} -std::vector TensorPlaceTF::get_consuming_ports() const { +std::vector TensorPlace::get_consuming_ports() const { std::vector consuming_ports; for (const auto& consuming_port : m_consuming_ports) { if (const auto& locked = consuming_port.lock()) { @@ -175,7 +175,7 @@ std::vector TensorPlaceTF::get_consuming_ports() const return consuming_ports; } -ov::frontend::Place::Ptr TensorPlaceTF::get_producing_port() const { +ov::frontend::Place::Ptr TensorPlace::get_producing_port() const { FRONT_END_GENERAL_CHECK(m_producing_ports.size() == 1, "Only one producing port is supported."); if (const auto& producing_port = m_producing_ports[0].lock()) { return producing_port; @@ -183,15 +183,15 @@ ov::frontend::Place::Ptr TensorPlaceTF::get_producing_port() const { FRONT_END_THROW("Producing Port has expired."); } -void TensorPlaceTF::add_producing_port(const std::shared_ptr& out_port) { +void TensorPlace::add_producing_port(const std::shared_ptr& out_port) { m_producing_ports.push_back(out_port); } -void TensorPlaceTF::add_consuming_port(const std::shared_ptr& in_port) { +void TensorPlace::add_consuming_port(const std::shared_ptr& in_port) { m_consuming_ports.push_back(in_port); } -std::vector TensorPlaceTF::get_consuming_operations() const { +std::vector TensorPlace::get_consuming_operations() const { std::vector consuming_ops; for (const auto& consuming_port : m_consuming_ports) { if (auto port_ptr = consuming_port.lock()) { @@ -204,7 +204,7 @@ std::vector TensorPlaceTF::get_consuming_operations() return consuming_ops; } -bool TensorPlaceTF::is_equal_data(const ov::frontend::Place::Ptr& another) const { +bool TensorPlace::is_equal_data(const ov::frontend::Place::Ptr& another) const { auto consuming_ports = get_consuming_ports(); bool eq_to_consuming_port = std::any_of(consuming_ports.begin(), consuming_ports.end(), [&another](const Ptr& place) { @@ -213,95 +213,97 @@ bool TensorPlaceTF::is_equal_data(const ov::frontend::Place::Ptr& another) const return is_equal(another) || get_producing_port()->is_equal(another) || eq_to_consuming_port; } -ov::frontend::Place::Ptr TensorPlaceTF::get_producing_operation() const { +ov::frontend::Place::Ptr TensorPlace::get_producing_operation() const { return get_producing_port()->get_producing_operation(); } -std::shared_ptr InPortPlaceTF::get_source_tensor_tf() const { +std::shared_ptr InPortPlace::get_source_tensor_tf() const { if (const auto& tensor = m_source_tensor.lock()) { return tensor; } FRONT_END_THROW("Source Tensor has expired."); } -std::shared_ptr InPortPlaceTF::get_op() { +std::shared_ptr InPortPlace::get_op() { if (const auto& op = m_op.lock()) { return op; } FRONT_END_THROW("Operation has expired."); } -void InPortPlaceTF::set_source_tensor(const std::weak_ptr& source_tensor) { +void InPortPlace::set_source_tensor(const std::weak_ptr& source_tensor) { m_source_tensor = source_tensor; } -std::vector InPortPlaceTF::get_consuming_operations() const { +std::vector InPortPlace::get_consuming_operations() const { if (const auto& consuming_op = m_op.lock()) { return {consuming_op}; } FRONT_END_THROW("Operation has expired."); } -ov::frontend::Place::Ptr InPortPlaceTF::get_source_tensor() const { +ov::frontend::Place::Ptr InPortPlace::get_source_tensor() const { if (const auto& tensor = m_source_tensor.lock()) { return tensor; } FRONT_END_THROW("Source Tensor has expired."); } -ov::frontend::Place::Ptr InPortPlaceTF::get_producing_port() const { +ov::frontend::Place::Ptr InPortPlace::get_producing_port() const { return get_source_tensor()->get_producing_port(); } -bool InPortPlaceTF::is_equal_data(const ov::frontend::Place::Ptr& another) const { +bool InPortPlace::is_equal_data(const ov::frontend::Place::Ptr& another) const { return get_source_tensor()->is_equal_data(another); } -ov::frontend::Place::Ptr InPortPlaceTF::get_producing_operation() const { +ov::frontend::Place::Ptr InPortPlace::get_producing_operation() const { return get_producing_port()->get_producing_operation(); } -std::shared_ptr OutPortPlaceTF::get_target_tensor_tf() const { +std::shared_ptr OutPortPlace::get_target_tensor_tf() const { if (const auto& target_tensor = m_target_tensor.lock()) { return target_tensor; } FRONT_END_THROW("Target Tensor has expired."); } -std::vector OutPortPlaceTF::get_consuming_operations() const { +std::vector OutPortPlace::get_consuming_operations() const { if (auto tensor_ptr = m_target_tensor.lock()) { return tensor_ptr->get_consuming_operations(); } FRONT_END_THROW("Tensor has expired."); } -void OutPortPlaceTF::set_target_tensor(const std::weak_ptr& target_tensor) { +void OutPortPlace::set_target_tensor(const std::weak_ptr& target_tensor) { m_target_tensor = target_tensor; } -std::vector OutPortPlaceTF::get_consuming_ports() const { +std::vector OutPortPlace::get_consuming_ports() const { if (auto tensor_ptr = m_target_tensor.lock()) { return tensor_ptr->get_consuming_ports(); } FRONT_END_THROW("Tensor has expired."); } -bool OutPortPlaceTF::is_equal_data(const ov::frontend::Place::Ptr& another) const { +bool OutPortPlace::is_equal_data(const ov::frontend::Place::Ptr& another) const { return get_target_tensor()->is_equal_data(another); } -ov::frontend::Place::Ptr OutPortPlaceTF::get_target_tensor() const { +ov::frontend::Place::Ptr OutPortPlace::get_target_tensor() const { if (const auto& target_tensor = m_target_tensor.lock()) { return target_tensor; } FRONT_END_THROW("Target Tensor has expired."); } -ov::frontend::Place::Ptr OutPortPlaceTF::get_producing_operation() const { +ov::frontend::Place::Ptr OutPortPlace::get_producing_operation() const { if (auto op = m_op.lock()) { return op; } FRONT_END_THROW("Operation has expired."); } + +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/place.hpp b/src/frontends/tensorflow/src/place.hpp index 0366342b9d84c4..639cd02a36e1f1 100644 --- a/src/frontends/tensorflow/src/place.hpp +++ b/src/frontends/tensorflow/src/place.hpp @@ -5,23 +5,24 @@ #pragma once #include "openvino/frontend/frontend.hpp" -#include "tensorflow_frontend/decoder.hpp" +#include "openvino/frontend/tensorflow/decoder.hpp" namespace ov { namespace frontend { +namespace tensorflow { -class TensorPlaceTF; -class OpPlaceTF; +class TensorPlace; +class OpPlace; -class PlaceTF : public ov::frontend::Place { +class Place : public ov::frontend::Place { public: - PlaceTF(const ov::frontend::InputModel& input_model, const std::vector& names) + Place(const ov::frontend::InputModel& input_model, const std::vector& names) : m_input_model(input_model), m_names(names) {} - explicit PlaceTF(const ov::frontend::InputModel& input_model) : PlaceTF(input_model, std::vector{}) {} + explicit Place(const ov::frontend::InputModel& input_model) : Place(input_model, std::vector{}) {} - ~PlaceTF() override = default; + ~Place() override = default; bool is_input() const override; bool is_output() const override; @@ -38,18 +39,18 @@ class PlaceTF : public ov::frontend::Place { std::vector m_names; }; -class InPortPlaceTF : public PlaceTF { +class InPortPlace : public Place { public: - explicit InPortPlaceTF(const ov::frontend::InputModel& input_model) : PlaceTF(input_model) {} + explicit InPortPlace(const ov::frontend::InputModel& input_model) : Place(input_model) {} - void set_op(const std::weak_ptr& op) { + void set_op(const std::weak_ptr& op) { m_op = op; } - void set_source_tensor(const std::weak_ptr& source_tensor); + void set_source_tensor(const std::weak_ptr& source_tensor); // Internal usage - std::shared_ptr get_source_tensor_tf() const; - std::shared_ptr get_op(); + std::shared_ptr get_source_tensor_tf() const; + std::shared_ptr get_op(); // External usage std::vector get_consuming_operations() const override; @@ -60,20 +61,20 @@ class InPortPlaceTF : public PlaceTF { bool is_equal_data(const Ptr& another) const override; private: - std::weak_ptr m_source_tensor; - std::weak_ptr m_op; + std::weak_ptr m_source_tensor; + std::weak_ptr m_op; }; -class OutPortPlaceTF : public PlaceTF { +class OutPortPlace : public Place { public: - explicit OutPortPlaceTF(const ov::frontend::InputModel& input_model) : PlaceTF(input_model) {} + explicit OutPortPlace(const ov::frontend::InputModel& input_model) : Place(input_model) {} - void set_op(const std::weak_ptr& op) { + void set_op(const std::weak_ptr& op) { m_op = op; } - void set_target_tensor(const std::weak_ptr& target_tensor); + void set_target_tensor(const std::weak_ptr& target_tensor); - std::shared_ptr get_target_tensor_tf() const; + std::shared_ptr get_target_tensor_tf() const; // External usage std::vector get_consuming_operations() const override; @@ -83,21 +84,21 @@ class OutPortPlaceTF : public PlaceTF { bool is_equal_data(const Ptr& another) const override; private: - std::weak_ptr m_op; - std::weak_ptr m_target_tensor; + std::weak_ptr m_op; + std::weak_ptr m_target_tensor; }; -class OpPlaceTF : public PlaceTF { +class OpPlace : public Place { public: - OpPlaceTF(const ov::frontend::InputModel& input_model, std::shared_ptr op_decoder); + OpPlace(const ov::frontend::InputModel& input_model, std::shared_ptr op_decoder); - void add_in_port(const std::shared_ptr& input, const std::string& name); - void add_out_port(const std::shared_ptr& output, int idx); + void add_in_port(const std::shared_ptr& input, const std::string& name); + void add_out_port(const std::shared_ptr& output, int idx); // Internal usage - const std::vector>& get_output_ports() const; - const std::map>>& get_input_ports() const; - std::shared_ptr get_input_port_tf(const std::string& inputName, int inputPortIndex) const; + const std::vector>& get_output_ports() const; + const std::map>>& get_input_ports() const; + std::shared_ptr get_input_port_tf(const std::string& inputName, int inputPortIndex) const; std::shared_ptr get_decoder() const; // External API methods @@ -129,19 +130,19 @@ class OpPlaceTF : public PlaceTF { private: std::shared_ptr m_op_decoder; - std::map>> m_input_ports; - std::vector> m_output_ports; + std::map>> m_input_ports; + std::vector> m_output_ports; }; -class TensorPlaceTF : public PlaceTF { +class TensorPlace : public Place { public: - TensorPlaceTF(const ov::frontend::InputModel& input_model, - const ov::PartialShape& pshape, - ov::element::Type type, - const std::vector& names); + TensorPlace(const ov::frontend::InputModel& input_model, + const ov::PartialShape& pshape, + ov::element::Type type, + const std::vector& names); - void add_producing_port(const std::shared_ptr& out_port); - void add_consuming_port(const std::shared_ptr& in_port); + void add_producing_port(const std::shared_ptr& out_port); + void add_consuming_port(const std::shared_ptr& in_port); // Internal usage const PartialShape& get_partial_shape() const { @@ -168,8 +169,10 @@ class TensorPlaceTF : public PlaceTF { PartialShape m_pshape; element::Type m_type; - std::vector> m_producing_ports; - std::vector> m_consuming_ports; + std::vector> m_producing_ports; + std::vector> m_consuming_ports; }; + +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/tensorflow.cpp b/src/frontends/tensorflow/src/tensorflow.cpp index e462ef7b92e3f8..1e826f9c5907b3 100644 --- a/src/frontends/tensorflow/src/tensorflow.cpp +++ b/src/frontends/tensorflow/src/tensorflow.cpp @@ -3,17 +3,18 @@ // #include "openvino/frontend/manager.hpp" -#include "tensorflow_frontend/frontend.hpp" +#include "openvino/frontend/tensorflow/frontend.hpp" +#include "openvino/frontend/tensorflow/visibility.hpp" -TF_C_API ov::frontend::FrontEndVersion GetAPIVersion() { +TENSORFLOW_C_API ov::frontend::FrontEndVersion GetAPIVersion() { return OV_FRONTEND_API_VERSION; } -TF_C_API void* GetFrontEndData() { +TENSORFLOW_C_API void* GetFrontEndData() { auto res = new ov::frontend::FrontEndPluginInfo(); res->m_name = "tf"; res->m_creator = []() { - return std::make_shared(); + return std::make_shared(); }; return res; } diff --git a/src/frontends/tensorflow/src/tf_framework_node.cpp b/src/frontends/tensorflow/src/tf_framework_node.cpp index 995eda18aafbdf..fd78a8afbbefa4 100644 --- a/src/frontends/tensorflow/src/tf_framework_node.cpp +++ b/src/frontends/tensorflow/src/tf_framework_node.cpp @@ -6,13 +6,13 @@ namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { -void TFFrameworkNode::validate_and_infer_types() { +void FrameworkNode::validate_and_infer_types() { for (size_t i = 0; i < get_output_size(); ++i) { set_output_type(i, ov::element::dynamic, PartialShape::dynamic()); } } -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/tf_framework_node.hpp b/src/frontends/tensorflow/src/tf_framework_node.hpp index 1ed553c299f396..25c060956b0141 100644 --- a/src/frontends/tensorflow/src/tf_framework_node.hpp +++ b/src/frontends/tensorflow/src/tf_framework_node.hpp @@ -6,19 +6,19 @@ #include +#include "openvino/frontend/tensorflow/decoder.hpp" #include "openvino/op/util/framework_node.hpp" -#include "tensorflow_frontend/decoder.hpp" namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { -class TFFrameworkNode : public ::ov::op::util::FrameworkNode { +class FrameworkNode : public ov::op::util::FrameworkNode { public: - OPENVINO_OP("TFFrameworkNode", "util", ::ov::op::util::FrameworkNode); + OPENVINO_OP("FrameworkNode", "util", ::ov::op::util::FrameworkNode); - TFFrameworkNode(const std::shared_ptr& decoder, const OutputVector& inputs, size_t num_outputs) - : FrameworkNode(inputs, std::max(num_outputs, size_t(1))), + FrameworkNode(const std::shared_ptr& decoder, const OutputVector& inputs, size_t num_outputs) + : ov::op::util::FrameworkNode(inputs, std::max(num_outputs, size_t(1))), m_decoder(decoder) { ov::op::util::FrameworkNodeAttrs attrs; attrs.set_type_name(m_decoder->get_op_type()); @@ -30,7 +30,7 @@ class TFFrameworkNode : public ::ov::op::util::FrameworkNode { void validate_and_infer_types() override; std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const override { - return std::make_shared(m_decoder, inputs, get_output_size()); + return std::make_shared(m_decoder, inputs, get_output_size()); } std::string get_op_type() const { @@ -44,6 +44,6 @@ class TFFrameworkNode : public ::ov::op::util::FrameworkNode { private: std::shared_ptr m_decoder; }; -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov diff --git a/src/frontends/tensorflow/src/utils.cpp b/src/frontends/tensorflow/src/utils.cpp index b8557330e78265..02488d0d97956b 100644 --- a/src/frontends/tensorflow/src/utils.cpp +++ b/src/frontends/tensorflow/src/utils.cpp @@ -4,7 +4,8 @@ #include "utils.hpp" -void ov::frontend::tf::tf_shape_to_ov_shape(const tensorflow::TensorShapeProto& tf_shape, ov::PartialShape* ng_shape) { +void ov::frontend::tensorflow::tf_shape_to_ov_shape(const ::tensorflow::TensorShapeProto& tf_shape, + ov::PartialShape* ng_shape) { std::vector dims; for (int i = 0; i < tf_shape.dim_size(); i++) { dims.emplace_back(tf_shape.dim(i).size()); @@ -12,7 +13,7 @@ void ov::frontend::tf::tf_shape_to_ov_shape(const tensorflow::TensorShapeProto& *ng_shape = ov::PartialShape(dims); } -void ov::frontend::tf::set_node_name(const std::string& node_name, const std::shared_ptr& node) { +void ov::frontend::tensorflow::set_node_name(const std::string& node_name, const std::shared_ptr& node) { const auto& outputs = node->outputs(); node->set_friendly_name(node_name); if (outputs.size() == 1) { @@ -23,6 +24,6 @@ void ov::frontend::tf::set_node_name(const std::string& node_name, const std::sh } } -void ov::frontend::tf::set_out_name(const std::string& out_name, const ov::Output& output) { +void ov::frontend::tensorflow::set_out_name(const std::string& out_name, const ov::Output& output) { output.get_tensor().add_names({out_name}); } diff --git a/src/frontends/tensorflow/src/utils.hpp b/src/frontends/tensorflow/src/utils.hpp index 6de7e432ee264d..352444099f2252 100644 --- a/src/frontends/tensorflow/src/utils.hpp +++ b/src/frontends/tensorflow/src/utils.hpp @@ -29,7 +29,7 @@ namespace ov { namespace frontend { -namespace tf { +namespace tensorflow { using OpMap = std::unordered_map>>; void extract_operation_name_and_port(const std::string& port_name, @@ -90,14 +90,14 @@ void get_const_input(const NodeContext& node, int64_t input_index, std::vector void values_from_const_node(const NodeContext& node, ov::Shape* const_tensor_shape, std::vector* values) { - TF_OP_VALIDATION_CHECK(node, node.get_op_type() == "Const", "Node is expected to be Constant."); + TENSORFLOW_OP_VALIDATION(node, node.get_op_type() == "Const", "Node is expected to be Constant."); auto dt = node.get_attribute<::tensorflow::DataType>("dtype"); auto tensor_proto = node.get_attribute<::tensorflow::TensorProto>("value"); - const tensorflow::TensorShapeProto& shape = tensor_proto.tensor_shape(); + const ::tensorflow::TensorShapeProto& shape = tensor_proto.tensor_shape(); ov::PartialShape pshape; tf_shape_to_ov_shape(shape, &pshape); *const_tensor_shape = pshape.get_shape(); - TF_OP_VALIDATION_CHECK(node, pshape.is_static(), "Dynamic shapes are not supported in Constant conversion."); + TENSORFLOW_OP_VALIDATION(node, pshape.is_static(), "Dynamic shapes are not supported in Constant conversion."); auto tensor_content = tensor_proto.tensor_content(); std::vector tensor_values_plain(tensor_content.begin(), tensor_content.end()); const T* tensor_values = reinterpret_cast(tensor_values_plain.data()); @@ -122,9 +122,9 @@ void values_from_const_node(const NodeContext& node, ov::Shape* const_tensor_sha if (tensor_content_size == 0) { int64_t n_elements = 1; for (auto i = 0; i < shape.dim_size(); i++) { - TF_OP_VALIDATION_CHECK(node, - shape.dim(i).size() >= 0, - "Const node has empty tensor and an unknown dimension size"); + TENSORFLOW_OP_VALIDATION(node, + shape.dim(i).size() >= 0, + "Const node has empty tensor and an unknown dimension size"); n_elements *= shape.dim(i).size(); } values->resize(n_elements); @@ -136,27 +136,27 @@ void values_from_const_node(const NodeContext& node, ov::Shape* const_tensor_sha switch (dt) { // TODO: there are more element types to support // here - case tensorflow::DT_INT32: + case ::tensorflow::DT_INT32: val_size = tensor_proto.int_val_size(); if (val_size > 0) val_i = tensor_proto.int_val()[i]; break; - case tensorflow::DT_INT64: + case ::tensorflow::DT_INT64: val_size = tensor_proto.int64_val_size(); if (val_size > 0) val_i = tensor_proto.int64_val()[i]; break; - case tensorflow::DT_FLOAT: + case ::tensorflow::DT_FLOAT: val_size = tensor_proto.float_val_size(); if (val_size > 0) val_i = tensor_proto.float_val()[i]; break; - case tensorflow::DT_BOOL: + case ::tensorflow::DT_BOOL: val_size = tensor_proto.bool_val_size(); if (val_size > 0) val_i = tensor_proto.bool_val()[i]; break; - case tensorflow::DT_DOUBLE: + case ::tensorflow::DT_DOUBLE: val_size = tensor_proto.double_val_size(); if (val_size > 0) val_i = tensor_proto.double_val()[i]; @@ -166,7 +166,7 @@ void values_from_const_node(const NodeContext& node, ov::Shape* const_tensor_sha "handle this element type"; FRONT_END_THROW("Encountered unknown element type " + DataType_Name(dt) + " on an empty tensor_proto"); } - TF_OP_VALIDATION_CHECK(node, val_size != 0, "Empty values vector"); + TENSORFLOW_OP_VALIDATION(node, val_size != 0, "Empty values vector"); if (i < val_size) { (*values)[i] = val_i; @@ -188,6 +188,6 @@ void make_const_op(const NodeContext& node, element::Type et, ov::Output(node, &ng_shape, &const_values); ng_node = std::make_shared(et, ng_shape, const_values); }; -} // namespace tf +} // namespace tensorflow } // namespace frontend } // namespace ov