OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Add reference implementations for `StringTensorPack-15` and `StringTensorUnpack-15` (#25941)
Przemyslaw Wysocki14901333acb2
diff --git a/src/core/include/openvino/op/string_tensor_unpack.hpp b/src/core/include/openvino/op/string_tensor_unpack.hppindex 0b70e60fc24..3c930e15b51 100644--- a/src/core/include/openvino/op/string_tensor_unpack.hpp+++ b/src/core/include/openvino/op/string_tensor_unpack.hpp@@ -18,7 +18,7 @@ public:StringTensorUnpack() = default;/// \brief Constructs a StringTensorUnpack operation.///- /// \param data Input strings encoded in utf-8 bytes+ /// \param data Input of type element::stringStringTensorUnpack(const Output<Node>& data);void validate_and_infer_types() override;diff --git a/src/core/include/openvino/opsets/opset15_tbl.hpp b/src/core/include/openvino/opsets/opset15_tbl.hppindex 4d85571d5b6..fee8e40fdf2 100644--- a/src/core/include/openvino/opsets/opset15_tbl.hpp+++ b/src/core/include/openvino/opsets/opset15_tbl.hpp@@ -18,5 +18,7 @@ _OPENVINO_OP_REG(ScatterNDUpdate, ov::op::v15)_OPENVINO_OP_REG(EmbeddingBagPacked, ov::op::v15)_OPENVINO_OP_REG(EmbeddingBagOffsets, ov::op::v15)_OPENVINO_OP_REG(Col2Im, ov::op::v15)+_OPENVINO_OP_REG(StringTensorUnpack, ov::op::v15)+_OPENVINO_OP_REG(StringTensorPack, ov::op::v15)_OPENVINO_OP_REG(BitwiseLeftShift, ov::op::v15)_OPENVINO_OP_REG(BitwiseRightShift, ov::op::v15)diff --git a/src/core/reference/include/openvino/reference/string_tensor_pack.hpp b/src/core/reference/include/openvino/reference/string_tensor_pack.hppnew file mode 100644index 00000000000..4ddff0c1a58--- /dev/null+++ b/src/core/reference/include/openvino/reference/string_tensor_pack.hpp@@ -0,0 +1,22 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once+#include "openvino/core/shape.hpp"++namespace ov {+namespace reference {+template <typename T_idx>+void string_tensor_pack(const T_idx* begins,+ const T_idx* ends,+ const uint8_t* symbols,+ std::string* out,+ const size_t string_count) {+ const char* chars = reinterpret_cast<const char*>(symbols);+ for (size_t i = 0; i < string_count; ++i) {+ out[i].assign(chars + begins[i], chars + ends[i]);+ }+}+} // namespace reference+} // namespace ovdiff --git a/src/core/reference/include/openvino/reference/string_tensor_unpack.hpp b/src/core/reference/include/openvino/reference/string_tensor_unpack.hppnew file mode 100644index 00000000000..1e5b24870e3--- /dev/null+++ b/src/core/reference/include/openvino/reference/string_tensor_unpack.hpp@@ -0,0 +1,24 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once+#include "openvino/core/shape.hpp"++namespace ov {+namespace reference {+void string_tensor_unpack(const std::string* data,+ int32_t* out_begins,+ int32_t* out_ends,+ uint8_t* out_symbols,+ const size_t element_count) {+ int32_t offset = 0;+ for (size_t i = 0; i < element_count; ++i) {+ out_begins[i] = offset;+ out_symbols = std::copy(data[i].begin(), data[i].end(), out_symbols);+ offset += static_cast<int32_t>(data[i].length());+ out_ends[i] = offset;+ }+}+} // namespace reference+} // namespace ovdiff --git a/src/core/shape_inference/include/string_tensor_pack_shape_inference.hpp b/src/core/shape_inference/include/string_tensor_pack_shape_inference.hppindex cb22d3d93fa..f87e69283e0 100644--- a/src/core/shape_inference/include/string_tensor_pack_shape_inference.hpp+++ b/src/core/shape_inference/include/string_tensor_pack_shape_inference.hpp@@ -26,12 +26,10 @@ static void validate_indices(const size_t input_index,NODE_SHAPE_INFER_CHECK(op, input_shapes, (*data)[0] >= 0, "Indices cannot be negative.");const auto& symbols_shape = input_shapes[2];if (symbols_shape.is_static()) {- // ends indices are offset by 1- const auto biggest_idx = symbols_shape[0].get_length() + (input_index == 0 ? 0 : 1);NODE_SHAPE_INFER_CHECK(op,input_shapes,- ov::cmp::lt(data->back(), biggest_idx),+ ov::cmp::le(data->back(), symbols_shape[0].get_length()),"The biggest index cannot be higher than the amount or characters in symbols input.");}const auto are_indices_ascending = std::is_sorted(data->begin(), data->end());@@ -50,18 +48,14 @@ std::vector<TRShape> shape_infer(const StringTensorPack* op,util::validate_indices(1, tensor_accessor, op, input_shapes);const auto& begins_shape = input_shapes[0];const auto& ends_shape = input_shapes[1];- NODE_SHAPE_INFER_CHECK(op, input_shapes, begins_shape.compatible(ends_shape));const auto& symbols_shape = input_shapes[2];NODE_SHAPE_INFER_CHECK(op, input_shapes, symbols_shape.rank().compatible(1), "Symbols input must be 1D.");-- // begins_shape and ends_shape always have to match- auto output_shapes = std::vector<TRShape>();- if (begins_shape.is_dynamic() && ends_shape.is_static()) {- output_shapes.push_back(ends_shape);- } else {- output_shapes.push_back(begins_shape);- }- return {std::move(output_shapes)};+ auto output_shapes = std::vector<TRShape>{begins_shape};+ NODE_SHAPE_INFER_CHECK(op,+ input_shapes,+ TRShape::merge_into(output_shapes[0], ends_shape),+ "The shapes of begins and ends have to be compatible.");+ return output_shapes;}} // namespace v15} // namespace opdiff --git a/src/core/shape_inference/include/string_tensor_unpack_shape_inference.hpp b/src/core/shape_inference/include/string_tensor_unpack_shape_inference.hppindex f7b79504764..a218c92eb9c 100644--- a/src/core/shape_inference/include/string_tensor_unpack_shape_inference.hpp+++ b/src/core/shape_inference/include/string_tensor_unpack_shape_inference.hpp@@ -31,18 +31,14 @@ std::vector<TRShape> shape_infer(const StringTensorUnpack* op,NODE_VALIDATION_CHECK(op, input_shapes.size() == 1);const auto& data_shape = input_shapes[0];auto output_shapes = std::vector<TRShape>{data_shape, data_shape};- if (data_shape.is_static()) {- if (const auto string_data = util::get_string_tensor(op, tensor_accessor)) {- const auto string_count = string_data.get_size();- const auto tensor_data = string_data.data<std::string>();- size_t total_length = 0;- for (auto it = tensor_data; it != std::next(tensor_data, string_count); ++it) {- total_length += (*it).length();- }- output_shapes.emplace_back(TRShape{static_cast<typename TRShape::value_type>(total_length)});- } else {- output_shapes.emplace_back(ov::PartialShape{ov::Dimension::dynamic()});+ if (const auto string_data = util::get_string_tensor(op, tensor_accessor)) {+ const auto string_count = string_data.get_size();+ const auto tensor_data = string_data.data<std::string>();+ size_t total_length = 0;+ for (auto it = tensor_data; it != std::next(tensor_data, string_count); ++it) {+ total_length += (*it).length();}+ output_shapes.emplace_back(TRShape{static_cast<typename TRShape::value_type>(total_length)});} else {output_shapes.emplace_back(ov::PartialShape{ov::Dimension::dynamic()});}diff --git a/src/core/tests/opset.cpp b/src/core/tests/opset.cppindex 3692ad5823f..fe3c3290d51 100644--- a/src/core/tests/opset.cpp+++ b/src/core/tests/opset.cpp@@ -75,7 +75,7 @@ INSTANTIATE_TEST_SUITE_P(opset,OpsetTestParams{ov::get_opset12, 178},OpsetTestParams{ov::get_opset13, 186},OpsetTestParams{ov::get_opset14, 188},- OpsetTestParams{ov::get_opset15, 10}),+ OpsetTestParams{ov::get_opset15, 12}),OpsetTestNameGenerator{});class MyOpOld : public ov::op::Op {diff --git a/src/core/tests/type_prop/string_tensor_pack.cpp b/src/core/tests/type_prop/string_tensor_pack.cppindex 005ee56efef..a81aa8eeb1f 100644--- a/src/core/tests/type_prop/string_tensor_pack.cpp+++ b/src/core/tests/type_prop/string_tensor_pack.cpp@@ -67,7 +67,7 @@ TEST_F(TypePropStringTensorPackV15Test, ends_static_begins_dynamic) {EXPECT_EQ(op->get_output_element_type(0), element::string);EXPECT_EQ(op->get_output_partial_shape(0), ends_shape);- EXPECT_EQ(get_shape_symbols(op->get_output_partial_shape(0)), ends_symbols);+ EXPECT_EQ(get_shape_symbols(op->get_output_partial_shape(0)), begins_symbols);}TEST_F(TypePropStringTensorPackV15Test, default_case) {@@ -105,7 +105,7 @@ TEST_F(TypePropStringTensorPackV15Test, begins_ends_shape_mismatch) {const auto symbols = std::make_shared<Parameter>(element::u8, PartialShape{100});OV_EXPECT_THROW(std::ignore = make_op(begins, ends, symbols),NodeValidationFailure,- HasSubstr("Check 'begins_shape.compatible(ends_shape)' failed"));+ HasSubstr("The shapes of begins and ends have to be compatible"));}TEST_F(TypePropStringTensorPackV15Test, incorrect_types) {diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/string_tensor_pack_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/string_tensor_pack_shape_inference_test.cppindex 1ddf2c8636d..3379651e11f 100644--- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/string_tensor_pack_shape_inference_test.cpp+++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/string_tensor_pack_shape_inference_test.cpp@@ -236,7 +236,7 @@ TEST_F(StringTensorPackStaticShapeInferenceWithTensorAccessorTest, indices_validtesting::HasSubstr("Indices cannot be negative"));}{ // begins out of bounds- int32_t begins[] = {1, 1, 1, 3};+ int32_t begins[] = {1, 1, 1, 4};int32_t ends[] = {1, 1, 2, 3};const auto const_inputs = std::unordered_map<size_t, Tensor>{{0, {element::i32, Shape{2, 2}, begins}},@@ -247,7 +247,7 @@ TEST_F(StringTensorPackStaticShapeInferenceWithTensorAccessorTest, indices_validtesting::HasSubstr("The biggest index cannot be higher than the amount or characters in symbols input"));}{ // ends out of bounds- int32_t begins[] = {1, 1, 1, 2};+ int32_t begins[] = {1, 1, 1, 3};int32_t ends[] = {1, 1, 2, 4};const auto const_inputs = std::unordered_map<size_t, Tensor>{{0, {element::i32, Shape{2, 2}, begins}},diff --git a/src/plugins/template/backend/ops/ops_evaluates.hpp b/src/plugins/template/backend/ops/ops_evaluates.hppindex 9bcd0d94b60..7f02386d41e 100644--- a/src/plugins/template/backend/ops/ops_evaluates.hpp+++ b/src/plugins/template/backend/ops/ops_evaluates.hpp@@ -535,3 +535,11 @@ extern template bool evaluate_node<ov::op::internal::AUGRUSequence>(std::shared_extern template bool evaluate_node<ov::op::internal::RMS>(std::shared_ptr<ov::Node> node,ov::TensorVector& outputs,const ov::TensorVector& inputs);++extern template bool evaluate_node<ov::op::v15::StringTensorUnpack>(std::shared_ptr<ov::Node> node,+ ov::TensorVector& outputs,+ const ov::TensorVector& inputs);++extern template bool evaluate_node<ov::op::v15::StringTensorPack>(std::shared_ptr<ov::Node> node,+ ov::TensorVector& outputs,+ const ov::TensorVector& inputs);diff --git a/src/plugins/template/backend/ops/string_tensor_pack.cpp b/src/plugins/template/backend/ops/string_tensor_pack.cppnew file mode 100644index 00000000000..dec0f8fd058--- /dev/null+++ b/src/plugins/template/backend/ops/string_tensor_pack.cpp@@ -0,0 +1,45 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/reference/string_tensor_pack.hpp"++#include "evaluate_node.hpp"+#include "string_tensor_pack_shape_inference.hpp"++template <>+bool evaluate_node<ov::op::v15::StringTensorPack>(std::shared_ptr<ov::Node> node,+ ov::TensorVector& outputs,+ const ov::TensorVector& inputs) {+ auto string_tensor_pack = std::dynamic_pointer_cast<ov::op::v15::StringTensorPack>(node);+ OPENVINO_ASSERT(string_tensor_pack, "Node passed to StringTensorPack evaluate function is invalid.");+ ov::Shape output_shape;+ output_shape = ov::op::v15::shape_infer(string_tensor_pack.get(),+ ov::util::get_tensors_partial_shapes(inputs),+ make_tensor_accessor(inputs))+ .front()+ .to_shape();+ outputs.front().set_shape(output_shape);+ const auto indices_type = node->get_input_element_type(0);+ const auto& data_shape = node->get_input_shape(0);+ int64_t string_count = std::accumulate(data_shape.begin(), data_shape.end(), 1, std::multiplies<int64_t>());+ switch (indices_type) {+ case ov::element::i32:+ ov::reference::string_tensor_pack(inputs[0].data<const int32_t>(),+ inputs[1].data<const int32_t>(),+ inputs[2].data<const uint8_t>(),+ outputs[0].data<std::string>(),+ string_count);+ break;+ case ov::element::i64:+ ov::reference::string_tensor_pack(inputs[0].data<const int64_t>(),+ inputs[1].data<const int64_t>(),+ inputs[2].data<const uint8_t>(),+ outputs[0].data<std::string>(),+ string_count);+ break;+ default:+ OPENVINO_THROW("Unhandled indices data type ", node->get_element_type().get_type_name(), " in evaluate_node()");+ }+ return true;+}diff --git a/src/plugins/template/backend/ops/string_tensor_unpack.cpp b/src/plugins/template/backend/ops/string_tensor_unpack.cppnew file mode 100644index 00000000000..31976202326--- /dev/null+++ b/src/plugins/template/backend/ops/string_tensor_unpack.cpp@@ -0,0 +1,37 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/reference/string_tensor_unpack.hpp"++#include "evaluate_node.hpp"+#include "string_tensor_unpack_shape_inference.hpp"++template <>+bool evaluate_node<ov::op::v15::StringTensorUnpack>(std::shared_ptr<ov::Node> node,+ ov::TensorVector& outputs,+ const ov::TensorVector& inputs) {+ if (node->get_input_element_type(0) == ov::element::string) {+ auto string_tensor_unpack = std::dynamic_pointer_cast<ov::op::v15::StringTensorUnpack>(node);+ OPENVINO_ASSERT(string_tensor_unpack, "Node passed to StringTensorUnpack evaluate function is invalid.");+ std::vector<ov::PartialShape> output_shapes;+ output_shapes = ov::op::v15::shape_infer(string_tensor_unpack.get(),+ ov::util::get_tensors_partial_shapes(inputs),+ make_tensor_accessor(inputs));+ auto outputs_it = outputs.begin();+ for (const auto& p_shape : output_shapes) {+ outputs_it->set_shape(p_shape.get_shape());+ ++outputs_it;+ }+ const auto& data_shape = node->get_input_shape(0);+ const auto element_count = shape_size(data_shape);+ ov::reference::string_tensor_unpack(inputs[0].data<const std::string>(),+ outputs[0].data<int32_t>(),+ outputs[1].data<int32_t>(),+ outputs[2].data<uint8_t>(),+ element_count);+ } else {+ OPENVINO_THROW("The input type for StringTensorUnpack operation must be ov::element::string.");+ }+ return true;+}diff --git a/src/plugins/template/backend/opset_int_tbl.hpp b/src/plugins/template/backend/opset_int_tbl.hppindex cce47e15111..f31f451454d 100644--- a/src/plugins/template/backend/opset_int_tbl.hpp+++ b/src/plugins/template/backend/opset_int_tbl.hpp@@ -169,6 +169,8 @@ _OPENVINO_OP_REG(ROIAlignRotated, ov::op::v15)_OPENVINO_OP_REG(EmbeddingBagOffsets, op::v15)_OPENVINO_OP_REG(EmbeddingBagPacked, op::v15)_OPENVINO_OP_REG(Col2Im, ov::op::v15)+_OPENVINO_OP_REG(StringTensorUnpack, ov::op::v15)+_OPENVINO_OP_REG(StringTensorPack, ov::op::v15)_OPENVINO_OP_REG(BitwiseLeftShift, ov::op::v15)_OPENVINO_OP_REG(BitwiseRightShift, ov::op::v15)diff --git a/src/plugins/template/tests/functional/op_reference/string_tensor_pack.cpp b/src/plugins/template/tests/functional/op_reference/string_tensor_pack.cppnew file mode 100644index 00000000000..0cfcff46b93--- /dev/null+++ b/src/plugins/template/tests/functional/op_reference/string_tensor_pack.cpp@@ -0,0 +1,181 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/string_tensor_pack.hpp"++#include <gtest/gtest.h>++#include "base_reference_test.hpp"++namespace {+struct StringTensorPackParams {+ StringTensorPackParams(const reference_tests::Tensor& beginsTensor,+ const reference_tests::Tensor& endsTensor,+ const reference_tests::Tensor& symbolsTensor,+ const reference_tests::Tensor& stringTensor)+ : beginsTensor(beginsTensor),+ endsTensor(endsTensor),+ symbolsTensor(symbolsTensor),+ stringTensor(stringTensor) {}++ reference_tests::Tensor beginsTensor;+ reference_tests::Tensor endsTensor;+ reference_tests::Tensor symbolsTensor;+ reference_tests::Tensor stringTensor;+};++class ReferenceStringTensorPackV15LayerTest : public testing::TestWithParam<StringTensorPackParams>,+ public reference_tests::CommonReferenceTest {+protected:+ void SetUp() override {+ const auto& params = GetParam();+ function = CreateFunction(params);+ inputData = {params.beginsTensor.data, params.endsTensor.data, params.symbolsTensor.data};+ refOutData = {params.stringTensor.data};+ }++public:+ static std::string getTestCaseName(const testing::TestParamInfo<StringTensorPackParams>& obj) {+ auto param = obj.param;+ std::ostringstream result;+ result << "indicesShape=" << param.beginsTensor.shape;+ result << "_indicesType=" << param.beginsTensor.type;+ result << "_symbolsShape=" << param.symbolsTensor.shape;+ return result.str();+ }++private:+ static std::shared_ptr<ov::Model> CreateFunction(const StringTensorPackParams& params) {+ const auto begins =+ std::make_shared<ov::op::v0::Parameter>(params.beginsTensor.type, params.beginsTensor.shape);+ const auto ends = std::make_shared<ov::op::v0::Parameter>(params.endsTensor.type, params.endsTensor.shape);+ const auto symbols =+ std::make_shared<ov::op::v0::Parameter>(params.symbolsTensor.type, params.symbolsTensor.shape);+ const auto string_tensor_pack = std::make_shared<ov::op::v15::StringTensorPack>(begins, ends, symbols);+ return std::make_shared<ov::Model>(ov::OutputVector{string_tensor_pack->outputs()},+ ov::ParameterVector{begins, ends, symbols},+ ov::op::util::VariableVector{});+ }+};++TEST_P(ReferenceStringTensorPackV15LayerTest, CompareWithRefs) {+ Exec();+}++template <ov::element::Type_t T_idx>+std::vector<StringTensorPackParams> generateStringTensorPackParams() {+ using ov::element::Type_t;+ using reference_tests::Tensor;+ using T_I = typename ov::element_type_traits<T_idx>::value_type;+ const std::vector<StringTensorPackParams> StringTensorPackParamsList{+ // simple 1D case+ StringTensorPackParams(+ Tensor({2}, T_idx, std::vector<T_I>{0, 5}),+ Tensor({2}, T_idx, std::vector<T_I>{5, 13}),+ Tensor({13},+ ov::element::u8,+ std::vector<uint8_t>{0x49, 0x6e, 0x74, 0x65, 0x6c, 0x4f, 0x70, 0x65, 0x6e, 0x56, 0x49, 0x4e, 0x4f}),+ Tensor({2}, ov::element::string, std::vector<std::string>{"Intel", "OpenVINO"})),+ // 2D strings with spaces and an empty string+ StringTensorPackParams(+ Tensor({1, 5}, T_idx, std::vector<T_I>{0, 10, 13, 22, 22}),+ Tensor({1, 5}, T_idx, std::vector<T_I>{10, 13, 22, 22, 45}),++ Tensor({45}, ov::element::u8, std::vector<uint8_t>{0x49, 0x6e, 0x74, 0x65, 0x6c, 0x20, 0x43, 0x6f, 0x72,+ 0x70, 0x20, 0x20, 0x20, 0x4f, 0x70, 0x65, 0x6e, 0x20,+ 0x56, 0x49, 0x4e, 0x4f, 0x41, 0x72, 0x74, 0x69, 0x66,+ 0x69, 0x63, 0x69, 0x61, 0x6c, 0x20, 0x49, 0x6e, 0x74,+ 0x65, 0x6c, 0x6c, 0x69, 0x67, 0x65, 0x6e, 0x63, 0x65}),+ Tensor({1, 5},+ ov::element::string,+ std::vector<std::string>{"Intel Corp", " ", "Open VINO", "", "Artificial Intelligence"})),+ // strings with special characters+ StringTensorPackParams(+ Tensor({3}, T_idx, std::vector<T_I>{0, 6, 15}),+ Tensor({3}, T_idx, std::vector<T_I>{6, 15, 18}),+ Tensor({18},+ ov::element::u8,+ std::vector<uint8_t>{0x49,+ 0x6e,+ 0x40,+ 0x74,+ 0x65,+ 0x6c,+ 0x4f,+ 0x70,+ 0x65,+ 0x6e,+ 0x23,+ 0x56,+ 0x49,+ 0x4e,+ 0x4f,+ 0x41,+ 0x24,+ 0x49}),+ Tensor({3}, ov::element::string, std::vector<std::string>{"In@tel", "Open#VINO", "A$I"})),+ // (2, 2, 2) data shape+ StringTensorPackParams(+ Tensor({2, 2, 2}, T_idx, std::vector<T_I>{0, 5, 13, 15, 19, 27, 33, 39}),+ Tensor({2, 2, 2}, T_idx, std::vector<T_I>{5, 13, 15, 19, 27, 33, 39, 47}),+ Tensor({47},+ ov::element::u8,+ std::vector<uint8_t>{0x49, 0x6e, 0x74, 0x65, 0x6c, 0x4f, 0x70, 0x65, 0x6e, 0x56, 0x49, 0x4e,+ 0x4f, 0x41, 0x49, 0x45, 0x64, 0x67, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x75,+ 0x74, 0x65, 0x72, 0x56, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x65, 0x75,+ 0x72, 0x61, 0x6c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73}),+ Tensor({2, 2, 2},+ ov::element::string,+ std::vector<+ std::string>{"Intel", "OpenVINO", "AI", "Edge", "Computer", "Vision", "Neural", "Networks"})),+ // single, empty string+ StringTensorPackParams(Tensor({1, 1, 1, 1}, T_idx, std::vector<T_I>{0}),+ Tensor({1, 1, 1, 1}, T_idx, std::vector<T_I>{0}),+ Tensor({0}, ov::element::u8, std::vector<uint8_t>{}),+ Tensor({1, 1, 1, 1}, ov::element::string, std::vector<std::string>{""})),+ // empty data+ StringTensorPackParams(Tensor({0}, T_idx, std::vector<T_I>{}),+ Tensor({0}, T_idx, std::vector<T_I>{}),+ Tensor({0}, ov::element::u8, std::vector<uint8_t>{}),+ Tensor({0}, ov::element::string, std::vector<std::string>{})),+ // skipped symbols+ StringTensorPackParams(+ Tensor({1, 2}, T_idx, std::vector<T_I>{0, 8}),+ Tensor({1, 2}, T_idx, std::vector<T_I>{3, 13}),+ Tensor({13},+ ov::element::u8,+ std::vector<uint8_t>{0x49, 0x6e, 0x74, 0x65, 0x6c, 0x4f, 0x70, 0x65, 0x6e, 0x56, 0x49, 0x4e, 0x4f}),+ Tensor({1, 2}, ov::element::string, std::vector<std::string>{"Int", "nVINO"})),+ // empty string at the end+ StringTensorPackParams(+ Tensor({1, 3}, T_idx, std::vector<T_I>{0, 5, 13}),+ Tensor({1, 3}, T_idx, std::vector<T_I>{5, 13, 13}),+ Tensor({13},+ ov::element::u8,+ std::vector<uint8_t>{0x49, 0x6e, 0x74, 0x65, 0x6c, 0x4f, 0x70, 0x65, 0x6e, 0x56, 0x49, 0x4e, 0x4f}),+ Tensor({1, 3}, ov::element::string, std::vector<std::string>{"Intel", "OpenVINO", ""})),+ };+ return StringTensorPackParamsList;+}++std::vector<StringTensorPackParams> generateStringTensorPackV15CombinedParams() {+ using ov::element::Type_t;+ const std::vector<std::vector<StringTensorPackParams>> stringTensorPackTypeParams{+ generateStringTensorPackParams<Type_t::i32>(),+ generateStringTensorPackParams<Type_t::i64>(),+ };++ std::vector<StringTensorPackParams> combinedParams;+ for (const auto& params : stringTensorPackTypeParams) {+ combinedParams.insert(combinedParams.end(), params.begin(), params.end());+ }+ return combinedParams;+}++INSTANTIATE_TEST_SUITE_P(smoke_StringTensorPack_With_Hardcoded_Refs,+ ReferenceStringTensorPackV15LayerTest,+ testing::ValuesIn(generateStringTensorPackV15CombinedParams()),+ ReferenceStringTensorPackV15LayerTest::getTestCaseName);++} // namespacediff --git a/src/plugins/template/tests/functional/op_reference/string_tensor_unpack.cpp b/src/plugins/template/tests/functional/op_reference/string_tensor_unpack.cppnew file mode 100644index 00000000000..5719a17b0a6--- /dev/null+++ b/src/plugins/template/tests/functional/op_reference/string_tensor_unpack.cpp@@ -0,0 +1,142 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/string_tensor_unpack.hpp"++#include <gtest/gtest.h>++#include "base_reference_test.hpp"++namespace {+struct StringTensorUnpackParams {+ StringTensorUnpackParams(const reference_tests::Tensor& dataTensor,+ const reference_tests::Tensor& beginsTensor,+ const reference_tests::Tensor& endsTensor,+ const reference_tests::Tensor& symbolsTensor)+ : dataTensor(dataTensor),+ beginsTensor(beginsTensor),+ endsTensor(endsTensor),+ symbolsTensor(symbolsTensor) {}++ reference_tests::Tensor dataTensor;+ reference_tests::Tensor beginsTensor;+ reference_tests::Tensor endsTensor;+ reference_tests::Tensor symbolsTensor;+};++class ReferenceStringTensorUnpackV15LayerTest : public testing::TestWithParam<StringTensorUnpackParams>,+ public reference_tests::CommonReferenceTest {+protected:+ void SetUp() override {+ const auto& params = GetParam();+ function = CreateFunction(params);+ inputData = {params.dataTensor.data};+ refOutData = {params.beginsTensor.data, params.endsTensor.data, params.symbolsTensor.data};+ }++public:+ static std::string getTestCaseName(const testing::TestParamInfo<StringTensorUnpackParams>& obj) {+ auto param = obj.param;+ std::ostringstream result;+ result << "dShape=" << param.dataTensor.shape;+ return result.str();+ }++private:+ static std::shared_ptr<ov::Model> CreateFunction(const StringTensorUnpackParams& params) {+ const auto data = std::make_shared<ov::op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);+ const auto string_tensor_unpack = std::make_shared<ov::op::v15::StringTensorUnpack>(data);+ return std::make_shared<ov::Model>(ov::OutputVector{string_tensor_unpack->outputs()},+ ov::ParameterVector{data},+ ov::op::util::VariableVector{});+ }+};++TEST_P(ReferenceStringTensorUnpackV15LayerTest, CompareWithRefs) {+ Exec();+}++std::vector<StringTensorUnpackParams> generateStringTensorUnpackParams() {+ using ov::element::Type_t;+ using reference_tests::Tensor;+ const std::vector<StringTensorUnpackParams> stringTensorUnpackParams{+ // simple 1D case+ StringTensorUnpackParams(+ Tensor({2}, ov::element::string, std::vector<std::string>{"Intel", "OpenVINO"}),+ Tensor({2}, ov::element::i32, std::vector<int32_t>{0, 5}),+ Tensor({2}, ov::element::i32, std::vector<int32_t>{5, 13}),+ Tensor({13},+ ov::element::u8,+ std::vector<uint8_t>{0x49, 0x6e, 0x74, 0x65, 0x6c, 0x4f, 0x70, 0x65, 0x6e, 0x56, 0x49, 0x4e, 0x4f})),+ // 2D strings with spaces and an empty string+ StringTensorUnpackParams(+ Tensor({1, 5},+ ov::element::string,+ std::vector<std::string>{"Intel Corp", " ", "Open VINO", "", "Artificial Intelligence"}),+ Tensor({1, 5}, ov::element::i32, std::vector<int32_t>{0, 10, 13, 22, 22}),+ Tensor({1, 5}, ov::element::i32, std::vector<int32_t>{10, 13, 22, 22, 45}),+ Tensor({45}, ov::element::u8, std::vector<uint8_t>{0x49, 0x6e, 0x74, 0x65, 0x6c, 0x20, 0x43, 0x6f, 0x72,+ 0x70, 0x20, 0x20, 0x20, 0x4f, 0x70, 0x65, 0x6e, 0x20,+ 0x56, 0x49, 0x4e, 0x4f, 0x41, 0x72, 0x74, 0x69, 0x66,+ 0x69, 0x63, 0x69, 0x61, 0x6c, 0x20, 0x49, 0x6e, 0x74,+ 0x65, 0x6c, 0x6c, 0x69, 0x67, 0x65, 0x6e, 0x63, 0x65})),+ // strings with special characters+ StringTensorUnpackParams(+ Tensor({3}, ov::element::string, std::vector<std::string>{"In@tel", "Open#VINO", "A$I"}),+ Tensor({3}, ov::element::i32, std::vector<int32_t>{0, 6, 15}),+ Tensor({3}, ov::element::i32, std::vector<int32_t>{6, 15, 18}),+ Tensor({18},+ ov::element::u8,+ std::vector<uint8_t>{0x49,+ 0x6e,+ 0x40,+ 0x74,+ 0x65,+ 0x6c,+ 0x4f,+ 0x70,+ 0x65,+ 0x6e,+ 0x23,+ 0x56,+ 0x49,+ 0x4e,+ 0x4f,+ 0x41,+ 0x24,+ 0x49})),+ // (2, 2, 2) data shape+ StringTensorUnpackParams(+ Tensor({2, 2, 2},+ ov::element::string,+ std::vector<+ std::string>{"Intel", "OpenVINO", "AI", "Edge", "Computer", "Vision", "Neural", "Networks"}),+ Tensor({2, 2, 2}, ov::element::i32, std::vector<int32_t>{0, 5, 13, 15, 19, 27, 33, 39}),+ Tensor({2, 2, 2}, ov::element::i32, std::vector<int32_t>{5, 13, 15, 19, 27, 33, 39, 47}),+ Tensor({47},+ ov::element::u8,+ std::vector<uint8_t>{0x49, 0x6e, 0x74, 0x65, 0x6c, 0x4f, 0x70, 0x65, 0x6e, 0x56, 0x49, 0x4e,+ 0x4f, 0x41, 0x49, 0x45, 0x64, 0x67, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x75,+ 0x74, 0x65, 0x72, 0x56, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x65, 0x75,+ 0x72, 0x61, 0x6c, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73})),+ // single, empty string+ StringTensorUnpackParams(Tensor({1, 1, 1, 1}, ov::element::string, std::vector<std::string>{""}),+ Tensor({1, 1, 1, 1}, ov::element::i32, std::vector<int32_t>{0}),+ Tensor({1, 1, 1, 1}, ov::element::i32, std::vector<int32_t>{0}),+ Tensor({0}, ov::element::u8, std::vector<uint8_t>{})),+ // empty data+ StringTensorUnpackParams(Tensor({0}, ov::element::string, std::vector<std::string>{}),+ Tensor({0}, ov::element::i32, std::vector<int32_t>{}),+ Tensor({0}, ov::element::i32, std::vector<int32_t>{}),+ Tensor({0}, ov::element::u8, std::vector<uint8_t>{})),+ };+ return stringTensorUnpackParams;+}++INSTANTIATE_TEST_SUITE_P(smoke_StringTensorUnpack_With_Hardcoded_Refs,+ ReferenceStringTensorUnpackV15LayerTest,+ testing::ValuesIn(generateStringTensorUnpackParams()),+ ReferenceStringTensorUnpackV15LayerTest::getTestCaseName);++} // namespacediff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cppindex 73595dfd1dc..aa46f0cb123 100644--- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp+++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/src/op_impl_check/single_op_graph.cpp@@ -1913,6 +1913,22 @@ std::shared_ptr<ov::Model> generate(const std::shared_ptr<ov::op::v15::Col2Im> &return std::make_shared<ov::Model>(results, ov::ParameterVector{data}, "Col2ImGraph");}+std::shared_ptr<ov::Model> generate(const std::shared_ptr<ov::op::v15::StringTensorUnpack> &node) {+ const auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::string, ov::PartialShape{2});+ const auto StringTensorUnpackNode = std::make_shared<ov::op::v15::StringTensorUnpack>(data);+ ov::ResultVector results{std::make_shared<ov::op::v0::Result>(StringTensorUnpackNode)};+ return std::make_shared<ov::Model>(results, ov::ParameterVector{data}, "StringTensorUnpackGraph");+}++std::shared_ptr<ov::Model> generate(const std::shared_ptr<ov::op::v15::StringTensorPack> &node) {+ const auto begins = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, ov::PartialShape{2});+ const auto ends = std::make_shared<ov::op::v0::Parameter>(ov::element::i32, ov::PartialShape{2});+ const auto symbols = std::make_shared<ov::op::v0::Parameter>(ov::element::u8, ov::PartialShape{5});+ const auto StringTensorPackNode = std::make_shared<ov::op::v15::StringTensorPack>(begins, ends, symbols);+ ov::ResultVector results{std::make_shared<ov::op::v0::Result>(StringTensorPackNode)};+ return std::make_shared<ov::Model>(results, ov::ParameterVector{begins, ends, symbols}, "StringTensorPackGraph");+}+std::shared_ptr<ov::Model> generateRNNCellBase(const std::shared_ptr<ov::op::Op> &node) {std::shared_ptr<ov::Node> RNNCellBaseNode;if (ov::is_type<ov::op::v3::GRUCell>(node)) {