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_BISECTION_SOLVER_H__
18 #define __MPQSOLVER_BISECTION_SOLVER_H__
20 #include "Quantizer.h"
21 #include "Evaluator.h"
22 #include <MPQSolver.h>
24 #include <luci/IR/Module.h>
34 class BisectionSolver final : public MPQSolver
38 * @brief Algorithm options for running bisection algorithm
49 * @brief construct Solver using input_data_path for .h5 file,
50 * qerror_ratio to set target qerror, and input_quantization/output_quantization to set
51 * quantization type at input/output respectively
53 BisectionSolver(const std::string &input_data_path, float qerror_ratio,
54 const std::string &input_quantization, const std::string &output_quantization);
55 BisectionSolver() = delete;
58 * @brief run bisection for recorded float module at module_path
60 std::unique_ptr<luci::Module> run(const std::string &module_path) override;
63 * @brief set used algorithm
65 void algorithm(Algorithm algorithm);
68 float evaluate(const DatasetEvaluator &evaluator, const std::string &module_path,
69 const std::string &def_quant, LayerParams &layers);
72 float _qerror = 0.f; // quantization error
73 Algorithm _algorithm = Algorithm::ForceQ16Front;
74 std::unique_ptr<Quantizer> _quantizer;
77 } // namespace bisection
78 } // namespace mpqsolver
80 #endif //__MPQSOLVER_BISECTION_SOLVER_H__