diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reverse_sequence.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reverse_sequence.cpp new file mode 100644 index 00000000000..0a69b4c0967 --- /dev/null +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/reverse_sequence.cpp @@ -0,0 +1,47 @@ +// Copyright (C) 2019 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "single_layer_tests/reverse_sequence.hpp" +#include "common_test_utils/test_constants.hpp" + +using namespace LayerTestsDefinitions; + +namespace { + +const std::vector 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 batchAxisIndices = { 0L }; + +const std::vector seqAxisIndices = { 1L }; + +const std::vector> inputShapes = { {3, 10} }; //, 10, 20 + +const std::vector> reversSeqLengthsVecShapes = { {3} }; + +const std::vector 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 diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp index aabdea52432..a44f30de83a 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp @@ -52,6 +52,8 @@ std::vector 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).*)" }; } \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/reverse_sequence.hpp b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/reverse_sequence.hpp new file mode 100644 index 00000000000..e7badc3bdd2 --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/reverse_sequence.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2019 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#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, // Input shapes + std::vector, // 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, + virtual public LayerTestsUtils::LayerTestsCommon { +public: + static std::string getTestCaseName(const testing::TestParamInfo &obj); + +protected: + void SetUp() override; +}; + +} // namespace LayerTestsDefinitions \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/reverse_sequence.cpp b/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/reverse_sequence.cpp new file mode 100644 index 00000000000..d56bb12b25b --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/reverse_sequence.cpp @@ -0,0 +1,67 @@ +// Copyright (C) 2019 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include +#include + +#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 &obj) { + int64_t batchAxisIndx; + int64_t seqAxisIndx; + InferenceEngine::Precision netPrecision; + std::string targetName; + std::vector inputShape; + std::vector 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 inputShape; + std::vector 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(secondaryInput)); + } + + auto reverse = std::make_shared(paramsIn[0], secondaryInput, batchAxisIndx, seqAxisIndx); + ngraph::ResultVector results{std::make_shared(reverse)}; + function = std::make_shared(results, paramsIn, "ReverseSequence"); +} + +TEST_P(ReverseSequenceLayerTest, CompareWithRefs) { + Run(); +}; + +} // namespace LayerTestsDefinitions \ No newline at end of file