From 649413a4916f909432c0debea3cbeb999dda68b1 Mon Sep 17 00:00:00 2001 From: Roman Kazantsev Date: Wed, 28 Feb 2024 12:38:09 +0400 Subject: [PATCH] [TF FE][Extensions] Support StringLower operation (#44) Signed-off-by: Kazantsev, Roman --- src/ov_extension.cpp | 1 + src/tensorflow_translators.cpp | 10 ++++++++++ src/tensorflow_translators.hpp | 1 + 3 files changed, 12 insertions(+) diff --git a/src/ov_extension.cpp b/src/ov_extension.cpp index 28f5d397b..0cb01d09f 100644 --- a/src/ov_extension.cpp +++ b/src/ov_extension.cpp @@ -36,6 +36,7 @@ OPENVINO_CREATE_EXTENSIONS( std::make_shared>(), std::make_shared("SentencepieceOp", translate_sentencepiece_op), std::make_shared("RaggedTensorToSparse", translate_sentencepiece_tokenizer), + std::make_shared("StringLower", translate_string_lower), })); //! [ov_extension:entry_point] // clang-format on diff --git a/src/tensorflow_translators.cpp b/src/tensorflow_translators.cpp index 56e72b644..2c5b4b397 100644 --- a/src/tensorflow_translators.cpp +++ b/src/tensorflow_translators.cpp @@ -151,3 +151,13 @@ ov::OutputVector translate_wordpiece_tokenize_with_offsets(const ov::frontend::N ); return { post_translate_ragged_tensor_output(wp_tokenizer->outputs()) }; } + +ov::OutputVector translate_string_lower(const ov::frontend::NodeContext& node) { + auto node_name = node.get_name(); + FRONT_END_GENERAL_CHECK(node.get_input_size() == 1, "StringLower expects only 1 input"); + auto encoding = node.get_attribute("encoding", ""); + ov::OutputVector inputs = pre_translate_string_tensor_input(node.get_input(0)); + auto string_lower_result = post_translate_string_tensor_output(std::make_shared(inputs, encoding)->outputs()); + set_node_name(node_name, string_lower_result.get_node_shared_ptr()); + return { string_lower_result }; +} diff --git a/src/tensorflow_translators.hpp b/src/tensorflow_translators.hpp index 9c1c263b6..941918c4c 100644 --- a/src/tensorflow_translators.hpp +++ b/src/tensorflow_translators.hpp @@ -13,3 +13,4 @@ ov::OutputVector translate_normalize_utf8(const ov::frontend::NodeContext& node) ov::OutputVector translate_static_regex_replace(const ov::frontend::NodeContext& node); ov::OutputVector translate_regex_split_with_offsets(const ov::frontend::NodeContext& node); ov::OutputVector translate_wordpiece_tokenize_with_offsets(const ov::frontend::NodeContext& node); +ov::OutputVector translate_string_lower(const ov::frontend::NodeContext& node);