Skip to content

Commit

Permalink
[LPT] Convolution regression tests (openvinotoolkit#543)
Browse files Browse the repository at this point in the history
* [LPT] Base test infrastructure extending & Convolution test

* [LPT] LPT test infrastructure refactoring
  • Loading branch information
eshoguli authored and azhogov committed Jun 1, 2020
1 parent 9e12abf commit 61674c1
Show file tree
Hide file tree
Showing 20 changed files with 409 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
};

const std::vector<LayerTransformation::Params> trasformationParamValues = {
LayerTestsUtils::LayerTransformationParamsFactory::createParamCpu(),
LayerTestsUtils::LayerTransformationParamsFactory::createParamI8I8(),
LayerTestsUtils::LayerTransformationParamsFactory::createParamU8I8()
LayerTestsUtils::LayerTransformationParamsFactory::createParams(),
LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8(),
LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8()
};

INSTANTIATE_TEST_CASE_P(LPT, ConcatNeighboringGraphTransformation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
};

const std::vector<LayerTransformation::Params> trasformationParamValues = {
LayerTestsUtils::LayerTransformationParamsFactory::createParamCpu(),
LayerTestsUtils::LayerTransformationParamsFactory::createParamI8I8(),
LayerTestsUtils::LayerTransformationParamsFactory::createParamU8I8()
LayerTestsUtils::LayerTransformationParamsFactory::createParams(),
LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8(),
LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8()
};

INSTANTIATE_TEST_CASE_P(LPT, ConcatTransformation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
};

const std::vector<LayerTransformation::Params> trasformationParamValues = {
LayerTestsUtils::LayerTransformationParamsFactory::createParamCpu(),
LayerTestsUtils::LayerTransformationParamsFactory::createParamI8I8(),
LayerTestsUtils::LayerTransformationParamsFactory::createParamU8I8()
LayerTestsUtils::LayerTransformationParamsFactory::createParams(),
LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8(),
LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8()
};

const std::vector<bool> transparentIntermediateValues = { true, false };
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (C) 2019 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include <vector>

#include "low_precision_transformations/convolution_transformation.hpp"
#include "common_test_utils/test_constants.hpp"

using namespace LayerTestsDefinitions;

namespace {
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16
};

const std::vector<InferenceEngine::details::LayerTransformation::Params> trasformationParamValues = {
LayerTestsUtils::LayerTransformationParamsFactory::createParams()
};

const std::vector<bool> fqOnActivationsValues = { true, false };

const std::vector<bool> fqOnWeightsValues = { true, false };

INSTANTIATE_TEST_CASE_P(LPT, ConvolutionTransformation,
::testing::Combine(
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })),
::testing::Values(CommonTestUtils::DEVICE_CPU),
::testing::ValuesIn(trasformationParamValues),
::testing::ValuesIn(fqOnActivationsValues),
::testing::ValuesIn(fqOnWeightsValues)),
ConvolutionTransformation::getTestCaseName);
} // namespace




Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include <memory>
#include <tuple>
#include <vector>
#include <string>

#include <ie_core.hpp>

#include "common_test_utils/common_utils.hpp"
#include "functional_test_utils/plugin_cache.hpp"
#include "functional_test_utils/layer_test_utils.hpp"
#include "functional_test_utils/blob_utils.hpp"

#include "ngraph_functions/pass/convert_prc.hpp"

#include "ie_util_internal.hpp"
#include "functional_test_utils/low_precision_transformations/layer_transformation.hpp"
#include "low_precision_transformations/convolution.hpp"
#include "low_precision_transformations/scaleshift_to_convolution.hpp"


namespace LayerTestsUtils {

InferenceEngine::details::LowPrecisionTransformations LayerTransformation::getLowPrecisionTransformations(
const InferenceEngine::details::LayerTransformation::Params& params) const {
return InferenceEngine::details::LowPrecisionTransformer::getAllTransformations(params).
add<InferenceEngine::details::ConvolutionTransformation>(InferenceEngine::details::LayerTransformation::Params(params).
setPrecisionsOnActivations({ InferenceEngine::Precision::U8 }), "Convolution").
addCleanup<InferenceEngine::details::ScaleShiftToConvolutionTransformation>(
InferenceEngine::details::LayerTransformation::Params(params).setPrecisionsOnActivations({ InferenceEngine::Precision::U8 }),
"ScaleShift");
}

InferenceEngine::details::LayerTransformation::Params LayerTransformationParamsFactory::createParams() {
return InferenceEngine::details::LayerTransformation::Params(
true,
true,
true,
InferenceEngine::details::LayerTransformation::QuantizedTensorAlignment::UpdateLevel,
InferenceEngine::details::LayerTransformation::QuantizedTensorAlignment::None,
true,
true,
true);
}

} // namespace LayerTestsUtils
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
};

const std::vector<LayerTransformation::Params> trasformationParamValues = {
LayerTestsUtils::LayerTransformationParamsFactory::createParamGpu()
LayerTestsUtils::LayerTransformationParamsFactory::createParams()
};

INSTANTIATE_TEST_CASE_P(LPT, ConcatNeighboringGraphTransformation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
};

const std::vector<LayerTransformation::Params> trasformationParamValues = {
LayerTestsUtils::LayerTransformationParamsFactory::createParamGpu()
LayerTestsUtils::LayerTransformationParamsFactory::createParams()
};

INSTANTIATE_TEST_CASE_P(LPT, ConcatTransformation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
};

const std::vector<LayerTransformation::Params> trasformationParamValues = {
LayerTestsUtils::LayerTransformationParamsFactory::createParamGpu()
LayerTestsUtils::LayerTransformationParamsFactory::createParams()
};

const std::vector<bool> transparentIntermediates = { true, false };
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (C) 2019 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include <vector>

