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 __MPQSOLVER_CORE_QUANTIZER_H__
18 #define __MPQSOLVER_CORE_QUANTIZER_H__
20 #include <luci/IR/Module.h>
21 #include <luci/CircleQuantizer.h>
32 using LayerParam = luci::CircleQuantizer::Options::LayerParam;
33 using LayerParams = std::vector<std::shared_ptr<LayerParam>>;
38 * @brief called on successfull quantization
39 * @param module quantized module
41 virtual void on_quantized(luci::Module *module) const = 0;
47 Quantizer(const std::string &input_dtype, const std::string &output_type);
50 * @brief set hook on the end of quantization event
52 void set_hook(const QuantizerHook *callback);
55 * @brief quantize recorded module (min/max initialized) with specified parameters
56 * returns true on success
58 bool quantize(luci::Module *module, const std::string &quant_dtype, LayerParams &layer_params);
61 * @brief fake_quantize recorded module (min/max initialized) with specified parameters
62 * returns true on success
64 bool fake_quantize(luci::Module *module, const std::string &quant_dtype,
65 LayerParams &layer_params);
68 std::string _input_dtype = "uint8";
69 std::string _output_dtype = "uint8";
70 const QuantizerHook *_hook = nullptr;
74 } // namespace mpqsolver
76 #endif //__MPQSOLVER_CORE_QUANTIZER_H__