[CPU] BatchToSpace dynamic done (#8222)

This commit is contained in:
Egor Shulman 2021-11-10 09:56:10 +03:00 committed by GitHub
parent 841e56c317
commit c8b44b275c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 271 additions and 105 deletions

View File

@ -2,12 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <cmath>
#include <vector>
#include <string>
#include <mkldnn_types.h>
#include "ie_parallel.hpp"
#include "utils/bfloat16.hpp"
#include <mkldnn_selective_build.h>
#include "mkldnn_batch_to_space_node.h"
#include <nodes/common/blocked_desc_creator.h>
@ -18,10 +16,6 @@ using namespace InferenceEngine;
bool MKLDNNBatchToSpaceNode::isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept {
try {
if (isDynamicNgraphNode(op)) {
errorMessage = "Doesn't support op with dynamic shapes";
return false;
}
const auto batchToSpace = std::dynamic_pointer_cast<const ngraph::opset2::BatchToSpace>(op);
if (!batchToSpace) {
errorMessage = "Only opset2 BatchToSpace operation is supported";
@ -48,11 +42,11 @@ MKLDNNBatchToSpaceNode::MKLDNNBatchToSpaceNode(const std::shared_ptr<ngraph::Nod
errorPrefix = "BatchToSpace layer with name '" + op->get_friendly_name() + "'";
if (op->get_input_size() != 4 || op->get_output_size() != 1)
if (inputShapes.size() != 4 || outputShapes.size() != 1)
IE_THROW() << errorPrefix << " has incorrect number of input or output edges!";
inDims = getInputShapeAtPort(0).getStaticDims();
outDims = getOutputShapeAtPort(0).getStaticDims();
const auto &inDims = getInputShapeAtPort(0).getDims();
const auto &outDims = getOutputShapeAtPort(0).getDims();
if (inDims.size() < 4 || inDims.size() > 5)
IE_THROW() << errorPrefix << " has unsupported 'data' input rank: " << inDims.size();
if (inDims.size() != outDims.size())
@ -66,6 +60,7 @@ void MKLDNNBatchToSpaceNode::initSupportedPrimitiveDescriptors() {
if (!supportedPrimitiveDescriptors.empty())
return;
const auto &inDims = getInputShapeAtPort(0).getDims();
const auto precision = getOriginalInputPrecisionAtPort(0);
const std::set<size_t> supported_precision_sizes = {1, 2, 4, 8};
if (supported_precision_sizes.find(precision.size()) == supported_precision_sizes.end())
@ -83,7 +78,7 @@ void MKLDNNBatchToSpaceNode::initSupportedPrimitiveDescriptors() {
{LayoutType::ncsp}},
{{LayoutType::ncsp, precision}},
impl_desc_type::ref_any);
if (inDims[1] % 8 == 0) {
if (inDims[1] != Shape::UNDEFINED_DIM && inDims[1] % 8 == 0) {
addSupportedPrimDesc({{LayoutType::nCsp8c, precision},
{LayoutType::ncsp},
{LayoutType::ncsp},
@ -91,7 +86,7 @@ void MKLDNNBatchToSpaceNode::initSupportedPrimitiveDescriptors() {
{{LayoutType::nCsp8c, precision}},
impl_desc_type::ref_any);
}
if (inDims[1] % 16 == 0) {
if (inDims[1] != Shape::UNDEFINED_DIM && inDims[1] % 16 == 0) {
addSupportedPrimDesc({{LayoutType::nCsp16c, precision},
{LayoutType::ncsp},
{LayoutType::ncsp},
@ -116,6 +111,9 @@ void MKLDNNBatchToSpaceNode::batchToSpaceKernel() {
const auto *srcData = reinterpret_cast<const T *>(getParentEdgeAt(0)->getMemoryPtr()->GetPtr());
auto *dstData = reinterpret_cast<T *>(getChildEdgeAt(0)->getMemoryPtr()->GetPtr());
const auto &inDims = getParentEdgesAtPort(0)[0]->getMemory().getStaticDims();
const auto &outDims = getChildEdgesAtPort(0)[0]->getMemory().getStaticDims();
auto srcDesc = getParentEdgeAt(0)->getMemory().GetDescWithType<BlockedMemoryDesc>();
const bool blocked = srcDesc->hasLayoutType(LayoutType::nCsp8c) || srcDesc->hasLayoutType(LayoutType::nCsp16c);

View File

@ -22,6 +22,9 @@ public:
void execute(mkldnn::stream strm) override;
bool created() const override;
bool needPrepareParams() const override { return false; };
void executeDynamicImpl(mkldnn::stream strm) override { execute(strm); };
static bool isSupportedOperation(const std::shared_ptr<const ngraph::Node>& op, std::string& errorMessage) noexcept;
private:
@ -29,8 +32,6 @@ private:
void batchToSpaceKernel();
private:
InferenceEngine::SizeVector inDims;
InferenceEngine::SizeVector outDims;
std::vector<size_t> blockShapeIn;
std::vector<size_t> cropsBeginIn;

View File

@ -2,56 +2,81 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <shared_test_classes/single_layer/batch_to_space.hpp>
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ngraph_functions/builders.hpp"
#include "test_utils/cpu_test_utils.hpp"
using namespace InferenceEngine;
using namespace CPUTestUtils;
using namespace ngraph::opset3;
using namespace ov::test;
namespace CPULayerTestsDefinitions {
typedef std::tuple<
LayerTestsDefinitions::batchToSpaceParamsTuple,
CPUSpecificParams> BatchToSpaceLayerCPUTestParamSet;
using BatchToSpaceLayerTestCPUParams = std::tuple<
std::vector<InputShape>, // Input shapes
std::vector<int64_t>, // block shape
std::vector<int64_t>, // crops begin
std::vector<int64_t>, // crops end
Precision , // Network precision
CPUSpecificParams>;
class BatchToSpaceCPULayerTest : public testing::WithParamInterface<BatchToSpaceLayerCPUTestParamSet>,
virtual public LayerTestsUtils::LayerTestsCommon, public CPUTestsBase {
class BatchToSpaceCPULayerTest : public testing::WithParamInterface<BatchToSpaceLayerTestCPUParams>,
virtual public SubgraphBaseTest, public CPUTestsBase {
public:
static std::string getTestCaseName(const testing::TestParamInfo<BatchToSpaceLayerCPUTestParamSet> &obj) {
LayerTestsDefinitions::batchToSpaceParamsTuple basicParamsSet;
static std::string getTestCaseName(const testing::TestParamInfo<BatchToSpaceLayerTestCPUParams> &obj) {
std::vector<InputShape> inputShapes;
std::vector<int64_t> blockShape, cropsBegin, cropsEnd;
Precision netPrecision;
CPUSpecificParams cpuParams;
std::tie(basicParamsSet, cpuParams) = obj.param;
std::tie(inputShapes, blockShape, cropsBegin, cropsEnd, netPrecision, cpuParams) = obj.param;
std::ostringstream result;
result << LayerTestsDefinitions::BatchToSpaceLayerTest::getTestCaseName(
testing::TestParamInfo<LayerTestsDefinitions::batchToSpaceParamsTuple>(basicParamsSet, 0));
if (inputShapes.front().first.size() != 0) {
result << "IS=(";
for (const auto &shape : inputShapes) {
result << CommonTestUtils::partialShape2str({shape.first}) << "_";
}
result.seekp(-1, result.cur);
result << ")_";
}
result << "TS=";
for (const auto& shape : inputShapes) {
for (const auto& item : shape.second) {
result << CommonTestUtils::vec2str(item) << "_";
}
}
result << "blockShape=" << CommonTestUtils::vec2str(blockShape) << "_";
result << "cropsBegin=" << CommonTestUtils::vec2str(cropsBegin) << "_";
result << "cropsEnd=" << CommonTestUtils::vec2str(cropsEnd) << "_";
result << "netPRC=" << netPrecision.name() << "_";
result << CPUTestsBase::getTestCaseName(cpuParams);
return result.str();
}
protected:
void SetUp() override {
LayerTestsDefinitions::batchToSpaceParamsTuple basicParamsSet;
CPUSpecificParams cpuParams;
std::tie(basicParamsSet, cpuParams) = this->GetParam();
std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;
std::vector<size_t> inputShape;
targetDevice = CommonTestUtils::DEVICE_CPU;
std::vector<InputShape> inputShapes;
std::vector<int64_t> blockShape, cropsBegin, cropsEnd;
InferenceEngine::Precision netPrecision;
std::tie(blockShape, cropsBegin, cropsEnd, inputShape, netPrecision, inPrc, outPrc, inLayout, outLayout, targetDevice) = basicParamsSet;
inPrc = outPrc = netPrecision;
Precision netPrecision;
CPUSpecificParams cpuParams;
std::tie(inputShapes, blockShape, cropsBegin, cropsEnd, netPrecision, cpuParams) = this->GetParam();
std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;
auto ngPrec = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
inType = outType = ngPrec;
init_input_shapes(inputShapes);
if (strcmp(netPrecision.name(), "U8") == 0)
selectedType = std::string("ref_any_") + "I8";
else
selectedType = std::string("ref_any_") + netPrecision.name();
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
auto params = ngraph::builder::makeParams(ngPrc, {inputShape});
auto paramOuts = ngraph::helpers::convert2OutputVector(
ngraph::helpers::castOps2Nodes<ngraph::op::Parameter>(params));
auto b2s = ngraph::builder::makeBatchToSpace(paramOuts[0], ngPrc, blockShape, cropsBegin, cropsEnd);
auto params = ngraph::builder::makeDynamicParams(ngPrec, {inputDynamicShapes.front()});
auto paramOuts = ngraph::helpers::convert2OutputVector(ngraph::helpers::castOps2Nodes<ngraph::op::Parameter>(params));
auto b2s = ngraph::builder::makeBatchToSpace(paramOuts[0], ngPrec, blockShape, cropsBegin, cropsEnd);
b2s->get_rt_info() = getCPUInfo();
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(b2s)};
function = std::make_shared<ngraph::Function>(results, params, "BatchToSpace");
@ -61,119 +86,261 @@ protected:
TEST_P(BatchToSpaceCPULayerTest, CompareWithRefs) {
SKIP_IF_CURRENT_TEST_IS_DISABLED()
Run();
CheckPluginRelatedResults(executableNetwork, "BatchToSpace");
run();
// TODO: Should be uncommented after updating the CheckPluginRelatedResults() method
// CheckPluginRelatedResults(executableNetwork, "BatchToSpace");
};
namespace {
const std::vector<Precision> precisions = {
const std::vector<Precision> netPrecision = {
Precision::U8,
Precision::I8,
Precision::I32,
Precision::FP32,
Precision::BF16
// TODO: Should be uncommented after PR #8339 merge
// Precision::BF16
};
const std::vector<std::vector<int64_t>> blockShape4D1 = {{1, 1, 1, 2}, {1, 2, 2, 1}};
const std::vector<std::vector<int64_t>> cropsBegin4D1 = {{0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 2, 0}};
const std::vector<std::vector<int64_t>> cropsEnd4D1 = {{0, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 1, 1}};
const std::vector<std::vector<size_t>> inputShapes4D1 = {{8, 16, 10, 10}, {16, 64, 13, 16}};
std::vector<std::vector<ov::Shape>> staticInputShapes4D1 = {
{{8, 16, 10, 10}}
};
std::vector<std::vector<InputShape>> dynamicInputShapes4D1 = {
{
{{{-1, -1, -1, -1}, {{8, 8, 6, 7}, {4, 10, 5, 5}, {12, 9, 7, 5}}}},
{{{{4, 12}, {8, 16}, 6, -1}, {{8, 8, 6, 7}, {4, 10, 6, 5}, {12, 9, 6, 5}}}}
}
};
std::vector<std::vector<InputShape>> dynamicInputShapes4D1Blocked = {
{
{{{-1, 16, -1, -1}, {{4, 16, 5, 8}, {8, 16, 7, 6}, {12, 16, 4, 5}}}}
}
};
const std::vector<std::vector<int64_t>> blockShape4D2 = {{1, 2, 3, 4}, {1, 3, 4, 2}};
const std::vector<std::vector<int64_t>> cropsBegin4D2 = {{0, 0, 0, 1}, {0, 0, 1, 2}};
const std::vector<std::vector<int64_t>> cropsEnd4D2 = {{0, 0, 1, 0}, {0, 0, 3, 1}};
const std::vector<std::vector<size_t>> inputShapes4D2 = {{48, 16, 7, 8}, {24, 32, 6, 6}};
const std::vector<CPUSpecificParams> cpuParams_4D = {
std::vector<std::vector<ov::Shape>> staticInputShapes4D2 = {
{{24, 16, 7, 8}}
};
std::vector<std::vector<InputShape>> dynamicInputShapes4D2 = {
{
{{{-1, -1, -1, -1}, {{48, 4, 7, 8}, {24, 8, 6, 7}, {24, 16, 5, 5}}}},
{{{24, {4, 10}, -1, -1}, {{24, 8, 6, 7}, {24, 6, 7, 5}, {24, 4, 5, 5}}}}
}
};
std::vector<std::vector<InputShape>> dynamicInputShapes4D2Blocked = {
{
{{-1, 16, -1, -1}, {{24, 16, 5, 5}, {24, 16, 6, 7}, {48, 16, 4, 4}}}
}
};
const std::vector<CPUSpecificParams> cpuParamsWithBlock_4D = {
CPUSpecificParams({nChw16c}, {nChw16c}, {}, {}),
CPUSpecificParams({nChw8c}, {nChw8c}, {}, {}),
CPUSpecificParams({nhwc}, {nhwc}, {}, {}),
CPUSpecificParams({nchw}, {nchw}, {}, {})
};
const auto batchToSpaceParamsSet4D1 = ::testing::Combine(
::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<int64_t>>({blockShape4D1})),
::testing::ValuesIn(std::vector<std::vector<int64_t>>({cropsBegin4D1})),
::testing::ValuesIn(std::vector<std::vector<int64_t>>({cropsEnd4D1})),
::testing::ValuesIn(std::vector<std::vector<size_t>> ({inputShapes4D1})),
::testing::ValuesIn(precisions),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::ValuesIn(cpuParams_4D));
const std::vector<CPUSpecificParams> cpuParams_4D = {
CPUSpecificParams({nhwc}, {nhwc}, {}, {}),
CPUSpecificParams({nchw}, {nchw}, {}, {})
};
const auto batchToSpaceParamsSet4D2 = ::testing::Combine(
::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<int64_t>>({blockShape4D2})),
::testing::ValuesIn(std::vector<std::vector<int64_t>>({cropsBegin4D2})),
::testing::ValuesIn(std::vector<std::vector<int64_t>>({cropsEnd4D2})),
::testing::ValuesIn(std::vector<std::vector<size_t>> ({inputShapes4D2})),
::testing::ValuesIn(precisions),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
const auto staticBatchToSpaceParamsSet4D1 = ::testing::Combine(
::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D1)),
::testing::ValuesIn(blockShape4D1),
::testing::ValuesIn(cropsBegin4D1),
::testing::ValuesIn(cropsEnd4D1),
::testing::ValuesIn(netPrecision),
::testing::ValuesIn(cpuParamsWithBlock_4D));
const auto dynamicBatchToSpaceParamsSet4D1 = ::testing::Combine(
::testing::ValuesIn(dynamicInputShapes4D1),
::testing::ValuesIn(blockShape4D1),
::testing::ValuesIn(cropsBegin4D1),
::testing::ValuesIn(cropsEnd4D1),
::testing::ValuesIn(netPrecision),
::testing::ValuesIn(cpuParams_4D));
INSTANTIATE_TEST_SUITE_P(smoke_BatchToSpaceCPULayerTestCase1_4D, BatchToSpaceCPULayerTest,
batchToSpaceParamsSet4D1, BatchToSpaceCPULayerTest::getTestCaseName);
const auto dynamicBatchToSpaceParamsWithBlockedSet4D1 = ::testing::Combine(
::testing::ValuesIn(dynamicInputShapes4D1Blocked),
::testing::ValuesIn(blockShape4D1),
::testing::ValuesIn(cropsBegin4D1),
::testing::ValuesIn(cropsEnd4D1),
::testing::ValuesIn(netPrecision),
::testing::ValuesIn(cpuParamsWithBlock_4D));
INSTANTIATE_TEST_SUITE_P(smoke_BatchToSpaceCPULayerTestCase2_4D, BatchToSpaceCPULayerTest,
batchToSpaceParamsSet4D2, BatchToSpaceCPULayerTest::getTestCaseName);
const auto staticBatchToSpaceParamsSet4D2 = ::testing::Combine(
::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes4D2)),
::testing::ValuesIn(blockShape4D2),
::testing::ValuesIn(cropsBegin4D2),
::testing::ValuesIn(cropsEnd4D2),
::testing::ValuesIn(netPrecision),
::testing::ValuesIn(cpuParamsWithBlock_4D));
const auto dynamicBatchToSpaceParamsSet4D2 = ::testing::Combine(
::testing::ValuesIn(dynamicInputShapes4D2),
::testing::ValuesIn(blockShape4D2),
::testing::ValuesIn(cropsBegin4D2),
::testing::ValuesIn(cropsEnd4D2),
::testing::ValuesIn(netPrecision),
::testing::ValuesIn(cpuParams_4D));
const auto dynamicBatchToSpaceParamsWithBlockedSet4D2 = ::testing::Combine(
::testing::ValuesIn(dynamicInputShapes4D2Blocked),
::testing::ValuesIn(blockShape4D2),
::testing::ValuesIn(cropsBegin4D2),
::testing::ValuesIn(cropsEnd4D2),
::testing::ValuesIn(netPrecision),
::testing::ValuesIn(cpuParamsWithBlock_4D));
INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase1_4D, BatchToSpaceCPULayerTest,
staticBatchToSpaceParamsSet4D1, BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase1_4D, BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsSet4D1, BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked1_4D, BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsWithBlockedSet4D1, BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase2_4D, BatchToSpaceCPULayerTest,
staticBatchToSpaceParamsSet4D2, BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase2_4D, BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsSet4D2, BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked2_4D, BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsWithBlockedSet4D2, BatchToSpaceCPULayerTest::getTestCaseName);
const std::vector<std::vector<int64_t>> blockShape5D1 = {{1, 1, 2, 2, 1}, {1, 2, 1, 2, 2}};
const std::vector<std::vector<int64_t>> cropsBegin5D1 = {{0, 0, 0, 0, 0}, {0, 0, 0, 3, 3}};
const std::vector<std::vector<int64_t>> cropsEnd5D1 = {{0, 0, 0, 0, 0}, {0, 0, 1, 0, 1}};
const std::vector<std::vector<size_t>> inputShapes5D1 = {{8, 16, 4, 10, 10}, {16, 32, 5, 8, 12}};
std::vector<std::vector<ov::Shape>> staticInputShapes5D1 = {
{{8, 16, 4, 10, 10}}
};
std::vector<std::vector<InputShape>> dynamicInputShapes5D1 = {
{
{{{-1, -1, -1, -1, -1}, {{8, 16, 4, 10, 10}, {16, 10, 5, 11, 9}, {24, 6, 6, 8, 8}}}},
{{{{8, 16}, {8, 16}, {2, 7}, -1, -1}, {{8, 16, 2, 6, 8}, {8, 10, 4, 7, 5}, {16, 8, 7, 5, 10}}}}
}
};
std::vector<std::vector<InputShape>> dynamicInputShapes5D1Blocked = {
{
{{{-1, 16, -1, -1, -1}, {{24, 16, 3, 6, 7}, {48, 16, 4, 5, 5}, {24, 16, 5, 8, 5}}}}
}
};
const std::vector<std::vector<int64_t>> blockShape5D2 = {{1, 2, 4, 3, 1}, {1, 1, 2, 4, 3}};
const std::vector<std::vector<int64_t>> cropsBegin5D2 = {{0, 0, 1, 2, 0}, {0, 0, 1, 0, 1}};
const std::vector<std::vector<int64_t>> cropsEnd5D2 = {{0, 0, 1, 0, 1}, {0, 0, 1, 1, 1}};
const std::vector<std::vector<size_t>> inputShapes5D2 = {{48, 16, 3, 3, 3}, {24, 32, 5, 3, 5}};
const std::vector<CPUSpecificParams> cpuParams_5D = {
std::vector<std::vector<ov::Shape>> staticInputShapes5D2 = {
{{48, 16, 3, 3, 3}}
};
std::vector<std::vector<InputShape>> dynamicInputShapes5D2 = {
{
{{{-1, -1, -1, -1, -1}, {{48, 4, 3, 3, 3}, {24, 16, 5, 3, 5}, {24, 8, 7, 5, 5}}}},
{{{24, {8, 16}, {3, 5}, -1, -1}, {{24, 16, 3, 4, 3}, {24, 12, 5, 3, 5}, {24, 8, 4, 5, 5}}}}
}
};
std::vector<std::vector<InputShape>> dynamicInputShapes5D2Blocked = {
{
{{{-1, 16, -1, -1, -1}, {{24, 16, 4, 5, 5}, {48, 16, 3, 4, 3}, {24, 16, 5, 3, 5}}}}
}
};
const std::vector<CPUSpecificParams> cpuParamsWithBlock_5D = {
CPUSpecificParams({nCdhw16c}, {nCdhw16c}, {}, {}),
CPUSpecificParams({nCdhw8c}, {nCdhw8c}, {}, {}),
CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}),
CPUSpecificParams({ncdhw}, {ncdhw}, {}, {})
};
const auto batchToSpaceParamsSet5D1 = ::testing::Combine(
::testing::Combine(
::testing::ValuesIn(blockShape5D1),
::testing::ValuesIn(cropsBegin5D1),
::testing::ValuesIn(cropsEnd5D1),
::testing::ValuesIn(inputShapes5D1),
::testing::ValuesIn(precisions),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(cpuParams_5D));
const std::vector<CPUSpecificParams> cpuParams_5D = {
CPUSpecificParams({ndhwc}, {ndhwc}, {}, {}),
CPUSpecificParams({ncdhw}, {ncdhw}, {}, {})
};
const auto batchToSpaceParamsSet5D2 = ::testing::Combine(
::testing::Combine(
::testing::ValuesIn(blockShape5D2),
::testing::ValuesIn(cropsBegin5D2),
::testing::ValuesIn(cropsEnd5D2),
::testing::ValuesIn(inputShapes5D2),
::testing::ValuesIn(precisions),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(cpuParams_5D));
const auto staticBatchToSpaceParamsSet5D1 = ::testing::Combine(
::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes5D1)),
::testing::ValuesIn(blockShape5D1),
::testing::ValuesIn(cropsBegin5D1),
::testing::ValuesIn(cropsEnd5D1),
::testing::ValuesIn(netPrecision),
::testing::ValuesIn(cpuParamsWithBlock_5D));
INSTANTIATE_TEST_SUITE_P(smoke_BatchToSpaceCPULayerTestCase1_5D, BatchToSpaceCPULayerTest,
batchToSpaceParamsSet5D1, BatchToSpaceCPULayerTest::getTestCaseName);
const auto dynamicBatchToSpaceParamsSet5D1 = ::testing::Combine(
::testing::ValuesIn(dynamicInputShapes5D1),
::testing::ValuesIn(blockShape5D1),
::testing::ValuesIn(cropsBegin5D1),
::testing::ValuesIn(cropsEnd5D1),
::testing::ValuesIn(netPrecision),
::testing::ValuesIn(cpuParams_5D));
INSTANTIATE_TEST_SUITE_P(smoke_BatchToSpaceCPULayerTestCase2_5D, BatchToSpaceCPULayerTest,
batchToSpaceParamsSet5D2, BatchToSpaceCPULayerTest::getTestCaseName);
const auto dynamicBatchToSpaceParamsWithBlockedSet5D1 = ::testing::Combine(
::testing::ValuesIn(dynamicInputShapes5D1Blocked),
::testing::ValuesIn(blockShape5D1),
::testing::ValuesIn(cropsBegin5D1),
::testing::ValuesIn(cropsEnd5D1),
::testing::ValuesIn(netPrecision),
::testing::ValuesIn(cpuParamsWithBlock_5D));
const auto staticBatchToSpaceParamsSet5D2 = ::testing::Combine(
::testing::ValuesIn(static_shapes_to_test_representation(staticInputShapes5D2)),
::testing::ValuesIn(blockShape5D2),
::testing::ValuesIn(cropsBegin5D2),
::testing::ValuesIn(cropsEnd5D2),
::testing::ValuesIn(netPrecision),
::testing::ValuesIn(cpuParamsWithBlock_5D));
const auto dynamicBatchToSpaceParamsSet5D2 = ::testing::Combine(
::testing::ValuesIn(dynamicInputShapes5D2),
::testing::ValuesIn(blockShape5D2),
::testing::ValuesIn(cropsBegin5D2),
::testing::ValuesIn(cropsEnd5D2),
::testing::ValuesIn(netPrecision),
::testing::ValuesIn(cpuParams_5D));
const auto dynamicBatchToSpaceParamsWithBlockedSet5D2 = ::testing::Combine(
::testing::ValuesIn(dynamicInputShapes5D2Blocked),
::testing::ValuesIn(blockShape5D2),
::testing::ValuesIn(cropsBegin5D2),
::testing::ValuesIn(cropsEnd5D2),
::testing::ValuesIn(netPrecision),
::testing::ValuesIn(cpuParamsWithBlock_5D));
INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase1_5D, BatchToSpaceCPULayerTest,
staticBatchToSpaceParamsSet5D1, BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase1_5D, BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsSet5D1, BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked1_5D, BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsWithBlockedSet5D1, BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_StaticBatchToSpaceCPULayerTestCase2_5D, BatchToSpaceCPULayerTest,
staticBatchToSpaceParamsSet5D2, BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCase2_5D, BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsSet5D2, BatchToSpaceCPULayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_DynamicBatchToSpaceCPULayerTestCaseWithBlocked2_5D, BatchToSpaceCPULayerTest,
dynamicBatchToSpaceParamsWithBlockedSet5D2, BatchToSpaceCPULayerTest::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions

View File

@ -12,7 +12,7 @@ std::shared_ptr<ngraph::Node> makeBatchToSpace(const ngraph::Output<Node> &in,
const std::vector<int64_t> &blockShape,
const std::vector<int64_t> &cropsBegin,
const std::vector<int64_t> &cropsEnd) {
ngraph::Shape constShape = {in.get_shape().size()};
ngraph::Shape constShape = {in.get_partial_shape().size()};
auto blockShapeNode = std::make_shared<ngraph::opset1::Constant>(ngraph::element::i64, constShape,
blockShape.data());
auto cropsBeginNode = std::make_shared<ngraph::opset1::Constant>(ngraph::element::i64, constShape,