[IE TESTS] Add Convert, ConvertLike single layer tests. Refactoring Range
(#1212)
This commit is contained in:
parent
ea10ad5ed4
commit
476dc0f00f
@ -0,0 +1,30 @@
|
||||
// Copyright (C) 2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "single_layer_tests/convert.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
|
||||
namespace {
|
||||
const std::vector<std::vector<size_t>> inShape = {{1, 2, 3, 4}};
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32,
|
||||
InferenceEngine::Precision::FP16,
|
||||
InferenceEngine::Precision::U8,
|
||||
InferenceEngine::Precision::I8,
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(NoReshape, ConvertLayerTest,
|
||||
::testing::Combine(
|
||||
::testing::Values(inShape),
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
ConvertLayerTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2019 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "single_layer_tests/convert_like.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
|
||||
namespace {
|
||||
const std::vector<std::vector<size_t>> inShape = {{1, 2, 3, 4}};
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32,
|
||||
InferenceEngine::Precision::FP16,
|
||||
InferenceEngine::Precision::U8,
|
||||
InferenceEngine::Precision::I8,
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(NoReshape, ConvertLikeLayerTest,
|
||||
::testing::Combine(
|
||||
::testing::Values(inShape),
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(inShape),
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
ConvertLikeLayerTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
@ -31,13 +31,18 @@ std::vector<std::string> disabledTestPatterns() {
|
||||
R"(.*Reduce.*type=Logical.*)",
|
||||
R"(.*Reduce.*axes=\(1\.-1\).*)",
|
||||
R"(.*Reduce.*axes=\(0\.3\)_type=Prod.*)",
|
||||
// TODO: Issue 34055
|
||||
// TODO: Issue: 34518
|
||||
R"(.*RangeLayerTest.*)",
|
||||
// TODO: Issue 34092
|
||||
R"(.*(RangeAddSubgraphTest).*Start=1.2.*Stop=(5.2|-5.2).*Step=(0.1|-0.1).*netPRC=FP16.*)",
|
||||
// TODO: Issue: 34083
|
||||
#if (defined(_WIN32) || defined(_WIN64))
|
||||
R"(.*(CoreThreadingTestsWithIterations).*(smoke_LoadNetworkAccuracy).*)",
|
||||
#endif
|
||||
// TODO: Issue: 34348
|
||||
R"(.*IEClassGetAvailableDevices.*)",
|
||||
// TODO: Issue: 25533
|
||||
R"(.*ConvertLikeLayerTest.*)",
|
||||
//TODO: Issue: 34516
|
||||
R"(.*ConvertLayerTest.*)",
|
||||
};
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "subgraph_tests/range_add.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
|
||||
namespace {
|
||||
|
||||
const std::vector<float> positiveStart = { 1.0f, 1.2f };
|
||||
const std::vector<float> positiveStop = { 5.0f, 5.2f };
|
||||
const std::vector<float> positiveStep = { 1.0f, 0.1f };
|
||||
|
||||
const std::vector<float> negativeStart = { 1.0f, 1.2f };
|
||||
const std::vector<float> negativeStop = { -5.0f, -5.2f };
|
||||
const std::vector<float> negativeStep = { -1.0f, -0.1f };
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32,
|
||||
InferenceEngine::Precision::FP16
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(BasicPositive, RangeAddSubgraphTest,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(positiveStart),
|
||||
::testing::ValuesIn(positiveStop),
|
||||
::testing::ValuesIn(positiveStep),
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
RangeAddSubgraphTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(BasicNegative, RangeAddSubgraphTest,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(negativeStart),
|
||||
::testing::ValuesIn(negativeStop),
|
||||
::testing::ValuesIn(negativeStep),
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
RangeAddSubgraphTest::getTestCaseName);
|
||||
} // namespace
|
@ -0,0 +1,33 @@
|
||||
// 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 ConvertParamsTuple = typename std::tuple<
|
||||
std::vector<std::vector<size_t>>, // Input shapes
|
||||
InferenceEngine::Precision, // Source precision
|
||||
InferenceEngine::Precision, // Target precision
|
||||
std::string>; // Device name
|
||||
|
||||
class ConvertLayerTest : public testing::WithParamInterface<ConvertParamsTuple>,
|
||||
public LayerTestsUtils::LayerTestsCommon {
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<ConvertParamsTuple> &obj);
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
|
||||
} // namespace LayerTestsDefinitions
|
@ -0,0 +1,34 @@
|
||||
// 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 ConvertLikeParamsTuple = typename std::tuple<
|
||||
std::vector<std::vector<size_t>>, // Input1 shapes
|
||||
InferenceEngine::Precision, // Input1 precision
|
||||
std::vector<std::vector<size_t>>, // Input2 shapes
|
||||
InferenceEngine::Precision, // Input2 precision
|
||||
std::string>; // Device name
|
||||
|
||||
class ConvertLikeLayerTest : public testing::WithParamInterface<ConvertLikeParamsTuple>,
|
||||
public LayerTestsUtils::LayerTestsCommon {
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<ConvertLikeParamsTuple> &obj);
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
|
||||
} // namespace LayerTestsDefinitions
|
@ -23,8 +23,10 @@ typedef std::tuple<
|
||||
|
||||
class RangeLayerTest : public testing::WithParamInterface<RangeParams>,
|
||||
public LayerTestsUtils::LayerTestsCommon {
|
||||
float start, stop, step;
|
||||
public:
|
||||
static std::string getTestCaseName(testing::TestParamInfo<RangeParams> obj);
|
||||
void Infer();
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
|
@ -0,0 +1,26 @@
|
||||
// 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"
|
||||
|
||||
#include "single_layer_tests/range.hpp"
|
||||
|
||||
namespace LayerTestsDefinitions {
|
||||
|
||||
class RangeAddSubgraphTest : 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,46 @@
|
||||
// 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/convert.hpp"
|
||||
|
||||
namespace LayerTestsDefinitions {
|
||||
|
||||
std::string ConvertLayerTest::getTestCaseName(const testing::TestParamInfo<ConvertParamsTuple> &obj) {
|
||||
InferenceEngine::Precision inputPrecision, targetPrecision;
|
||||
std::string targetName;
|
||||
std::vector<std::vector<size_t>> inputShape;
|
||||
std::tie(inputShape, inputPrecision, targetPrecision, targetName) = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "IS=" << CommonTestUtils::vec2str(inputShape) << "_";
|
||||
result << "targetPRC=" << targetPrecision.name() << "_";
|
||||
result << "inputPRC=" << inputPrecision.name() << "_";
|
||||
result << "targetDevice=" << targetName;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void ConvertLayerTest::SetUp() {
|
||||
InferenceEngine::Precision inputPrecision, targetPrecision;
|
||||
std::vector<std::vector<size_t>> inputShape;
|
||||
std::tie(inputShape, inputPrecision, targetPrecision, targetDevice) = GetParam();
|
||||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision);
|
||||
auto targetPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(targetPrecision);
|
||||
auto params = ngraph::builder::makeParams(ngPrc, inputShape);
|
||||
auto convert = std::make_shared<ngraph::opset3::Convert>(params.front(), targetPrc);
|
||||
ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(convert)};
|
||||
function = std::make_shared<ngraph::Function>(results, params, "Convert");
|
||||
}
|
||||
|
||||
TEST_P(ConvertLayerTest, CompareWithRefs) {
|
||||
Run();
|
||||
};
|
||||
} // namespace LayerTestsDefinitions
|
@ -0,0 +1,48 @@
|
||||
// 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/convert_like.hpp"
|
||||
|
||||
namespace LayerTestsDefinitions {
|
||||
|
||||
std::string ConvertLikeLayerTest::getTestCaseName(const testing::TestParamInfo<ConvertLikeParamsTuple> &obj) {
|
||||
InferenceEngine::Precision precision, targetPrecision;
|
||||
std::vector<std::vector<size_t>> inputShape1, inputShape2;
|
||||
std::string targetName;
|
||||
std::tie(inputShape1, precision, inputShape2, targetPrecision, targetName) = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "IS1=" << CommonTestUtils::vec2str(inputShape1) << "_";
|
||||
result << "IS2=" << CommonTestUtils::vec2str(inputShape2) << "_";
|
||||
result << "PRC1=" << precision.name() << "_";
|
||||
result << "PRC2=" << targetPrecision.name() << "_";
|
||||
result << "targetDevice=" << targetName;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void ConvertLikeLayerTest::SetUp() {
|
||||
InferenceEngine::Precision inputPrecision, targetPrecision;
|
||||
std::vector<std::vector<size_t>> inputShape1, inputShape2;
|
||||
std::tie(inputShape1, inputPrecision, inputShape2, targetPrecision, targetDevice) = GetParam();
|
||||
auto ngPrc1 = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision);
|
||||
auto targetPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(targetPrecision);
|
||||
auto params = ngraph::builder::makeParams(ngPrc1, inputShape1);
|
||||
params.push_back(ngraph::builder::makeParams(targetPrc, inputShape2).front());
|
||||
auto convertLike = std::make_shared<ngraph::opset3::ConvertLike>(params.front(), params.back());
|
||||
ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(convertLike)};
|
||||
function = std::make_shared<ngraph::Function>(results, params, "ConvertLike");
|
||||
}
|
||||
|
||||
TEST_P(ConvertLikeLayerTest, CompareWithRefs) {
|
||||
Run();
|
||||
};
|
||||
} // namespace LayerTestsDefinitions
|
@ -11,12 +11,12 @@
|
||||
|
||||
#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;
|
||||
@ -33,17 +33,37 @@ std::string RangeLayerTest::getTestCaseName(testing::TestParamInfo<RangeParams>
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void RangeLayerTest::Infer() {
|
||||
inferRequest = executableNetwork.CreateInferRequest();
|
||||
inputs.clear();
|
||||
|
||||
auto blobStart = inferRequest.GetBlob("start");
|
||||
blobStart = FuncTestUtils::createAndFillBlobWithFloatArray(blobStart->getTensorDesc(), &start, 1);
|
||||
|
||||
auto blobStop = inferRequest.GetBlob("stop");
|
||||
blobStop = FuncTestUtils::createAndFillBlobWithFloatArray(blobStop->getTensorDesc(), &stop, 1);
|
||||
|
||||
auto blobStep = inferRequest.GetBlob("step");
|
||||
blobStep = FuncTestUtils::createAndFillBlobWithFloatArray(blobStep->getTensorDesc(), &step, 1);
|
||||
|
||||
inferRequest.Infer();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
auto params = ngraph::builder::makeParams(ngPrc, {std::vector<size_t>(), std::vector<size_t>(), std::vector<size_t>()});
|
||||
params[0]->set_friendly_name("start");
|
||||
params[1]->set_friendly_name("stop");
|
||||
params[2]->set_friendly_name("step");
|
||||
|
||||
auto range = std::make_shared<ngraph::opset3::Range>(params[0], params[1], params[2]);
|
||||
const ngraph::ResultVector results{std::make_shared<ngraph::opset1::Result>(range)};
|
||||
function = std::make_shared<ngraph::Function>(results, params, "Range");
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2020 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "subgraph_tests/range_add.hpp"
|
||||
|
||||
namespace LayerTestsDefinitions {
|
||||
|
||||
std::string RangeAddSubgraphTest::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 RangeAddSubgraphTest::SetUp() {
|
||||
InferenceEngine::Precision netPrecision;
|
||||
float start, stop, step;
|
||||
std::tie(start, stop, step, netPrecision, targetDevice) = GetParam();
|
||||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
|
||||
|
||||
auto startConstant = std::make_shared<ngraph::opset1::Constant>(ngPrc, ngraph::Shape{}, start);
|
||||
auto stopConstant = std::make_shared<ngraph::opset1::Constant>(ngPrc, ngraph::Shape{}, stop);
|
||||
auto stepConstant = std::make_shared<ngraph::opset1::Constant>(ngPrc, ngraph::Shape{}, step);
|
||||
auto range = std::make_shared<ngraph::opset3::Range>(startConstant, stopConstant, stepConstant);
|
||||
|
||||
auto params = ngraph::builder::makeParams(ngPrc, {range->get_shape()});
|
||||
auto eltwise = ngraph::builder::makeEltwise(params.front(), range, ngraph::helpers::EltwiseTypes::ADD);
|
||||
const ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(eltwise)};
|
||||
function = std::make_shared<ngraph::Function>(results, params, "RangeEltwise");
|
||||
}
|
||||
|
||||
TEST_P(RangeAddSubgraphTest, CompareWithRefs) {
|
||||
Run();
|
||||
}
|
||||
} // namespace LayerTestsDefinitions
|
@ -107,13 +107,13 @@ protected:
|
||||
|
||||
virtual std::vector<std::vector<std::uint8_t>> CalculateRefs();
|
||||
|
||||
InferenceEngine::InferRequest inferRequest;
|
||||
|
||||
private:
|
||||
void ConfigureNetwork() const;
|
||||
|
||||
std::vector<InferenceEngine::Blob::Ptr> GetOutputs();
|
||||
|
||||
std::shared_ptr<InferenceEngine::Core> core;
|
||||
InferenceEngine::InferRequest inferRequest;
|
||||
RefMode refMode = RefMode::INTERPRETER;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user