fq_decomposition.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include <transformations_visibility.hpp>
8 #include <ngraph/pass/graph_rewrite.hpp>
9 
10 namespace ngraph {
11 namespace pass {
12 
13 class TRANSFORMATIONS_API FakeQuantizeDecomposition;
14 
15 } // namespace pass
16 } // namespace ngraph
17 
18 /**
19  * @ingroup ie_transformation_common_api
20  * @brief FakeQuantizeDecomposition transformation decomposes FakeQuantize layer.
21  *
22  * Expression from specification:
23  * if x <= min(input_low, input_high):
24  * output = output_low
25  * elif x > max(input_low, input_high):
26  * output = output_high
27  * else:
28  * output = round((x - input_low) / (input_high - input_low) * (levels-1)) / (levels-1) * (output_high - output_low) + output_low
29  *
30  * expand brackets into round:
31  * round(x * (levels-1) / (input_high - input_low) - input_low * (levels-1) / (input_high - input_low))
32  * div on (levels-1) and mult on (output_high - output_low) => mult on (output_high - output_low) / (levels-1)
33  *
34  * =>
35  * round(x * (levels-1) / (input_high - input_low) - input_low * (levels-1) / (input_high - input_low)) * (output_high - output_low) / (levels-1) + output_low
36  *
37  * This transformation doesn't support following cases:
38  * 1. At least one 'range' input is not Constant
39  * 2. At least one 'input_low' input value greater or equal than 'input_high' input value
40  *
41  */
42 
43 class ngraph::pass::FakeQuantizeDecomposition: public ngraph::pass::MatcherPass {
44 public:
45  NGRAPH_RTTI_DECLARATION;
47 };
FakeQuantizeDecomposition transformation decomposes FakeQuantize layer.
Definition: fq_decomposition.hpp:43
ngraph namespace
Definition: add_fake_quantize_fusion.hpp:14