[IE TESTS] Range (#1094)
This commit is contained in:
@@ -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
|
||||
@@ -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.*)",
|
||||
};
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user