Unify SLTs classes of Convert and ConvertLike operations (#7129)

* update comparisiofiles to use const ref param

* introduce conversion layer test definitions

* adapt old tests to the new format

* remove old duplicated conversion tests

* fix "convertion" typo to "conversion"

* fix style issues and abandon unnecessary changes

* fix include order

* update remaining conversion tests to use introduced class

* fix gpu class test naming

* bring back convert.hpp and convert_like.hpp files

* bring back convert.hppcppd convert_like.cpp files

* bring back single_layer_tests/convert.hpp file

* add missing copyright info

* fix issue with braces initiator for conversion types

* add missing convert_like tests

* add deprecated code macros

* update deprecated code macro message

* add missing space in deprecated code macro message

* update skip ConvertLike tests ticket

* update deprecated code to  use IE macros

* update remaining ngraph_deprecated macros to use IE macros
This commit is contained in:
Dawid Kożykowski 2021-09-01 13:19:38 +02:00 committed by GitHub
parent 8550579b60
commit 3081fac758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 208 additions and 151 deletions

View File

@ -47,7 +47,7 @@ public:
static std::string getTestCaseName(const testing::TestParamInfo<ConvertParams>& obj) {
const auto& param = obj.param;
std::ostringstream result;
result << "convertionType=" << conversionNames[param.conversionType] << "_";
result << "conversionType=" << conversionNames[param.conversionType] << "_";
result << "shape=" << param.pshape << "_";
result << "iType=" << param.inType << "_";
result << "oType=" << param.outType;

View File

@ -2,13 +2,18 @@
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_layer/convert.hpp"
#include "shared_test_classes/single_layer/conversion.hpp"
#include <vector>
using namespace LayerTestsDefinitions;
namespace {
const std::vector<ngraph::helpers::ConversionTypes> conversionOpTypes = {
ngraph::helpers::ConversionTypes::CONVERT,
ngraph::helpers::ConversionTypes::CONVERT_LIKE,
};
const std::vector<std::vector<size_t>> inShape = {{1, 2, 3, 4}};
const std::vector<InferenceEngine::Precision> precisions = {
@ -21,18 +26,19 @@ const std::vector<InferenceEngine::Precision> precisions = {
InferenceEngine::Precision::BF16, InferenceEngine::Precision::FP16,
InferenceEngine::Precision::FP32, InferenceEngine::Precision::FP64};
TEST_P(ConvertLayerTest, Serialize) {
TEST_P(ConversionLayerTest, Serialize) {
Serialize();
}
INSTANTIATE_TEST_SUITE_P(
smoke_Serialization_ConvertLayerTest, ConvertLayerTest,
::testing::Combine(::testing::Values(inShape),
smoke_Serialization_ConversionLayerTest, ConversionLayerTest,
::testing::Combine(::testing::ValuesIn(conversionOpTypes),
::testing::Values(inShape),
::testing::ValuesIn(precisions),
::testing::ValuesIn(precisions),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
ConvertLayerTest::getTestCaseName);
ConversionLayerTest::getTestCaseName);
} // namespace
} // namespace

View File

@ -0,0 +1,50 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <vector>
#include "common_test_utils/test_constants.hpp"
#include "single_layer_tests/conversion.hpp"
using namespace LayerTestsDefinitions;
namespace {
const std::vector<ngraph::helpers::ConversionTypes> conversionOpTypes = {
ngraph::helpers::ConversionTypes::CONVERT,
ngraph::helpers::ConversionTypes::CONVERT_LIKE,
};
const std::vector<std::vector<size_t>> inShape = {{1, 2, 3, 4}};
const std::vector<InferenceEngine::Precision> netPrecisions = {
// Ticket: 59594
// InferenceEngine::Precision::I4,
InferenceEngine::Precision::I8,
InferenceEngine::Precision::I16,
InferenceEngine::Precision::I32,
InferenceEngine::Precision::I64,
// Ticket: 59594
// InferenceEngine::Precision::BIN,
// InferenceEngine::Precision::BOOL,
// InferenceEngine::Precision::U4,
InferenceEngine::Precision::U8,
InferenceEngine::Precision::U16,
// Ticket: 59594
// InferenceEngine::Precision::U32,
InferenceEngine::Precision::U64,
InferenceEngine::Precision::BF16,
InferenceEngine::Precision::FP16,
InferenceEngine::Precision::FP32};
INSTANTIATE_TEST_SUITE_P(smoke_ConversionLayerTest,
ConversionLayerTest,
::testing::Combine(::testing::ValuesIn(conversionOpTypes),
::testing::Values(inShape),
::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
ConversionLayerTest::getTestCaseName);
} // namespace

View File

@ -1,47 +0,0 @@
// Copyright (C) 2018-2021 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;
using namespace InferenceEngine;
namespace {
const std::vector<std::vector<size_t>> inShape = {{1, 2, 3, 4}};
const std::vector<Precision> precisions = {
// Ticket: 59594
// Precision::I4,
Precision::I8,
Precision::I16,
Precision::I32,
Precision::I64,
// Ticket: 59594
// Precision::BIN,
// Precision::BOOL,
// Precision::U4,
Precision::U8,
Precision::U16,
// Ticket: 59594
// Precision::U32,
Precision::U64,
Precision::BF16,
Precision::FP16,
Precision::FP32
};
INSTANTIATE_TEST_SUITE_P(smoke_ConvertLayerTest, ConvertLayerTest,
::testing::Combine(
::testing::Values(inShape),
::testing::ValuesIn(precisions),
::testing::ValuesIn(precisions),
::testing::Values(Layout::ANY),
::testing::Values(Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
ConvertLayerTest::getTestCaseName);
} // namespace

View File

@ -1,33 +0,0 @@
// Copyright (C) 2018-2021 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_SUITE_P(smoke_NoReshape, ConvertLikeLayerTest,
::testing::Combine(
::testing::Values(inShape),
::testing::ValuesIn(netPrecisions),
::testing::Values(inShape),
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
ConvertLikeLayerTest::getTestCaseName);
} // namespace

View File

@ -29,8 +29,8 @@ std::vector<std::string> disabledTestPatterns() {
R"(.*InferRequestPreprocessDynamicallyInSetBlobTest.*oPRC=0.*_oLT=1.*)",
// TODO: Issue: 34348
R"(.*IEClassGetAvailableDevices.*)",
// TODO: Issue: 25533
R"(.*ConvertLikeLayerTest.*)",
// TODO: Issue: 63469
R"(.*ConversionLayerTest.*ConvertLike.*)",
// TODO: Issue: 34055
R"(.*ShapeOfLayerTest.*)",
R"(.*ReluShapeOfSubgraphTest.*)",

View File

@ -2,26 +2,31 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <shared_test_classes/single_layer/convert.hpp>
#include <shared_test_classes/single_layer/conversion.hpp>
using namespace LayerTestsDefinitions;
using namespace InferenceEngine;
namespace CPULayerTestsDefinitions {
class ConvertCPULayerTest : public ConvertLayerTest {};
class ConvertCPULayerTest : public ConversionLayerTest {};
TEST_P(ConvertCPULayerTest, CompareWithRefs) {
SKIP_IF_CURRENT_TEST_IS_DISABLED()
ConvertParamsTuple params = GetParam();
inPrc = std::get<1>(params);
outPrc = std::get<2>(params);
ConversionParamsTuple params = GetParam();
inPrc = std::get<2>(params);
outPrc = std::get<3>(params);
Run();
}
namespace {
const std::vector<ngraph::helpers::ConversionTypes> conversionOpTypes = {
ngraph::helpers::ConversionTypes::CONVERT,
ngraph::helpers::ConversionTypes::CONVERT_LIKE,
};
const std::vector<std::vector<size_t>> inShape = {{1, 2, 3, 4}};
// List of precisions natively supported by mkldnn.
@ -33,24 +38,26 @@ const std::vector<Precision> precisions = {
Precision::BF16
};
INSTANTIATE_TEST_SUITE_P(smoke_ConvertLayerTest_From_BF16, ConvertCPULayerTest,
INSTANTIATE_TEST_SUITE_P(smoke_ConversionLayerTest_From_BF16, ConvertCPULayerTest,
::testing::Combine(
::testing::ValuesIn(conversionOpTypes),
::testing::Values(inShape),
::testing::Values(Precision::BF16),
::testing::ValuesIn(precisions),
::testing::Values(Layout::ANY),
::testing::Values(Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
ConvertLayerTest::getTestCaseName);
ConversionLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_ConvertLayerTest_To_BF16, ConvertCPULayerTest,
INSTANTIATE_TEST_SUITE_P(smoke_ConversionLayerTest_To_BF16, ConvertCPULayerTest,
::testing::Combine(
::testing::ValuesIn(conversionOpTypes),
::testing::Values(inShape),
::testing::ValuesIn(precisions),
::testing::Values(Precision::BF16),
::testing::Values(Layout::ANY),
::testing::Values(Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
ConvertLayerTest::getTestCaseName);
ConversionLayerTest::getTestCaseName);
} // namespace
} // namespace CPULayerTestsDefinitions
} // namespace CPULayerTestsDefinitions

View File

@ -4,12 +4,17 @@
#include <vector>
#include "single_layer_tests/convert.hpp"
#include "single_layer_tests/conversion.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
namespace {
const std::vector<ngraph::helpers::ConversionTypes> conversionOpTypes = {
ngraph::helpers::ConversionTypes::CONVERT,
ngraph::helpers::ConversionTypes::CONVERT_LIKE,
};
const std::vector<std::vector<size_t>> inShape = {{1, 2, 3, 4}};
const std::vector<InferenceEngine::Precision> netPrecisions = {
@ -19,14 +24,15 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::I8,
};
INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, ConvertLayerTest,
INSTANTIATE_TEST_SUITE_P(smoke_NoReshape, ConversionLayerTest,
::testing::Combine(
::testing::ValuesIn(conversionOpTypes),
::testing::Values(inShape),
::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_GPU)),
ConvertLayerTest::getTestCaseName);
ConversionLayerTest::getTestCaseName);
} // namespace

View File

@ -1,33 +0,0 @@
// Copyright (C) 2018-2021 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_SUITE_P(smoke_NoReshape, ConvertLikeLayerTest,
::testing::Combine(
::testing::Values(inShape),
::testing::ValuesIn(netPrecisions),
::testing::Values(inShape),
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(CommonTestUtils::DEVICE_GPU)),
ConvertLikeLayerTest::getTestCaseName);
} // namespace

View File

@ -4,12 +4,10 @@
#pragma once
#include "shared_test_classes/single_layer/convert_like.hpp"
#include "shared_test_classes/single_layer/conversion.hpp"
namespace LayerTestsDefinitions {
TEST_P(ConvertLikeLayerTest, CompareWithRefs) {
TEST_P(ConversionLayerTest, CompareWithRefs) {
Run();
};
} // namespace LayerTestsDefinitions
} // namespace LayerTestsDefinitions

View File

@ -4,6 +4,9 @@
#pragma once
#include <ie_api.h>
IE_SUPPRESS_DEPRECATED_START
#include "shared_test_classes/single_layer/convert.hpp"
namespace LayerTestsDefinitions {
@ -12,4 +15,6 @@ TEST_P(ConvertLayerTest, CompareWithRefs) {
Run();
};
} // namespace LayerTestsDefinitions
} // namespace LayerTestsDefinitions
IE_SUPPRESS_DEPRECATED_END

View File

@ -36,6 +36,6 @@ protected:
void SetUp() override;
public:
static std::string getTestCaseName(testing::TestParamInfo<ComparisonTestParams> obj);
static std::string getTestCaseName(const testing::TestParamInfo<ComparisonTestParams> &obj);
};
} // namespace LayerTestsDefinitions

View File

@ -0,0 +1,39 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <gtest/gtest.h>
#include <map>
#include <shared_test_classes/base/layer_test_utils.hpp>
#include "common_test_utils/common_utils.hpp"
#include "common_test_utils/test_common.hpp"
#include "common_test_utils/test_constants.hpp"
#include "ie_core.hpp"
namespace LayerTestsDefinitions {
static std::map<ngraph::helpers::ConversionTypes, std::string> conversionNames = {
{ngraph::helpers::ConversionTypes::CONVERT, "Convert"},
{ngraph::helpers::ConversionTypes::CONVERT_LIKE, "ConvertLike"}};
using ConversionParamsTuple = typename std::tuple<ngraph::helpers::ConversionTypes, // Convertion op type
std::vector<std::vector<size_t>>, // Input1 shapes
InferenceEngine::Precision, // Input1 precision
InferenceEngine::Precision, // Input2 precision
InferenceEngine::Layout, // Input layout
InferenceEngine::Layout, // Output layout
std::string>; // Device name
class ConversionLayerTest : public testing::WithParamInterface<ConversionParamsTuple>,
virtual public LayerTestsUtils::LayerTestsCommon {
public:
static std::string getTestCaseName(const testing::TestParamInfo<ConversionParamsTuple>& obj);
protected:
void SetUp() override;
};
} // namespace LayerTestsDefinitions

View File

@ -23,8 +23,10 @@ using ConvertParamsTuple = typename std::tuple<
InferenceEngine::Layout, // Output layout
std::string>; // Device name
class ConvertLayerTest : public testing::WithParamInterface<ConvertParamsTuple>,
virtual public LayerTestsUtils::LayerTestsCommon {
class INFERENCE_ENGINE_DEPRECATED("This class is deprecated and will be removed soon. "
"Please use new ConversionLayerTest class.") ConvertLayerTest :
public testing::WithParamInterface<ConvertParamsTuple>,
virtual public LayerTestsUtils::LayerTestsCommon {
public:
static std::string getTestCaseName(const testing::TestParamInfo<ConvertParamsTuple> &obj);
@ -32,4 +34,4 @@ protected:
void SetUp() override;
};
} // namespace LayerTestsDefinitions
} // namespace LayerTestsDefinitions

View File

@ -24,8 +24,10 @@ using ConvertLikeParamsTuple = typename std::tuple<
InferenceEngine::Layout, // Output layout
std::string>; // Device name
class ConvertLikeLayerTest : public testing::WithParamInterface<ConvertLikeParamsTuple>,
virtual public LayerTestsUtils::LayerTestsCommon {
class INFERENCE_ENGINE_DEPRECATED("This class is deprecated and will be removed soon. "
"Please use new ConversionLayerTest class.") ConvertLikeLayerTest :
public testing::WithParamInterface<ConvertLikeParamsTuple>,
virtual public LayerTestsUtils::LayerTestsCommon {
public:
static std::string getTestCaseName(const testing::TestParamInfo<ConvertLikeParamsTuple> &obj);
@ -33,4 +35,4 @@ protected:
void SetUp() override;
};
} // namespace LayerTestsDefinitions
} // namespace LayerTestsDefinitions

View File

@ -8,7 +8,7 @@
using namespace LayerTestsDefinitions::ComparisonParams;
namespace LayerTestsDefinitions {
std::string ComparisonLayerTest::getTestCaseName(testing::TestParamInfo<ComparisonTestParams> obj) {
std::string ComparisonLayerTest::getTestCaseName(const testing::TestParamInfo<ComparisonTestParams> &obj) {
InputShapesTuple inputShapes;
InferenceEngine::Precision ngInputsPrecision;
ngraph::helpers::ComparisonTypes comparisonOpType;

View File

@ -0,0 +1,45 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_layer/conversion.hpp"
#include "ngraph_functions/builders.hpp"
namespace LayerTestsDefinitions {
std::string ConversionLayerTest::getTestCaseName(const testing::TestParamInfo<ConversionParamsTuple>& obj) {
ngraph::helpers::ConversionTypes conversionOpType;
InferenceEngine::Precision inputPrecision, targetPrecision;
InferenceEngine::Layout inLayout, outLayout;
std::string targetName;
std::vector<std::vector<size_t>> inputShape;
std::tie(conversionOpType, inputShape, inputPrecision, targetPrecision, inLayout, outLayout, targetName) =
obj.param;
std::ostringstream result;
result << "conversionOpType=" << conversionNames[conversionOpType] << "_";
result << "IS=" << CommonTestUtils::vec2str(inputShape) << "_";
result << "inputPRC=" << inputPrecision.name() << "_";
result << "targetPRC=" << targetPrecision.name() << "_";
result << "inL=" << inLayout << "_";
result << "outL=" << outLayout << "_";
result << "trgDev=" << targetName;
return result.str();
}
void ConversionLayerTest::SetUp() {
ngraph::helpers::ConversionTypes conversionOpType;
InferenceEngine::Precision inputPrecision, targetPrecision;
std::vector<std::vector<size_t>> inputShape;
std::tie(conversionOpType, inputShape, inputPrecision, targetPrecision, inLayout, outLayout, targetDevice) =
GetParam();
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision);
auto targetPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(targetPrecision);
auto params = ngraph::builder::makeParams(ngPrc, inputShape);
auto conversion = ngraph::builder::makeConversion(params.front(), targetPrc, conversionOpType);
ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(conversion)};
function = std::make_shared<ngraph::Function>(results, params, "Conversion");
}
} // namespace LayerTestsDefinitions

View File

@ -2,6 +2,9 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <ie_api.h>
IE_SUPPRESS_DEPRECATED_START
#include "shared_test_classes/single_layer/convert.hpp"
namespace LayerTestsDefinitions {
@ -33,4 +36,6 @@ void ConvertLayerTest::SetUp() {
ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(convert)};
function = std::make_shared<ngraph::Function>(results, params, "Convert");
}
} // namespace LayerTestsDefinitions
} // namespace LayerTestsDefinitions
IE_SUPPRESS_DEPRECATED_END

View File

@ -2,6 +2,9 @@
// SPDX-License-Identifier: Apache-2.0
//
#include <ie_api.h>
IE_SUPPRESS_DEPRECATED_START
#include "shared_test_classes/single_layer/convert_like.hpp"
namespace LayerTestsDefinitions {
@ -35,4 +38,6 @@ void ConvertLikeLayerTest::SetUp() {
ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(convertLike)};
function = std::make_shared<ngraph::Function>(results, params, "ConvertLike");
}
} // namespace LayerTestsDefinitions
} // namespace LayerTestsDefinitions
IE_SUPPRESS_DEPRECATED_END