ec9c0d6b752c16e90d7b61c60e188da9f1ba487c
[platform/upstream/dldt.git] /
1 // Copyright (C) 2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #include <string>
8 #include <tuple>
9
10 #include "ie_util_internal.hpp"
11 #include "low_precision_transformations/network_helper.hpp"
12 #include "low_precision_transformations/convolution.hpp"
13 #include "low_precision_transformations/scaleshift_to_convolution.hpp"
14 #include "functional_test_utils/layer_test_utils.hpp"
15 #include "low_precision_transformations/transformer.hpp"
16
17 namespace LayerTestsUtils {
18
19 typedef std::tuple<
20     InferenceEngine::Precision,
21     InferenceEngine::SizeVector,
22     std::string,
23     InferenceEngine::details::LayerTransformation::Params> LayerTransformationParams;
24
25 class LayerTransformationParamsFactory {
26 public:
27     static InferenceEngine::details::LayerTransformation::Params createParamsU8I8();
28     static InferenceEngine::details::LayerTransformation::Params createParamsU8U8();
29     static InferenceEngine::details::LayerTransformation::Params createParamsI8I8();
30     static InferenceEngine::details::LayerTransformation::Params createParams();
31 };
32
33 IE_SUPPRESS_DEPRECATED_START
34
35 class LayerTransformation : public LayerTestsUtils::LayerTestsCommon {
36 protected:
37     LayerTransformation();
38
39     static InferenceEngine::Blob::Ptr GenerateInput(
40         const InferenceEngine::Precision precision,
41         const InferenceEngine::TensorDesc& tensorDesc,
42         const float k = 1.f);
43
44     LayerTransformation();
45
46     InferenceEngine::details::LowPrecisionTransformations getLowPrecisionTransformations(
47         const InferenceEngine::details::LayerTransformation::Params& params) const;
48
49     InferenceEngine::details::LowPrecisionTransformer getLowPrecisionTransformer(
50         const InferenceEngine::details::LayerTransformation::Params& params) const;
51
52     InferenceEngine::CNNNetwork transform(InferenceEngine::details::LayerTransformation::Params& params);
53
54     InferenceEngine::CNNNetwork transform(const InferenceEngine::details::LowPrecisionTransformations& transformations);
55
56     static void checkPrecisions(const InferenceEngine::CNNLayer& layer, const InferenceEngine::Precision& expectedPrecision);
57
58     static void checkPrecisions(
59         const InferenceEngine::CNNLayer& layer,
60         const std::vector<std::vector<InferenceEngine::Precision>>& expectedInputPrecisions,
61         const std::vector<InferenceEngine::Precision>& expectedOutputPrecisions,
62         const bool asymmetricQuantizationOnData = false,
63         const bool asymmetricQuantizationOnWeights = false);
64
65     static std::pair<float, float> getQuantizationInterval(const InferenceEngine::Precision precision);
66
67     static std::string toString(const InferenceEngine::details::LayerTransformation::Params& params);
68
69     static InferenceEngine::Precision getDeviceInternalPrecision(const InferenceEngine::Precision precision);
70 };
71
72 IE_SUPPRESS_DEPRECATED_END
73
74 }  // namespace LayerTestsUtils