[IE TESTS] Add Reverse Seq single layer test (#1933)

* [IE TESTS] Add Reverse Seq single layer test

* Added spaces for better readability.
This commit is contained in:
Maksim Kutakov 2020-08-26 15:13:32 +03:00 committed by GitHub
parent fe6cb54bca
commit 99136f0940
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 153 additions and 1 deletions

View File

@ -0,0 +1,47 @@
// Copyright (C) 2019 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <vector>
#include "single_layer_tests/reverse_sequence.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
namespace {
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16,
InferenceEngine::Precision::U8, //doesn't match the reference values
InferenceEngine::Precision::I8, //doesn't match the reference values
InferenceEngine::Precision::U16,
InferenceEngine::Precision::I32
};
const std::vector<int64_t> batchAxisIndices = { 0L };
const std::vector<int64_t> seqAxisIndices = { 1L };
const std::vector<std::vector<size_t>> inputShapes = { {3, 10} }; //, 10, 20
const std::vector<std::vector<size_t>> reversSeqLengthsVecShapes = { {3} };
const std::vector<ngraph::helpers::InputLayerType> secondaryInputTypes = {
ngraph::helpers::InputLayerType::CONSTANT,
ngraph::helpers::InputLayerType::PARAMETER
};
INSTANTIATE_TEST_CASE_P(Basic_smoke, ReverseSequenceLayerTest,
::testing::Combine(
::testing::ValuesIn(batchAxisIndices),
::testing::ValuesIn(seqAxisIndices),
::testing::ValuesIn(inputShapes),
::testing::ValuesIn(reversSeqLengthsVecShapes),
::testing::ValuesIn(secondaryInputTypes),
::testing::ValuesIn(netPrecisions),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
ReverseSequenceLayerTest::getTestCaseName);
} // namespace

View File

@ -52,6 +52,8 @@ std::vector<std::string> disabledTestPatterns() {
// TODO: Issue: 32032
R"(.*ActivationParamLayerTest.*)",
// TODO: Issue: 30999 (Implement Interpolate reference in NGraph)
R"(.*InterpolateLayerTest.*)"
R"(.*InterpolateLayerTest.*)",
// TODO: Issue: 37862
R"(.*ReverseSequenceLayerTest.*netPRC=(I8|U8).*)"
};
}

View File

@ -0,0 +1,36 @@
// Copyright (C) 2019 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <tuple>
#include <string>
#include <vector>
#include <memory>
#include "functional_test_utils/layer_test_utils.hpp"
#include "ngraph_functions/builders.hpp"
#include "ngraph_functions/utils/ngraph_helpers.hpp"
namespace LayerTestsDefinitions {
using ReverseSequenceParamsTuple = typename std::tuple<
int64_t, // Index of the batch dimension
int64_t, // Index of the sequence dimension
std::vector<size_t>, // Input shapes
std::vector<size_t>, // Shape of the input vector with sequence lengths to be reversed
ngraph::helpers::InputLayerType, // Secondary input type
InferenceEngine::Precision, // Network precision
std::string>; // Device name
class ReverseSequenceLayerTest : public testing::WithParamInterface<ReverseSequenceParamsTuple>,
virtual public LayerTestsUtils::LayerTestsCommon {
public:
static std::string getTestCaseName(const testing::TestParamInfo<ReverseSequenceParamsTuple> &obj);
protected:
void SetUp() override;
};
} // namespace LayerTestsDefinitions

View File

@ -0,0 +1,67 @@
// Copyright (C) 2019 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <tuple>
#include <string>
#include <vector>
#include <memory>
#include "common_test_utils/common_utils.hpp"
#include "functional_test_utils/precision_utils.hpp"
#include "functional_test_utils/skip_tests_config.hpp"
#include "single_layer_tests/reverse_sequence.hpp"
namespace LayerTestsDefinitions {
std::string ReverseSequenceLayerTest::getTestCaseName(const testing::TestParamInfo<ReverseSequenceParamsTuple> &obj) {
int64_t batchAxisIndx;
int64_t seqAxisIndx;
InferenceEngine::Precision netPrecision;
std::string targetName;
std::vector<size_t> inputShape;
std::vector<size_t> secondInputShape;
ngraph::helpers::InputLayerType secondaryInputType;
std::tie(batchAxisIndx, seqAxisIndx, inputShape, secondInputShape, secondaryInputType, netPrecision, targetName) = obj.param;
std::ostringstream result;
result << "IS=" << CommonTestUtils::vec2str(inputShape) << "_";
result << "seqLengthsShape" << CommonTestUtils::vec2str(secondInputShape) << "_";
result << "secondaryInputType=" << secondaryInputType << "_";
result << "batchAxis=" << batchAxisIndx << "_";
result << "seqAxis=" << seqAxisIndx << "_";
result << "netPRC=" << netPrecision.name() << "_";
result << "targetDevice=" << targetName;
return result.str();
}
void ReverseSequenceLayerTest::SetUp() {
InferenceEngine::Precision netPrecision;
int64_t batchAxisIndx;
int64_t seqAxisIndx;
std::vector<size_t> inputShape;
std::vector<size_t> secondInputShape;
ngraph::helpers::InputLayerType secondaryInputType;
std::tie(batchAxisIndx, seqAxisIndx, inputShape, secondInputShape, secondaryInputType, netPrecision, targetDevice) = GetParam();
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
auto paramsIn = ngraph::builder::makeParams(ngPrc, {inputShape});
auto secondPrc = ngraph::element::Type_t::i32; //according to the specification
auto secondaryInput = ngraph::builder::makeInputLayer(secondPrc, secondaryInputType, secondInputShape);
if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) {
paramsIn.push_back(std::dynamic_pointer_cast<ngraph::opset3::Parameter>(secondaryInput));
}
auto reverse = std::make_shared<ngraph::opset1::ReverseSequence>(paramsIn[0], secondaryInput, batchAxisIndx, seqAxisIndx);
ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(reverse)};
function = std::make_shared<ngraph::Function>(results, paramsIn, "ReverseSequence");
}
TEST_P(ReverseSequenceLayerTest, CompareWithRefs) {
Run();
};
} // namespace LayerTestsDefinitions