#include "low_precision_transformations/convolution_transformation.hpp"
#include "common_test_utils/test_constants.hpp"

using namespace LayerTestsDefinitions;

namespace {
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16
};

const std::vector<InferenceEngine::details::LayerTransformation::Params> trasformationParamValues = {
LayerTestsUtils::LayerTransformationParamsFactory::createParams()
};

const std::vector<bool> fqOnActivationsValues = { true, false };

const std::vector<bool> fqOnWeightsValues = { true, false };

INSTANTIATE_TEST_CASE_P(LPT, ConvolutionTransformation,
::testing::Combine(
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })),
::testing::Values(CommonTestUtils::DEVICE_GPU),
::testing::ValuesIn(trasformationParamValues),
::testing::ValuesIn(fqOnActivationsValues),
::testing::ValuesIn(fqOnWeightsValues)),
ConvolutionTransformation::getTestCaseName);
} // namespace




Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include <memory>
#include <tuple>
#include <vector>
#include <string>

#include <ie_core.hpp>

#include "common_test_utils/common_utils.hpp"
#include "functional_test_utils/plugin_cache.hpp"
#include "functional_test_utils/layer_test_utils.hpp"
#include "functional_test_utils/blob_utils.hpp"

#include "ngraph_functions/pass/convert_prc.hpp"

#include "ie_util_internal.hpp"
#include "functional_test_utils/low_precision_transformations/layer_transformation.hpp"
#include "low_precision_transformations/convolution.hpp"
#include "low_precision_transformations/scaleshift_to_convolution.hpp"


namespace LayerTestsUtils {

InferenceEngine::details::LowPrecisionTransformations LayerTransformation::getLowPrecisionTransformations(
const InferenceEngine::details::LayerTransformation::Params& params) const {
return InferenceEngine::details::LowPrecisionTransformer::getAllTransformations(params);
}

InferenceEngine::details::LayerTransformation::Params LayerTransformationParamsFactory::createParams() {
return InferenceEngine::details::LayerTransformation::Params(
true,
true,
true,
InferenceEngine::details::LayerTransformation::QuantizedTensorAlignment::UpdateLevel,
InferenceEngine::details::LayerTransformation::QuantizedTensorAlignment::None,
true,
true,
true);
}
} // namespace LayerTestsUtils
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

namespace LayerTestsDefinitions {

class ConcatNeighboringGraphTransformation : public LayerTestsUtils::LayerTransformation<LayerTestsUtils::LayerTransformationParams> {
class ConcatNeighboringGraphTransformation :
public testing::WithParamInterface<LayerTestsUtils::LayerTransformationParams>,
public LayerTestsUtils::LayerTransformation {
public:
static std::string getTestCaseName(testing::TestParamInfo<LayerTestsUtils::LayerTransformationParams> obj);
InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

namespace LayerTestsDefinitions {

class ConcatTransformation : public LayerTestsUtils::LayerTransformation<LayerTestsUtils::LayerTransformationParams> {
class ConcatTransformation :
public testing::WithParamInterface<LayerTestsUtils::LayerTransformationParams>,
public LayerTestsUtils::LayerTransformation {
public:
static std::string getTestCaseName(testing::TestParamInfo<LayerTestsUtils::LayerTransformationParams> obj);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ typedef std::tuple<
// multichannel
bool> ConcatWithIntermediateTransformationParams;

class ConcatWithIntermediateTransformation : public LayerTestsUtils::LayerTransformation<ConcatWithIntermediateTransformationParams> {
class ConcatWithIntermediateTransformation :
public testing::WithParamInterface<ConcatWithIntermediateTransformationParams>,
public LayerTestsUtils::LayerTransformation {
public:
static std::string getTestCaseName(testing::TestParamInfo<ConcatWithIntermediateTransformationParams> obj);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (C) 2019 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include <string>
#include <memory>

#include "functional_test_utils/low_precision_transformations/layer_transformation.hpp"

namespace LayerTestsDefinitions {

typedef std::tuple<
InferenceEngine::Precision,
InferenceEngine::SizeVector,
std::string,
InferenceEngine::details::LayerTransformation::Params,
bool, // fqOnActivations
bool // fqOnWeights
> ConvolutionTransformationParams;

class ConvolutionTransformation :
public testing::WithParamInterface<ConvolutionTransformationParams>,
public LayerTestsUtils::LayerTransformation {
public:
static std::string getTestCaseName(testing::TestParamInfo<ConvolutionTransformationParams> obj);

protected:
void SetUp() override;

private:
void validate();
};

} // namespace LayerTestsDefinitions
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ void ConcatNeighboringGraphTransformation::validate() {
const InferenceEngine::CNNLayerPtr outputLayer = it.second->getCreatorLayer().lock();
EXPECT_TRUE(outputLayer != nullptr);
EXPECT_EQ("ScaleShift", outputLayer->type);

checkParentPrecision(outputLayer, params.updatePrecisions);
}

// check quantized FQ layers map: should includes all FQ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ void ConcatTransformation::validate() {
EXPECT_TRUE(outputLayer != nullptr);
EXPECT_EQ("ScaleShift", outputLayer->type);

checkParentPrecision(outputLayer, params.updatePrecisions);

IE_SUPPRESS_DEPRECATED_END
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ void ConcatWithIntermediateTransformation::validate() {
children = CNNNetworkHelper::getChildren(*concat);
EXPECT_EQ(1ul, children.size());
EXPECT_EQ("ScaleShift", children[0]->type);

checkParentPrecision(children[0], params.updatePrecisions);
} else {
std::vector<CNNLayerPtr> children = CNNNetworkHelper::getChildren(*intermediate);
EXPECT_EQ(2ul, children.size());
Expand Down
Loading

0 comments on commit 61674c1

Please sign in to comment.