2 * Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __LUCI_CIRCLE_QUANTIZER_H__
18 #define __LUCI_CIRCLE_QUANTIZER_H__
28 class CircleQuantizer final
37 std::string granularity;
42 QuantizeDequantizeWeights,
47 ConvertToFakeQuantizedModel,
51 enum AlgorithmParameters
54 Quantize_input_model_dtype,
55 Quantize_output_model_dtype,
56 Quantize_granularity, // layer-wise or channel-wise
57 Quantize_tensor_names,
60 Quantize_layer_params,
63 Quantize_src_tensor_names,
64 Quantize_dst_tensor_names,
68 Quantize_TF_style_maxpool,
71 virtual ~Options() = default;
73 virtual void enable(Algorithm) = 0;
74 virtual bool query(Algorithm) = 0;
75 virtual void param(AlgorithmParameters, const std::string &) = 0;
76 virtual const std::string param(AlgorithmParameters) const = 0;
77 virtual void params(AlgorithmParameters, std::vector<std::string> &) = 0;
78 virtual std::vector<std::string> params(AlgorithmParameters) const = 0;
80 // Quantization parameters for multiple layers
81 virtual void layer_params(AlgorithmParameters, std::vector<std::shared_ptr<LayerParam>> &) = 0;
82 virtual std::vector<std::shared_ptr<LayerParam>> layer_params(AlgorithmParameters) const = 0;
86 // TODO maybe caller can provide Options as ctor parameters
87 Options *options(void);
90 void quantize(loco::Graph *) const;
93 std::unique_ptr<Options> _options;
98 #endif // __LUCI_CIRCLE_QUANTIZER_H__