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,
50 enum AlgorithmParameters
53 Quantize_input_model_dtype,
54 Quantize_output_model_dtype,
55 Quantize_granularity, // layer-wise or channel-wise
56 Quantize_tensor_names,
59 Quantize_layer_params,
62 Quantize_src_tensor_names,
63 Quantize_dst_tensor_names,
67 Quantize_TF_style_maxpool,
70 virtual ~Options() = default;
72 virtual void enable(Algorithm) = 0;
73 virtual bool query(Algorithm) = 0;
74 virtual void param(AlgorithmParameters, const std::string &) = 0;
75 virtual const std::string param(AlgorithmParameters) const = 0;
76 virtual void params(AlgorithmParameters, std::vector<std::string> &) = 0;
77 virtual std::vector<std::string> params(AlgorithmParameters) const = 0;
79 // Quantization parameters for multiple layers
80 virtual void layer_params(AlgorithmParameters, std::vector<std::shared_ptr<LayerParam>> &) = 0;
81 virtual std::vector<std::shared_ptr<LayerParam>> layer_params(AlgorithmParameters) const = 0;
85 // TODO maybe caller can provide Options as ctor parameters
86 Options *options(void);
89 void quantize(loco::Graph *) const;
92 std::unique_ptr<Options> _options;
97 #endif // __LUCI_CIRCLE_QUANTIZER_H__