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
Extend CPU Plugin with reference implementations of `StringTensorUnpack-15` and `StringTensorPack-15` (#26119)
Przemyslaw Wysocki963e3e1c46e9
diff --git a/src/core/reference/include/openvino/reference/string_tensor_unpack.hpp b/src/core/reference/include/openvino/reference/string_tensor_unpack.hppindex 1e5b24870e3..3bd4f76f398 100644--- a/src/core/reference/include/openvino/reference/string_tensor_unpack.hpp+++ b/src/core/reference/include/openvino/reference/string_tensor_unpack.hpp@@ -7,11 +7,11 @@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) {+inline 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;diff --git a/src/plugins/intel_cpu/src/cpu_types.cpp b/src/plugins/intel_cpu/src/cpu_types.cppindex 759f771a1f6..ff08009005e 100644--- a/src/plugins/intel_cpu/src/cpu_types.cpp+++ b/src/plugins/intel_cpu/src/cpu_types.cpp@@ -150,6 +150,8 @@ static const TypeToNameMap& get_type_to_name_tbl() {{"ScatterUpdate", Type::ScatterUpdate},{"ScatterElementsUpdate", Type::ScatterElementsUpdate},{"ScatterNDUpdate", Type::ScatterNDUpdate},+ {"StringTensorPack", Type::StringTensorPack},+ {"StringTensorUnpack", Type::StringTensorUnpack},{"Interpolate", Type::Interpolate},{"RandomUniform", Type::RandomUniform},{"ReduceL1", Type::Reduce},@@ -314,6 +316,8 @@ std::string NameFromType(const Type type) {CASE(ScatterUpdate);CASE(ScatterElementsUpdate);CASE(ScatterNDUpdate);+ CASE(StringTensorPack);+ CASE(StringTensorUnpack);CASE(Interaction);CASE(Interpolate);CASE(Reduce);diff --git a/src/plugins/intel_cpu/src/cpu_types.h b/src/plugins/intel_cpu/src/cpu_types.hindex 6624b21b3e8..d98129ef9b7 100644--- a/src/plugins/intel_cpu/src/cpu_types.h+++ b/src/plugins/intel_cpu/src/cpu_types.h@@ -67,6 +67,8 @@ enum class Type {ScatterUpdate,ScatterElementsUpdate,ScatterNDUpdate,+ StringTensorPack,+ StringTensorUnpack,Interpolate,Reduce,Broadcast,diff --git a/src/plugins/intel_cpu/src/nodes/string_tensor_pack.cpp b/src/plugins/intel_cpu/src/nodes/string_tensor_pack.cppnew file mode 100644index 00000000000..5ecb15b57fb--- /dev/null+++ b/src/plugins/intel_cpu/src/nodes/string_tensor_pack.cpp@@ -0,0 +1,93 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "string_tensor_pack.h"+#include "openvino/reference/string_tensor_pack.hpp"+#include "openvino/op/string_tensor_pack.hpp"++namespace ov {+namespace intel_cpu {+namespace node {+StringTensorPack::StringTensorPack(const std::shared_ptr<ov::Node>& op, const GraphContext::CPtr context)+ : Node(op, context, NgraphShapeInferFactory(op, PortMask(0, 1))) {+ std::string errorMessage;+ if (!isSupportedOperation(op, errorMessage)) {+ OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage);+ }+}++bool StringTensorPack::isSupportedOperation(const std::shared_ptr<const ov::Node>& op, std::string& errorMessage) noexcept {+ try {+ if (!ov::is_type<ov::op::v15::StringTensorPack>(op)) {+ errorMessage = "Only opset15 StringTensorPack operation is supported";+ return false;+ }+ } catch (...) {+ return false;+ }+ return true;+}++void StringTensorPack::getSupportedDescriptors() {+ // Validation is already done in the ov::opset15::StringTensorPack+}++void StringTensorPack::initSupportedPrimitiveDescriptors() {+ if (!supportedPrimitiveDescriptors.empty())+ return;+ ov::element::Type indicesPrecision = getOriginalInputPrecisionAtPort(0);+ addSupportedPrimDesc(+ {{LayoutType::ncsp, indicesPrecision}, {LayoutType::ncsp, indicesPrecision}, {LayoutType::ncsp, ov::element::u8}},+ {{LayoutType::ncsp, ov::element::string}},+ impl_desc_type::ref);+}++bool StringTensorPack::created() const {+ return getType() == Type::StringTensorPack;+}++bool StringTensorPack::needPrepareParams() const {+ return false;+}++void StringTensorPack::executeDynamicImpl(dnnl::stream strm) {+ execute(strm);+}++template <class T_idx>+void StringTensorPack::executeImpl() {+ const auto& data_shape = getSrcMemoryAtPort(0)->getStaticDims();+ ov::reference::string_tensor_pack(+ getSrcDataAtPortAs<const T_idx>(0),+ getSrcDataAtPortAs<const T_idx>(1),+ getSrcDataAtPortAs<const uint8_t>(2),+ getDstDataAtPortAs<std::string>(0),+ ov::shape_size(data_shape));+}++namespace {+struct StringTensorPackContext {+ StringTensorPack &node;+};+}++template<typename T_idx>+struct StringTensorPack::StringTensorPackExecute {+ void operator()(StringTensorPackContext& ctx) {+ ctx.node.executeImpl<T_idx>();+ }+};++void StringTensorPack::execute(dnnl::stream strm) {+ auto indicesPrecision = getParentEdgeAt(0)->getMemory().getDesc().getPrecision();+ StringTensorPackContext ctx = {+ *this+ };+ OV_SWITCH(intel_cpu, StringTensorPackExecute, ctx, indicesPrecision,+ OV_CASE(ov::element::i32, int32_t),+ OV_CASE(ov::element::i64, int64_t))+}+} // namespace node+} // namespace intel_cpu+} // namespace ovdiff --git a/src/plugins/intel_cpu/src/nodes/string_tensor_pack.h b/src/plugins/intel_cpu/src/nodes/string_tensor_pack.hnew file mode 100644index 00000000000..57ebe63721e--- /dev/null+++ b/src/plugins/intel_cpu/src/nodes/string_tensor_pack.h@@ -0,0 +1,35 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "node.h"++namespace ov {+namespace intel_cpu {+namespace node {++class StringTensorPack : public Node {+public:+ StringTensorPack(const std::shared_ptr<ov::Node>& op, const GraphContext::CPtr context);++ static bool isSupportedOperation(const std::shared_ptr<const ov::Node>& op, std::string& errorMessage) noexcept;+ void getSupportedDescriptors() override;+ void initSupportedPrimitiveDescriptors() override;+ void execute(dnnl::stream strm) override;+ bool created() const override;+ bool needPrepareParams() const override;+ void executeDynamicImpl(dnnl::stream strm) override;++private:+ template <class OV_INDEX_TYPE>+ void executeImpl();++ template<typename T_idx>+ struct StringTensorPackExecute;+};++} // namespace node+} // namespace intel_cpu+} // namespace ovdiff --git a/src/plugins/intel_cpu/src/nodes/string_tensor_unpack.cpp b/src/plugins/intel_cpu/src/nodes/string_tensor_unpack.cppnew file mode 100644index 00000000000..06eb2f149d0--- /dev/null+++ b/src/plugins/intel_cpu/src/nodes/string_tensor_unpack.cpp@@ -0,0 +1,78 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "string_tensor_unpack.h"+#include "openvino/reference/string_tensor_unpack.hpp"+#include "openvino/op/string_tensor_unpack.hpp"+#include "shape_inference/shape_inference_internal_dyn.hpp"++namespace ov {+namespace intel_cpu {+namespace node {+StringTensorUnpack::StringTensorUnpack(const std::shared_ptr<ov::Node>& op, const GraphContext::CPtr context)+ : Node(op, context, InternalDynShapeInferFactory()) {+ std::string errorMessage;+ if (!isSupportedOperation(op, errorMessage)) {+ OPENVINO_THROW_NOT_IMPLEMENTED(errorMessage);+ }+}++bool StringTensorUnpack::isSupportedOperation(const std::shared_ptr<const ov::Node>& op, std::string& errorMessage) noexcept {+ try {+ if (!ov::is_type<ov::op::v15::StringTensorUnpack>(op)) {+ errorMessage = "Only opset15 StringTensorUnpack operation is supported";+ return false;+ }+ } catch (...) {+ return false;+ }+ return true;+}++void StringTensorUnpack::getSupportedDescriptors() {+ // Validation is already done in the ov::opset15::StringTensorUnpack+}++void StringTensorUnpack::initSupportedPrimitiveDescriptors() {+ if (!supportedPrimitiveDescriptors.empty())+ return;+ addSupportedPrimDesc(+ {{LayoutType::ncsp, ov::element::string}},+ {{LayoutType::ncsp, ov::element::i32}, {LayoutType::ncsp, ov::element::i32}, {LayoutType::ncsp, ov::element::u8}},+ impl_desc_type::ref);+}++bool StringTensorUnpack::created() const {+ return getType() == Type::StringTensorUnpack;+}++bool StringTensorUnpack::needPrepareParams() const {+ return false;+}++void StringTensorUnpack::executeDynamicImpl(dnnl::stream strm) {+ const auto& srcMemory = getSrcMemoryAtPort(0);+ const auto& srcDataDims = srcMemory->getStaticDims();+ const auto& srcData = srcMemory->getDataAs<std::string>();+ Dim stringCount = std::accumulate(srcDataDims.begin(), srcDataDims.end(), 1, std::multiplies<Dim>());+ size_t totalCharLength = 0;+ for (Dim i = 0; i < stringCount; ++i) {+ totalCharLength += srcData[i].length();+ }+ redefineOutputMemory({ srcDataDims, srcDataDims, {totalCharLength}});+ execute(strm);+}++void StringTensorUnpack::execute(dnnl::stream strm) {+ const auto stringCount = ov::shape_size(getSrcMemoryAtPort(0)->getStaticDims());+ ov::reference::string_tensor_unpack(+ getSrcDataAtPortAs<const std::string>(0),+ getDstDataAtPortAs<int32_t>(0),+ getDstDataAtPortAs<int32_t>(1),+ getDstDataAtPortAs<uint8_t>(2),+ stringCount);+}+} // namespace node+} // namespace intel_cpu+} // namespace ovdiff --git a/src/plugins/intel_cpu/src/nodes/string_tensor_unpack.h b/src/plugins/intel_cpu/src/nodes/string_tensor_unpack.hnew file mode 100644index 00000000000..8dee5ee6c01--- /dev/null+++ b/src/plugins/intel_cpu/src/nodes/string_tensor_unpack.h@@ -0,0 +1,28 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "node.h"++namespace ov {+namespace intel_cpu {+namespace node {++class StringTensorUnpack : public Node {+public:+ StringTensorUnpack(const std::shared_ptr<ov::Node>& op, const GraphContext::CPtr context);++ static bool isSupportedOperation(const std::shared_ptr<const ov::Node>& op, std::string& errorMessage) noexcept;+ void getSupportedDescriptors() override;+ void initSupportedPrimitiveDescriptors() override;+ void execute(dnnl::stream strm) override;+ bool created() const override;+ bool needPrepareParams() const override;+ void executeDynamicImpl(dnnl::stream strm) override;+};++} // namespace node+} // namespace intel_cpu+} // namespace ovdiff --git a/src/plugins/intel_cpu/src/nodes_factory.cpp b/src/plugins/intel_cpu/src/nodes_factory.cppindex 9012c37f5ac..4ae50fa1bad 100644--- a/src/plugins/intel_cpu/src/nodes_factory.cpp+++ b/src/plugins/intel_cpu/src/nodes_factory.cpp@@ -88,6 +88,8 @@#include "nodes/rope.h"#include "nodes/scaled_attn.h"#include "nodes/scatter_update.h"+#include "nodes/string_tensor_pack.h"+#include "nodes/string_tensor_unpack.h"#include "nodes/shapeof.h"#include "nodes/shuffle_channels.h"#include "nodes/softmax.h"@@ -174,6 +176,8 @@ Node::NodesFactory::NodesFactory() : Factory("NodesFactory") {INTEL_CPU_NODE(ScatterUpdate, Type::ScatterUpdate);INTEL_CPU_NODE(ScatterUpdate, Type::ScatterElementsUpdate);INTEL_CPU_NODE(ScatterUpdate, Type::ScatterNDUpdate);+ INTEL_CPU_NODE(StringTensorPack, Type::StringTensorPack);+ INTEL_CPU_NODE(StringTensorUnpack, Type::StringTensorUnpack);INTEL_CPU_NODE(ShuffleChannels, Type::ShuffleChannels);INTEL_CPU_NODE(TensorIterator, Type::TensorIterator);INTEL_CPU_NODE(Concat, Type::Concatenation);diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/string_tensor_pack.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/string_tensor_pack.cppnew file mode 100644index 00000000000..1cf1b1dc08d--- /dev/null+++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/string_tensor_pack.cpp@@ -0,0 +1,127 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "string_tensor_pack.hpp"+#include "utils/cpu_test_utils.hpp"+#include "common_test_utils/ov_tensor_utils.hpp"+#include "shared_test_classes/base/ov_subgraph.hpp"+#include "utils/precision_support.h"++using namespace CPUTestUtils;++namespace ov {+namespace test {+namespace StringTensorPack {+std::string StringTensorPackLayerCPUTest::getTestCaseName(testing::TestParamInfo<StringTensorPackLayerCPUTestParamsSet> obj) {+ StringTensorPackLayerTestParams basicParamsSet;+ CPUSpecificParams cpuParams;+ StringTensorPackSpecificParams StringTensorPackPar;+ std::tie(basicParamsSet, cpuParams) = obj.param;+ std::string td;+ ElementType indicesPrecision;+ std::tie(StringTensorPackPar, indicesPrecision, td) = basicParamsSet;++ InputShape indicesShape;+ InputShape symbolsShape;+ std::tie(indicesShape, symbolsShape) = StringTensorPackPar;+ std::ostringstream result;++ result << ov::test::utils::partialShape2str({ indicesShape.first }) << "_";+ result << "TS=";+ result << "(";+ for (const auto& targetShape : indicesShape.second) {+ result << ov::test::utils::vec2str(targetShape) << "_";+ }+ result << ")";+ result << "_symbolsShape=";+ result << "(";+ for (const auto& targetShape : symbolsShape.second) {+ result << ov::test::utils::vec2str(targetShape) << "_";+ }+ result << ")";+ result << "_indicesPrecision=" << indicesPrecision;+ result << CPUTestsBase::getTestCaseName(cpuParams);++ return result.str();+ }++void StringTensorPackLayerCPUTest::generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) {+ inputs.clear();+ const auto& funcInputs = function->inputs();+ const auto indicesType = funcInputs[0].get_element_type();+ const auto& indicesShape = targetInputStaticShapes[0];+ const auto& symbolsShape = targetInputStaticShapes[2];++ const ov::Tensor beginsTensor = ov::test::utils::create_and_fill_tensor_consistently(indicesType, indicesShape, symbolsShape[0], 0, 3);+ const ov::Tensor endsTensor = ov::test::utils::create_and_fill_tensor_consistently(indicesType, indicesShape, symbolsShape[0], 3, 3);+ inputs.insert({ funcInputs[0].get_node_shared_ptr(), beginsTensor });+ inputs.insert({ funcInputs[1].get_node_shared_ptr(), endsTensor });++ ov::Tensor symbolsTensor;+ ov::test::utils::InputGenerateData in_symbol_data;+ in_symbol_data.start_from = 0;+ in_symbol_data.range = 10;+ symbolsTensor = ov::test::utils::create_and_fill_tensor(ov::element::u8, symbolsShape, in_symbol_data);+ inputs.insert({ funcInputs[2].get_node_shared_ptr(), symbolsTensor });+ }++void StringTensorPackLayerCPUTest::SetUp() {+ StringTensorPackLayerTestParams basicParamsSet;+ CPUSpecificParams cpuParams;+ std::tie(basicParamsSet, cpuParams) = this->GetParam();+ std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;++ StringTensorPackSpecificParams StringTensorPackParams;+ ElementType indicesPrecision;+ std::tie(StringTensorPackParams, indicesPrecision, targetDevice) = basicParamsSet;++ InputShape indicesShape;+ InputShape symbolsShape;+ std::tie(indicesShape, symbolsShape) = StringTensorPackParams;++ init_input_shapes({indicesShape, indicesShape, symbolsShape});+ auto beginsParameter = std::make_shared<ov::op::v0::Parameter>(indicesPrecision, inputDynamicShapes[0]);+ auto endsParameter = std::make_shared<ov::op::v0::Parameter>(indicesPrecision, inputDynamicShapes[1]);+ auto symbolsParameter = std::make_shared<ov::op::v0::Parameter>(ov::element::u8, inputDynamicShapes[2]);+ auto StringTensorPack = std::make_shared<ov::op::v15::StringTensorPack>(beginsParameter, endsParameter, symbolsParameter);++ ov::ParameterVector params{ beginsParameter, endsParameter, symbolsParameter };+ function = makeNgraphFunction(ov::element::string, params, StringTensorPack, "StringTensorPack");+}++TEST_P(StringTensorPackLayerCPUTest, CompareWithRefs) {+ run();+ CheckPluginRelatedResults(compiledModel, "StringTensorPack");+}++const std::vector<StringTensorPackSpecificParams> StringTensorPackParamsVector = {+ StringTensorPackSpecificParams {+ InputShape{{}, {{3}}}, // begins/ends shape+ InputShape{{}, {{9}}}, // utf-8 encoded symbols shape+ },+ StringTensorPackSpecificParams {+ InputShape{{}, {{1, 3, 4}}}, // begins/ends shape+ InputShape{{}, {{108}}}, // utf-8 encoded symbols shape+ },+ StringTensorPackSpecificParams {+ InputShape{{}, {{1, 1, 1, 2}}}, // begins/ends shape+ InputShape{{}, {{67}}}, // utf-8 encoded symbols shape+ },+ StringTensorPackSpecificParams {+ InputShape{{-1, -1, -1}, {{1, 3, 4}}}, // begins/ends shape+ InputShape{{-1}, {{108}}}, // utf-8 encoded symbols shape+ },+ StringTensorPackSpecificParams {+ InputShape{{-1, {1, 4}, {2, 3}}, {{1, 2, 2}, {1, 1, 3}}}, // begins/ends shape+ InputShape{{{50, 100}}, {{67}}}, // utf-8 encoded symbols shape+ },+ StringTensorPackSpecificParams {+ InputShape{{-1, {1, 4}, {1, 4}}, {{1, 1, 4}, {1, 4, 1}}}, // begins/ends shape+ InputShape{{{50, 100}}, {{50}, {75}, {100}}}, // utf-8 encoded symbols shape+ },+};++} // namespace StringTensorPack+} // namespace test+} // namespace ovdiff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/string_tensor_pack.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/string_tensor_pack.hppnew file mode 100644index 00000000000..184d6afea0b--- /dev/null+++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/string_tensor_pack.hpp@@ -0,0 +1,43 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "shared_test_classes/base/ov_subgraph.hpp"+#include "common_test_utils/ov_tensor_utils.hpp"+#include "utils/fusing_test_utils.hpp"+#include "utils/cpu_test_utils.hpp"+#include "gtest/gtest.h"++namespace ov {+namespace test {+namespace StringTensorPack {+using StringTensorPackSpecificParams = std::tuple<+ InputShape, // begins/ends shape+ InputShape // utf-8 encoded symbols shape+>;++using StringTensorPackLayerTestParams = std::tuple<+ StringTensorPackSpecificParams,+ ElementType,+ ov::test::TargetDevice+>;++using StringTensorPackLayerCPUTestParamsSet = std::tuple<+ StringTensorPackLayerTestParams,+ CPUTestUtils::CPUSpecificParams>;++class StringTensorPackLayerCPUTest : public testing::WithParamInterface<StringTensorPackLayerCPUTestParamsSet>,+ public SubgraphBaseTest, public CPUTestUtils::CPUTestsBase {+public:+ static std::string getTestCaseName(testing::TestParamInfo<StringTensorPackLayerCPUTestParamsSet> obj);+protected:+ void SetUp() override;+ void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override;+};++extern const std::vector<StringTensorPackSpecificParams> StringTensorPackParamsVector;+} // namespace StringTensorPack+} // namespace test+} // namespace ovdiff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/string_tensor_unpack.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/string_tensor_unpack.cppnew file mode 100644index 00000000000..af483489f9c--- /dev/null+++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/string_tensor_unpack.cpp@@ -0,0 +1,110 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "string_tensor_unpack.hpp"+#include "utils/cpu_test_utils.hpp"+#include "common_test_utils/ov_tensor_utils.hpp"+#include "shared_test_classes/base/ov_subgraph.hpp"+#include "utils/precision_support.h"++using namespace CPUTestUtils;++namespace ov {+namespace test {+namespace StringTensorUnpack {+std::string StringTensorUnpackLayerCPUTest::getTestCaseName(testing::TestParamInfo<StringTensorUnpackLayerCPUTestParamsSet> obj) {+ StringTensorUnpackLayerTestParams basicParamsSet;+ CPUSpecificParams cpuParams;+ std::tie(basicParamsSet, cpuParams) = obj.param;+ std::string td;+ StringTensorUnpackSpecificParams StringTensorUnpackPar;+ std::tie(StringTensorUnpackPar, td) = basicParamsSet;++ InputShape inputShape;+ std::tie(inputShape) = StringTensorUnpackPar;+ std::ostringstream result;++ result << ov::test::utils::partialShape2str({ inputShape.first }) << "_";+ result << "TS=";+ result << "(";+ for (const auto& targetShape : inputShape.second) {+ result << ov::test::utils::vec2str(targetShape) << "_";+ }+ result << ")";+ result << CPUTestsBase::getTestCaseName(cpuParams);++ return result.str();+ }++void StringTensorUnpackLayerCPUTest::generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) {+ inputs.clear();+ const auto& funcInputs = function->inputs();++ ov::Tensor data_tensor;+ const auto& dataShape = targetInputStaticShapes.front();+ ov::test::utils::InputGenerateData in_data;+ in_data.start_from = 0;+ in_data.range = 10;+ data_tensor = ov::test::utils::create_and_fill_tensor(ov::element::string, dataShape, in_data);+ inputs.insert({ funcInputs[0].get_node_shared_ptr(), data_tensor });+ }++void StringTensorUnpackLayerCPUTest::SetUp() {+ StringTensorUnpackLayerTestParams basicParamsSet;+ CPUSpecificParams cpuParams;+ std::tie(basicParamsSet, cpuParams) = this->GetParam();+ std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;++ StringTensorUnpackSpecificParams StringTensorUnpackParams;+ std::tie(StringTensorUnpackParams, targetDevice) = basicParamsSet;++ InputShape dataInputShape;+ std::tie(dataInputShape) = StringTensorUnpackParams;++ init_input_shapes({dataInputShape});+ auto dataParameter = std::make_shared<ov::op::v0::Parameter>(ov::element::string, inputDynamicShapes[0]);+ auto StringTensorUnpack = std::make_shared<ov::op::v15::StringTensorUnpack>(dataParameter);++ ov::ParameterVector params{ dataParameter };+ function = makeNgraphFunction(ov::element::string, params, StringTensorUnpack, "StringTensorUnpack");+}++TEST_P(StringTensorUnpackLayerCPUTest, CompareWithRefs) {+ run();+ CheckPluginRelatedResults(compiledModel, "StringTensorUnpack");+}++const std::vector<StringTensorUnpackSpecificParams> StringTensorUnpackParamsVector = {+ StringTensorUnpackSpecificParams {+ InputShape{{}, {{3}}}+ },+ StringTensorUnpackSpecificParams {+ InputShape{{}, {{1, 1, 13}}}+ },+ StringTensorUnpackSpecificParams {+ InputShape{{}, {{100, 10}}}+ },+ StringTensorUnpackSpecificParams {+ InputShape{{}, {{3, 8, 12, 8, 4}}}+ },+ StringTensorUnpackSpecificParams {+ InputShape{{-1}, {{3}}}+ },+ StringTensorUnpackSpecificParams {+ InputShape{{-1, -1, -1}, {{1, 1, 13}}}+ },+ StringTensorUnpackSpecificParams {+ InputShape{{-1, 10}, {{100, 10}}}+ },+ StringTensorUnpackSpecificParams {+ InputShape{{-1, {7, 9}, 12, {1, 20}, -1}, {{3, 8, 12, 8, 4}, {21, 7, 12, 1, 3}, {4, 9, 12, 20, 1}}}+ },+ StringTensorUnpackSpecificParams {+ InputShape{{3, -1, {3, 8}}, {{3, 1, 3}, {3, 2, 8}}}+ },+};++} // namespace StringTensorUnpack+} // namespace test+} // namespace ovdiff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/string_tensor_unpack.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/string_tensor_unpack.hppnew file mode 100644index 00000000000..e92d609a01e--- /dev/null+++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/string_tensor_unpack.hpp@@ -0,0 +1,41 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "shared_test_classes/base/ov_subgraph.hpp"+#include "common_test_utils/ov_tensor_utils.hpp"+#include "utils/fusing_test_utils.hpp"+#include "utils/cpu_test_utils.hpp"+#include "gtest/gtest.h"++namespace ov {+namespace test {+namespace StringTensorUnpack {+using StringTensorUnpackSpecificParams = std::tuple<+ InputShape+>;++using StringTensorUnpackLayerTestParams = std::tuple<+ StringTensorUnpackSpecificParams,+ ov::test::TargetDevice+>;++using StringTensorUnpackLayerCPUTestParamsSet = std::tuple<+ StringTensorUnpackLayerTestParams,+ CPUTestUtils::CPUSpecificParams>;++class StringTensorUnpackLayerCPUTest : public testing::WithParamInterface<StringTensorUnpackLayerCPUTestParamsSet>,+ public SubgraphBaseTest, public CPUTestUtils::CPUTestsBase {+public:+ static std::string getTestCaseName(testing::TestParamInfo<StringTensorUnpackLayerCPUTestParamsSet> obj);+protected:+ void SetUp() override;+ void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override;+};++extern const std::vector<StringTensorUnpackSpecificParams> StringTensorUnpackParamsVector;+} // namespace StringTensorUnpack+} // namespace test+} // namespace ovdiff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/string_tensor_pack.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/string_tensor_pack.cppnew file mode 100644index 00000000000..2e3e00ee1da--- /dev/null+++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/string_tensor_pack.cpp@@ -0,0 +1,24 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "custom/single_layer_tests/classes/string_tensor_pack.hpp"+#include "utils/cpu_test_utils.hpp"+#include "utils/fusing_test_utils.hpp"++using namespace CPUTestUtils;++namespace ov {+namespace test {+namespace StringTensorPack {+INSTANTIATE_TEST_SUITE_P(smoke_StringTensorPackLayoutTest, StringTensorPackLayerCPUTest,+ ::testing::Combine(+ ::testing::Combine(+ ::testing::ValuesIn(StringTensorPackParamsVector),+ ::testing::ValuesIn(std::vector<ElementType>{ElementType::i32, ElementType::i64}),+ ::testing::Values(ov::test::utils::DEVICE_CPU)),+ ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref_i32"})),+ StringTensorPackLayerCPUTest::getTestCaseName);+} // namespace StringTensorPack+} // namespace test+} // namespace ovdiff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/string_tensor_unpack.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/string_tensor_unpack.cppnew file mode 100644index 00000000000..bee4ea3ab92--- /dev/null+++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/string_tensor_unpack.cpp@@ -0,0 +1,23 @@+// Copyright (C) 2018-2024 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "custom/single_layer_tests/classes/string_tensor_unpack.hpp"+#include "utils/cpu_test_utils.hpp"+#include "utils/fusing_test_utils.hpp"++using namespace CPUTestUtils;++namespace ov {+namespace test {+namespace StringTensorUnpack {+INSTANTIATE_TEST_SUITE_P(smoke_StringTensorUnpackLayoutTest, StringTensorUnpackLayerCPUTest,+ ::testing::Combine(+ ::testing::Combine(+ ::testing::ValuesIn(StringTensorUnpackParamsVector),+ ::testing::Values(ov::test::utils::DEVICE_CPU)),+ ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref_string"})),+ StringTensorUnpackLayerCPUTest::getTestCaseName);+} // namespace StringTensorUnpack+} // namespace test+} // namespace ov