[CPU] fix: supported Tile with more than 5 dims (#2062)
This commit is contained in:
parent
cba0892832
commit
7c95e8f8ff
@ -45,21 +45,7 @@ void MKLDNNTileNode::initSupportedPrimitiveDescriptors() {
|
||||
auto outputDataType = MKLDNNExtensionUtils::IEPrecisionToDataType(precision);
|
||||
|
||||
auto& inDims = getParentEdgeAt(0)->getDims();
|
||||
memory::format fmt = memory::format::any;
|
||||
if (inDims.ndims() == 1) {
|
||||
fmt = memory::format::x;
|
||||
} else if (inDims.ndims() == 2) {
|
||||
fmt = memory::format::nc;
|
||||
} else if (inDims.ndims() == 3) {
|
||||
fmt = memory::format::tnc;
|
||||
} else if (inDims.ndims() == 4) {
|
||||
fmt = memory::format::nchw;
|
||||
} else if (inDims.ndims() == 5) {
|
||||
fmt = memory::format::ncdhw;
|
||||
}
|
||||
if (fmt == memory::format::any) {
|
||||
THROW_IE_EXCEPTION << "Tile " << getName() << " supports only 2D, 4D and 5D dimensions!";
|
||||
}
|
||||
memory::format fmt = MKLDNNMemory::GetPlainFormat(inDims);
|
||||
|
||||
InferenceEngine::LayerConfig config;
|
||||
config.dynBatchSupport = true;
|
||||
|
@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "single_layer_tests/tile.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
|
||||
namespace {
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32
|
||||
};
|
||||
|
||||
const std::vector<std::vector<size_t>> repeats = {
|
||||
{1, 2, 3},
|
||||
{2, 1, 1},
|
||||
{2, 3, 1},
|
||||
{2, 2, 2},
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Tile, TileLayerTest,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(repeats),
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(std::vector<size_t>({2, 3, 4})),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
TileLayerTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Tile6d, TileLayerTest,
|
||||
::testing::Combine(
|
||||
::testing::Values(std::vector<size_t>({1, 1, 1, 2, 1, 2})),
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(std::vector<size_t>({1, 4, 3, 1, 3, 1})),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
TileLayerTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include "functional_test_utils/layer_test_utils.hpp"
|
||||
#include "ngraph_functions/builders.hpp"
|
||||
|
||||
typedef std::vector<size_t> TileSpecificParams;
|
||||
typedef std::tuple<
|
||||
TileSpecificParams,
|
||||
InferenceEngine::Precision, // Net precision
|
||||
InferenceEngine::SizeVector, // Input shapes
|
||||
LayerTestsUtils::TargetDevice // Device name
|
||||
> TileLayerTestParamsSet;
|
||||
|
||||
namespace LayerTestsDefinitions {
|
||||
|
||||
class TileLayerTest : public testing::WithParamInterface<TileLayerTestParamsSet>,
|
||||
public LayerTestsUtils::LayerTestsCommon {
|
||||
public:
|
||||
static std::string getTestCaseName(testing::TestParamInfo<TileLayerTestParamsSet> obj);
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
|
||||
} // namespace LayerTestsDefinitions
|
@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
#include "single_layer_tests/tile.hpp"
|
||||
|
||||
|
||||
namespace LayerTestsDefinitions {
|
||||
|
||||
std::string TileLayerTest::getTestCaseName(testing::TestParamInfo<TileLayerTestParamsSet> obj) {
|
||||
TileSpecificParams tileParams;
|
||||
InferenceEngine::Precision netPrecision;
|
||||
InferenceEngine::SizeVector inputShapes;
|
||||
std::string targetDevice;
|
||||
std::tie(tileParams, netPrecision, inputShapes, targetDevice) = obj.param;
|
||||
|
||||
std::ostringstream result;
|
||||
result << "IS=" << CommonTestUtils::vec2str(inputShapes) << "_";
|
||||
result << "Repeats=" << CommonTestUtils::vec2str(tileParams) << "_";
|
||||
result << "netPRC=" << netPrecision.name() << "_";
|
||||
result << "targetDevice=" << targetDevice;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void TileLayerTest::SetUp() {
|
||||
TileSpecificParams tileParams;
|
||||
std::vector<size_t> inputShape;
|
||||
auto netPrecision = InferenceEngine::Precision::UNSPECIFIED;
|
||||
std::tie(tileParams, netPrecision, inputShape, targetDevice) = this->GetParam();
|
||||
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 tile = ngraph::builder::makeTile(paramOuts[0], tileParams);
|
||||
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(tile)};
|
||||
function = std::make_shared<ngraph::Function>(results, params, "tile");
|
||||
}
|
||||
|
||||
TEST_P(TileLayerTest, CompareWithRefs) {
|
||||
Run();
|
||||
}
|
||||
|
||||
} // namespace LayerTestsDefinitions
|
@ -415,5 +415,9 @@ std::shared_ptr<ngraph::Node> makeRNNCell(const OutputVector& in,
|
||||
const std::vector<float>& activations_alpha = {},
|
||||
const std::vector<float>& activations_beta = {},
|
||||
float clip = 0.f);
|
||||
|
||||
std::shared_ptr<ngraph::Node> makeTile(const ngraph::Output<Node>& in,
|
||||
const std::vector<size_t>& repeats);
|
||||
|
||||
} // namespace builder
|
||||
} // namespace ngraph
|
||||
|
18
inference-engine/tests/ngraph_functions/src/tile.cpp
Normal file
18
inference-engine/tests/ngraph_functions/src/tile.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "ngraph_functions/builders.hpp"
|
||||
|
||||
namespace ngraph {
|
||||
namespace builder {
|
||||
|
||||
std::shared_ptr<ngraph::Node> makeTile(const ngraph::Output<Node>& in,
|
||||
const std::vector<size_t>& repeats) {
|
||||
auto repeatsNode = std::make_shared<ngraph::opset1::Constant>(ngraph::element::i64, std::vector<size_t>{repeats.size()}, repeats);
|
||||
auto tileNode = std::make_shared<ngraph::opset1::Tile>(in, repeatsNode);
|
||||
return tileNode;
|
||||
}
|
||||
|
||||
} // namespace builder
|
||||
} // namespace ngraph
|
Loading…
Reference in New Issue
Block a user