From 2952ba70af3758e6b68f6ae786aa17b49641b752 Mon Sep 17 00:00:00 2001 From: Nikolay Shchegolev Date: Thu, 21 Oct 2021 13:28:50 +0300 Subject: [PATCH] [CPU] Dynamic shapes. Transpose node. (#7859) --- .../nodes/common/permute_kernel.h | 3 + .../nodes/mkldnn_transpose_node.cpp | 151 +++++++++------ .../nodes/mkldnn_transpose_node.h | 46 ++++- .../cpu/single_layer_tests/transpose.cpp | 174 ++++++++++++------ 4 files changed, 253 insertions(+), 121 deletions(-) diff --git a/inference-engine/src/mkldnn_plugin/nodes/common/permute_kernel.h b/inference-engine/src/mkldnn_plugin/nodes/common/permute_kernel.h index 63497f3fa91..678bbc9ad8a 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/common/permute_kernel.h +++ b/inference-engine/src/mkldnn_plugin/nodes/common/permute_kernel.h @@ -57,6 +57,9 @@ public: void execute(const uint8_t* src_data, uint8_t* dst_data); void execute(const uint8_t* src_data, uint8_t* dst_data, const int mb); + const PermuteParams& getPermuteParams() const { + return params; + } private: void prepareParams(); diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_transpose_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_transpose_node.cpp index 850f651b2ef..c194ebace31 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_transpose_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_transpose_node.cpp @@ -3,37 +3,26 @@ // #include "mkldnn_transpose_node.h" +#include "ie_parallel.hpp" #include #include -#include -#include -#include "ie_parallel.hpp" -#include "utils/bfloat16.hpp" -#include -#include "utils/ngraph_utils.hpp" using namespace mkldnn; using namespace MKLDNNPlugin; using namespace InferenceEngine; -bool MKLDNNTransposeNode::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { +bool MKLDNNTransposeNode::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - if (isDynamicNgraphNode(op)) { - errorMessage = "Doesn't support op with dynamic shapes"; + if (!one_of(op->get_type_info(), + ov::op::v1::Transpose::type_info)) { + errorMessage = "Node is not an instance of the Transpose operation from opset1."; return false; } - const auto transposeOp = ngraph::as_type_ptr(op); - if (!transposeOp) { - errorMessage = "Node is not an instance of the Transpose operation."; - return false; - } - - auto orderOp = ngraph::as_type_ptr(op->get_input_node_shared_ptr(1)); - if (!orderOp) { - errorMessage = "Constant expected as the second input."; + if (!isDynamicNgraphNode(op) && op->get_input_node_ptr(INPUT_ORDER_IDX)->get_type_info() != ov::op::v0::Constant::type_info) { + errorMessage = "Constant expected as the second input for static shapes."; return false; } } catch (...) { @@ -42,20 +31,22 @@ bool MKLDNNTransposeNode::isSupportedOperation(const std::shared_ptr& op, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache) +MKLDNNTransposeNode::MKLDNNTransposeNode(const std::shared_ptr& op, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache) : MKLDNNNode(op, eng, cache) { std::string errorMessage; if (!isSupportedOperation(op, errorMessage)) { IE_THROW(NotImplemented) << errorMessage; } - auto orderOp = ngraph::as_type_ptr(op->get_input_node_shared_ptr(1)); - order = orderOp->cast_vector(); + if (op->get_input_node_ptr(INPUT_ORDER_IDX)->get_type_info() == ov::op::v0::Constant::type_info) { + constMap[INPUT_ORDER_IDX] = true; + order = ov::as_type(op->get_input_node_ptr(INPUT_ORDER_IDX))->cast_vector(); - if (order.empty()) { - size_t rank = op->get_input_shape(0).size(); - for (size_t i = 1lu; i <= rank; ++i) { - order.emplace_back(rank - i); + if (order.empty()) { + size_t rank = getInputShapeAtPort(INPUT_DATA_IDX).getRank(); + for (size_t i = 1lu; i <= rank; ++i) { + order.emplace_back(rank - i); + } } } } @@ -75,24 +66,26 @@ void MKLDNNTransposeNode::initSupportedPrimitiveDescriptors() { config.dynBatchSupport = true; config.inConfs.resize(2); config.outConfs.resize(1); - config.inConfs[0].inPlace = -1; - config.inConfs[0].constant = false; + config.inConfs[INPUT_DATA_IDX].inPlace = -1; + config.inConfs[INPUT_DATA_IDX].constant = false; + config.inConfs[INPUT_ORDER_IDX].constant = constMap[INPUT_ORDER_IDX]; + config.inConfs[INPUT_ORDER_IDX].desc = creatorsMap.at(LayoutType::ncsp)->createSharedDesc( + getOriginalInputPrecisionAtPort(INPUT_ORDER_IDX), getInputShapeAtPort(INPUT_ORDER_IDX)); config.outConfs[0].inPlace = -1; config.outConfs[0].constant = false; - config.inConfs[1].desc = creatorsMap.at(LayoutType::ncsp)->createSharedDesc(getOriginalInputPrecisionAtPort(1), getInputShapeAtPort(1)); if (getInputShapeAtPort(0).getRank() == 4 || getInputShapeAtPort(0).getRank() == 5) { config.inConfs[0].desc = creatorsMap.at(LayoutType::ncsp)->createSharedDesc(prec, getInputShapeAtPort(0)); config.outConfs[0].desc = creatorsMap.at(LayoutType::ncsp)->createSharedDesc(prec, getOutputShapeAtPort(0)); supportedPrimitiveDescriptors.push_back({config, impl_desc_type::unknown}); - auto srcDims = getInputShapeAtPort(0).getStaticDims(); - if (srcDims[1] % 8 == 0) { + auto srcDims = getInputShapeAtPort(0).getDims(); + if (srcDims[1] != Shape::UNDEFINED_DIM && srcDims[1] % 8 == 0) { config.inConfs[0].desc = creatorsMap.at(LayoutType::nCsp8c)->createSharedDesc(prec, getInputShapeAtPort(0)); supportedPrimitiveDescriptors.push_back({config, impl_desc_type::unknown}); } - if (srcDims[1] % 16 == 0) { + if (srcDims[1] != Shape::UNDEFINED_DIM && srcDims[1] % 16 == 0) { config.inConfs[0].desc = creatorsMap.at(LayoutType::nCsp16c)->createSharedDesc(prec, getInputShapeAtPort(0)); supportedPrimitiveDescriptors.push_back({config, impl_desc_type::unknown}); } @@ -110,34 +103,55 @@ void MKLDNNTransposeNode::initSupportedPrimitiveDescriptors() { } } +bool MKLDNNTransposeNode::needPrepareParams() const { + if (isOptimized) + return false; + return MKLDNNNode::needPrepareParams(); +} + +void MKLDNNTransposeNode::prepareParams() { + auto srcDesc = getParentEdgeAt(INPUT_DATA_IDX)->getMemory().GetDescWithType(); + params.src_block_dims = srcDesc->getBlockDims(); + auto dstDesc = getChildEdgeAt(0)->getMemory().GetDescWithType(); + params.dst_block_dims = dstDesc->getBlockDims(); + if (!constMap[INPUT_ORDER_IDX]) { + auto orderPtr = reinterpret_cast(getParentEdgeAt(0)->getMemoryPtr()->GetPtr()); + auto orderLen = getParentEdgeAt(0)->getMemoryPtr()->GetSize(); + params.order.assign(orderPtr, orderPtr + orderLen); + } + + execPtr = std::make_shared(params); +} + void MKLDNNTransposeNode::createPrimitive() { auto& dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto& srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); + auto& srcMemPtr = getParentEdgeAt(INPUT_DATA_IDX)->getMemoryPtr(); if (!dstMemPtr || !dstMemPtr->GetPrimitivePtr()) - IE_THROW() << "Destination memory didn't allocate."; + IE_THROW() << "Destination memory was not allocated."; if (!srcMemPtr || !srcMemPtr->GetPrimitivePtr()) - IE_THROW() << "Input memory didn't allocate."; + IE_THROW() << "Input memory was not allocated."; if (getSelectedPrimitiveDescriptor() == nullptr) - IE_THROW() << "Preferable primitive descriptor is not set."; + IE_THROW() << "Preferable primitive descriptor was not set."; - if (getParentEdgeAt(0)->getMemory().getDesc().hasLayoutType(LayoutType::ncsp) && - std::find(optimizedOrders.begin(), optimizedOrders.end(), order) != optimizedOrders.end()) { + if (getParentEdgeAt(INPUT_DATA_IDX)->getMemory().getDesc().hasLayoutType(LayoutType::ncsp) && + std::find(optimizedOrders.begin(), optimizedOrders.end(), order) != optimizedOrders.end()) { isOptimized = true; + execPtr = std::make_shared(); return; } - PermuteParams params; params.data_size = getSelectedPrimitiveDescriptor()->getConfig().inConfs[0].desc->getPrecision().size(); - params.order = order; - auto srcDesc = getParentEdgeAt(0)->getMemory().GetDescWithType(); - params.src_block_dims = srcDesc->getBlockDims(); + if (constMap[INPUT_ORDER_IDX]) + params.order = order; + auto srcDesc = getParentEdgeAt(INPUT_DATA_IDX)->getMemory().GetDescWithType(); params.src_block_order = srcDesc->getOrder(); - auto dstDesc = getChildEdgeAt(0)->getMemory().GetDescWithType(); - params.dst_block_dims = dstDesc->getBlockDims(); params.dst_block_order = dstDesc->getOrder(); - permuteKernel = std::unique_ptr(new PermuteKernel(params)); + if (inputShapesDefined()) { + prepareParams(); + updateLastInputDims(); + } } template @@ -242,27 +256,52 @@ void MKLDNNTransposeNode::optimizedExecute(const int MB, const MKLDNNMemoryPtr& } void MKLDNNTransposeNode::execute(mkldnn::stream strm) { - auto &dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); - auto &srcMemPtr = getParentEdgeAt(0)->getMemoryPtr(); - int MB = batchToProcess(); + if (execPtr) { + auto &dstMemPtr = getChildEdgeAt(0)->getMemoryPtr(); + auto &srcMemPtr = getParentEdgeAt(INPUT_DATA_IDX)->getMemoryPtr(); - if (isOptimized) { - const size_t dataSize = getParentEdgeAt(0)->getMemory().getDesc().getPrecision().size(); - TransposeContext ctx = {this, srcMemPtr, dstMemPtr, MB}; - OV_SWITCH(MKLDNNPlugin, TransposeOptimizedEmitter, ctx, dataSize, - OV_CASE(1, PrecisionTrait::value_type), - OV_CASE(2, PrecisionTrait::value_type), - OV_CASE(4, PrecisionTrait::value_type)); + int MB = 0; + if (isDynamicNode()) { + MB = srcMemPtr->getStaticDims()[0]; + } else { + MB = batchToProcess(); + } - return; + execPtr->exec(this, srcMemPtr, dstMemPtr, MB); + } else { + IE_THROW() << "Could not execute Transpose node. Primitive was not created."; } +} + +void MKLDNNTransposeNode::executeDynamicImpl(mkldnn::stream strm) { + execute(strm); +} + +MKLDNNTransposeNode::TransposeJitExecutor::TransposeJitExecutor(const PermuteParams& params) { + pKernel = std::make_shared(params); +} + +void MKLDNNTransposeNode::TransposeJitExecutor::exec(MKLDNNTransposeNode* node, MKLDNNMemoryPtr& srcMemPtr, MKLDNNMemoryPtr& dstMemPtr, const int MB) { + if (!pKernel) + IE_THROW() << "Could not execute. Kernel for Transpose node was not compiled."; const uint8_t* srcData = reinterpret_cast(srcMemPtr->GetPtr()); uint8_t* dstData = reinterpret_cast(dstMemPtr->GetPtr()); - permuteKernel->execute(srcData, dstData, MB); + + pKernel->execute(srcData, dstData, MB); +} + +void MKLDNNTransposeNode::TransposeRefExecutor::exec(MKLDNNTransposeNode* node, MKLDNNMemoryPtr& srcMemPtr, MKLDNNMemoryPtr& dstMemPtr, const int MB) { + const size_t dataSize = srcMemPtr->getDesc().getPrecision().size(); + TransposeContext ctx = {node, srcMemPtr, dstMemPtr, MB}; + OV_SWITCH(MKLDNNPlugin, TransposeOptimizedEmitter, ctx, dataSize, + OV_CASE(1, PrecisionTrait::value_type), + OV_CASE(2, PrecisionTrait::value_type), + OV_CASE(4, PrecisionTrait::value_type)); } bool MKLDNNTransposeNode::created() const { return getType() == Transpose; } + REG_MKLDNN_PRIM_FOR(MKLDNNTransposeNode, Transpose); diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_transpose_node.h b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_transpose_node.h index 6de2cefa5d8..0bd71612479 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_transpose_node.h +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_transpose_node.h @@ -4,15 +4,13 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include #include "common/permute_kernel.h" +#include +#include +#include +#include + namespace MKLDNNPlugin { class MKLDNNTransposeNode : public MKLDNNNode { @@ -33,7 +31,33 @@ public: return order; } + bool needPrepareParams() const override; + void prepareParams() override; + +protected: + void executeDynamicImpl(mkldnn::stream strm) override; + private: + struct TransposeExecutor { + TransposeExecutor() = default; + virtual void exec(MKLDNNTransposeNode* node, MKLDNNMemoryPtr& srcMemPtr, MKLDNNMemoryPtr& dstMemPtr, const int MB) = 0; + virtual ~TransposeExecutor() = default; + }; + using executorPtr = std::shared_ptr; + executorPtr execPtr = nullptr; + + struct TransposeJitExecutor : public TransposeExecutor { + TransposeJitExecutor(const PermuteParams& params); + void exec(MKLDNNTransposeNode* node, MKLDNNMemoryPtr& srcMemPtr, MKLDNNMemoryPtr& dstMemPtr, const int MB) override; + + std::shared_ptr pKernel; + }; + + struct TransposeRefExecutor : public TransposeExecutor { + TransposeRefExecutor() = default; + void exec(MKLDNNTransposeNode* node, MKLDNNMemoryPtr& srcMemPtr, MKLDNNMemoryPtr& dstMemPtr, const int MB) override; + }; + template void optimizedExecute(const int MB, const MKLDNNMemoryPtr& srcMemPtr, MKLDNNMemoryPtr& dstMemPtr); InferenceEngine::SizeVector order; @@ -46,7 +70,7 @@ private: std::vector{0, 5, 1, 2, 3, 4}, }; - std::unique_ptr permuteKernel; + PermuteParams params; struct TransposeContext { MKLDNNTransposeNode* nodePtr; @@ -61,7 +85,11 @@ private: ctx.nodePtr->optimizedExecute(ctx.MB, ctx.srcMemPtr, ctx.dstMemPtr); } }; + + bool constMap[3] = { false }; + + static constexpr size_t INPUT_DATA_IDX = 0lu; + static constexpr size_t INPUT_ORDER_IDX = 1lu; }; } // namespace MKLDNNPlugin - diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/transpose.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/transpose.cpp index 9708b8d50ec..ee8c44398a5 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/transpose.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/transpose.cpp @@ -2,9 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include "ngraph_functions/builders.hpp" #include "test_utils/cpu_test_utils.hpp" +#include "ngraph_functions/builders.hpp" // Since the Transpose ngraph operation is converted to the transpose node, we will use it in the transpose test @@ -13,11 +12,13 @@ using namespace CPUTestUtils; namespace CPULayerTestsDefinitions { +using inputShapesPair = std::pair, std::vector>>; + typedef std::tuple< - std::vector, // Input order - InferenceEngine::Precision, // Net precision - std::vector, // Input shapes - std::string, // Target device name + inputShapesPair, // Input shapes + std::vector, // Input order + InferenceEngine::Precision, // Net precision + std::string, // Target device name std::map, // Additional network configuration CPUSpecificParams> TransposeLayerCPUTestParamSet; @@ -26,14 +27,16 @@ class TransposeLayerCPUTest : public testing::WithParamInterface obj) { Precision netPrecision; - std::vector inputShape, inputOrder; + inputShapesPair inputShapes; + std::vector inputOrder; std::string targetDevice; CPUSpecificParams cpuParams; std::map additionalConfig; - std::tie(inputOrder, netPrecision, inputShape, targetDevice, additionalConfig, cpuParams) = obj.param; + std::tie(inputShapes, inputOrder, netPrecision, targetDevice, additionalConfig, cpuParams) = obj.param; std::ostringstream result; - result << "IS=" << CommonTestUtils::vec2str(inputShape) << "_"; + result << "DynShapes=" << CommonTestUtils::partialShape2str(inputShapes.first) << "_"; + result << "StatShapes=" << CommonTestUtils::vec2str(inputShapes.second) << "_"; result << "inputOrder=" << CommonTestUtils::vec2str(inputOrder) << "_"; result << "netPRC=" << netPrecision.name() << "_"; result << "trgDev=" << targetDevice; @@ -43,10 +46,11 @@ public: protected: void SetUp() override { Precision netPrecision; - std::vector inputShape, inputOrder; + inputShapesPair inputShapes; + std::vector inputOrder; CPUSpecificParams cpuParams; std::map additionalConfig; - std::tie(inputOrder, netPrecision, inputShape, targetDevice, additionalConfig, cpuParams) = this->GetParam(); + std::tie(inputShapes, inputOrder, netPrecision, targetDevice, additionalConfig, cpuParams) = this->GetParam(); configuration.insert(additionalConfig.begin(), additionalConfig.end()); inPrc = outPrc = netPrecision; // since the layer does not convert precisions @@ -54,19 +58,27 @@ protected: selectedType = std::string("unknown_") + inPrc.name(); - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - auto params = ngraph::builder::makeParams(ngPrc, {inputShape}); - auto paramOuts = ngraph::helpers::convert2OutputVector( - ngraph::helpers::castOps2Nodes(params)); + targetStaticShapes.reserve(inputShapes.second.size()); + for (const auto& staticShape : inputShapes.second) { + targetStaticShapes.push_back({staticShape}); + } + inputDynamicShapes = { inputShapes.first }; - const auto inOrderShape = inputOrder.empty() ? ngraph::Shape({0}) : ngraph::Shape({inputShape.size()}); - const auto inputOrderOp = std::make_shared(ngraph::element::i64, + ov::Shape inputDataShape = targetStaticShapes.front().front(); + + auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + auto params = ngraph::builder::makeParams(ngPrc, {inputDataShape}); + auto paramOuts = ngraph::helpers::convert2OutputVector( + ngraph::helpers::castOps2Nodes(params)); + + const auto inOrderShape = inputOrder.empty() ? ov::Shape({0}) : ov::Shape({inputDataShape.size()}); + const auto inputOrderOp = std::make_shared(ov::element::i64, inOrderShape, inputOrder); - const auto transpose = std::make_shared(paramOuts.at(0), inputOrderOp); + const auto transpose = std::make_shared(paramOuts.at(0), inputOrderOp); transpose->get_rt_info() = getCPUInfo(); - const ngraph::ResultVector results{std::make_shared(transpose)}; - function = std::make_shared(results, params, "Transpose"); + const ov::ResultVector results{std::make_shared(transpose)}; + function = std::make_shared(results, params, "Transpose"); } }; @@ -103,8 +115,13 @@ const std::vector netPrecisionsPerChannels = { Precision::FP32 }; -const std::vector> inputShapes4D = { - {2, 32, 10, 20} +const std::vector + staticInputShapes4D = { + {{}, {{{2, 32, 10, 20}}}} +}; +const std::vector + dynamicInputShapes4D = { + {{{2, ov::Dimension(20, 40), 10, 20}}, {{{2, 32, 10, 20}, {2, 10, 10, 20}}}} }; const std::vector> inputOrder4D = { @@ -128,28 +145,53 @@ const std::vector CPUParams4D = { cpuParams_nchw, }; -const auto params4D = ::testing::Combine( - ::testing::ValuesIn(inputOrder4D), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes4D), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config), - ::testing::ValuesIn(CPUParams4D)); +INSTANTIATE_TEST_SUITE_P(smoke_staticShapes4D_Transpose, TransposeLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(staticInputShapes4D), + ::testing::ValuesIn(inputOrder4D), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CommonTestUtils::DEVICE_CPU), + ::testing::Values(additional_config), + ::testing::ValuesIn(CPUParams4D)), + TransposeLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_Transpose4D_CPU, TransposeLayerCPUTest, params4D, TransposeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_dynamicShapes4D_Transpose, TransposeLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(dynamicInputShapes4D), + ::testing::ValuesIn(inputOrder4D), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CommonTestUtils::DEVICE_CPU), + ::testing::Values(additional_config), + ::testing::ValuesIn(std::vector{})), + TransposeLayerCPUTest::getTestCaseName); -const auto paramsPerChannels4D = ::testing::Combine( - ::testing::ValuesIn(inputOrderPerChannels4D), - ::testing::ValuesIn(netPrecisionsPerChannels), - ::testing::ValuesIn(inputShapes4D), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config), - ::testing::Values(cpuParams_nhwc)); +INSTANTIATE_TEST_SUITE_P(smoke_staticShapes4D_PermutePerChannels, TransposeLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(staticInputShapes4D), + ::testing::ValuesIn(inputOrderPerChannels4D), + ::testing::ValuesIn(netPrecisionsPerChannels), + ::testing::Values(CommonTestUtils::DEVICE_CPU), + ::testing::Values(additional_config), + ::testing::Values(cpuParams_nhwc)), + TransposeLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_PermutePerChannels4D_CPU, TransposeLayerCPUTest, paramsPerChannels4D, TransposeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_dynamicShapes4D_PermutePerChannels, TransposeLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(dynamicInputShapes4D), + ::testing::ValuesIn(inputOrderPerChannels4D), + ::testing::ValuesIn(netPrecisionsPerChannels), + ::testing::Values(CommonTestUtils::DEVICE_CPU), + ::testing::Values(additional_config), + ::testing::Values(cpuParams_nhwc)), + TransposeLayerCPUTest::getTestCaseName); -const std::vector> inputShapes5D = { - {2, 32, 5, 10, 20} +const std::vector + staticInputShapes5D = { + {{}, {{{2, 32, 5, 10, 20}}}} +}; +const std::vector + dynamicInputShapes5D = { + {{{2, ov::Dimension(20, 40), 5, 10, 20}}, {{{2, 32, 5, 10, 20}, {2, 20, 5, 10, 20}}}} }; const std::vector> inputOrder5D = { @@ -181,25 +223,45 @@ const std::vector CPUParams5D = { cpuParams_ncdhw, }; -const auto params5D = ::testing::Combine( - ::testing::ValuesIn(inputOrder5D), - ::testing::ValuesIn(netPrecisions), - ::testing::ValuesIn(inputShapes5D), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config), - ::testing::ValuesIn(CPUParams5D)); +INSTANTIATE_TEST_SUITE_P(smoke_staticShapes5D_Transpose, TransposeLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(staticInputShapes5D), + ::testing::ValuesIn(inputOrder5D), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CommonTestUtils::DEVICE_CPU), + ::testing::Values(additional_config), + ::testing::ValuesIn(CPUParams5D)), + TransposeLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_Transpose5D_CPU, TransposeLayerCPUTest, params5D, TransposeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_dynamicShapes5D_Transpose, TransposeLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(dynamicInputShapes5D), + ::testing::ValuesIn(inputOrder5D), + ::testing::ValuesIn(netPrecisions), + ::testing::Values(CommonTestUtils::DEVICE_CPU), + ::testing::Values(additional_config), + ::testing::ValuesIn(std::vector{})), + TransposeLayerCPUTest::getTestCaseName); -const auto paramsPerChannels5D = ::testing::Combine( - ::testing::ValuesIn(inputOrderPerChannels5D), - ::testing::ValuesIn(netPrecisionsPerChannels), - ::testing::ValuesIn(inputShapes5D), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config), - ::testing::Values(cpuParams_ndhwc)); +INSTANTIATE_TEST_SUITE_P(smoke_staticShapes5D_PermutePerChannels, TransposeLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(staticInputShapes5D), + ::testing::ValuesIn(inputOrderPerChannels5D), + ::testing::ValuesIn(netPrecisionsPerChannels), + ::testing::Values(CommonTestUtils::DEVICE_CPU), + ::testing::Values(additional_config), + ::testing::Values(cpuParams_ndhwc)), + TransposeLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_PermutePerChannels5D_CPU, TransposeLayerCPUTest, paramsPerChannels5D, TransposeLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_dynamicShapes5D_PermutePerChannels, TransposeLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(dynamicInputShapes5D), + ::testing::ValuesIn(inputOrderPerChannels5D), + ::testing::ValuesIn(netPrecisionsPerChannels), + ::testing::Values(CommonTestUtils::DEVICE_CPU), + ::testing::Values(additional_config), + ::testing::Values(cpuParams_ndhwc)), + TransposeLayerCPUTest::getTestCaseName); } // namespace } // namespace CPULayerTestsDefinitions