[IE TESTS] Range (#1094)

This commit is contained in:
Irina Efode
2020-06-23 20:39:06 +03:00
committed by GitHub
parent 69a342ea68
commit 11d3bd1cb3
4 changed files with 121 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <vector>
#include "single_layer_tests/range.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
namespace {
const std::vector<float> start = { 1.0f, 1.2f };
const std::vector<float> stop = { 5.0f, 5.2f };
const std::vector<float> step = { 1.0f, 0.1f };
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16
};
INSTANTIATE_TEST_CASE_P(Basic, RangeLayerTest,
::testing::Combine(
::testing::ValuesIn(start),
::testing::ValuesIn(stop),
::testing::ValuesIn(step),
::testing::ValuesIn(netPrecisions),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
RangeLayerTest::getTestCaseName);
} // namespace

View File

@@ -31,5 +31,7 @@ std::vector<std::string> disabledTestPatterns() {
R"(.*Reduce.*type=Logical.*)",
R"(.*Reduce.*axes=\(1\.-1\).*)",
R"(.*Reduce.*axes=\(0\.3\)_type=Prod.*)",
// TODO: Issue 34055
R"(.*RangeLayerTest.*)",
};
}

View File

@@ -0,0 +1,33 @@
// Copyright (C) 2020 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"
namespace LayerTestsDefinitions {
typedef std::tuple<
float, // start
float, // stop
float, // step
InferenceEngine::Precision, // Net precision
std::string // Target device name
> RangeParams;
class RangeLayerTest : public testing::WithParamInterface<RangeParams>,
public LayerTestsUtils::LayerTestsCommon {
public:
static std::string getTestCaseName(testing::TestParamInfo<RangeParams> obj);
protected:
void SetUp() override;
};
} // namespace LayerTestsDefinitions

View File

@@ -0,0 +1,55 @@
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
#include <tuple>
#include <string>
#include <vector>
#include <memory>
#include <functional_test_utils/skip_tests_config.hpp>
#include "ie_precision.hpp"
#include "common_test_utils/common_utils.hpp"
#include "functional_test_utils/layer_test_utils.hpp"
#include "single_layer_tests/range.hpp"
namespace LayerTestsDefinitions {
std::string RangeLayerTest::getTestCaseName(testing::TestParamInfo<RangeParams> obj) {
InferenceEngine::Precision netPrecision;
float start, stop, step;
std::string targetDevice;
std::tie(start, stop, step, netPrecision, targetDevice) = obj.param;
std::ostringstream result;
const char separator = '_';
result << "Start=" << start << separator;
result << "Stop=" << stop << separator;
result << "Step=" << step << separator;
result << "netPRC=" << netPrecision.name() << separator;
result << "targetDevice=" << targetDevice;
return result.str();
}
void RangeLayerTest::SetUp() {
InferenceEngine::Precision netPrecision;
float start, stop, step;
std::tie(start, stop, step, netPrecision, targetDevice) = GetParam();
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
std::vector<size_t> inShape;
auto params = ngraph::builder::makeParams(ngPrc, {inShape});
auto start_constant = std::make_shared<ngraph::opset1::Constant>(ngPrc, ngraph::Shape{}, start);
auto stop_constant = std::make_shared<ngraph::opset1::Constant>(ngPrc, ngraph::Shape{}, stop);
auto step_constant = std::make_shared<ngraph::opset1::Constant>(ngPrc, ngraph::Shape{}, step);
auto range = std::make_shared<ngraph::opset3::Range>(start_constant, stop_constant, step_constant);
const ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(range)};
function = std::make_shared<ngraph::Function>(results, params, "Range");
}
TEST_P(RangeLayerTest, CompareWithRefs) {
Run();
}
} // namespace LayerTestsDefinitions