Class MkldnnQuantizerConfig¶
Defined in File paddle_mkldnn_quantizer_config.h
Class Documentation¶
-
class
paddle
::
MkldnnQuantizerConfig
¶ Config for mkldnn quantize.
The MkldnnQuantizerConfig is used to configure Mkldnn’s quantization parameters, including scale algorithm, warmup data, warmup batch size, quantized op list, etc.
It is not recommended to use this config directly, please refer to AnalysisConfig::mkldnn_quantizer_config()
Public Functions
-
MkldnnQuantizerConfig
()¶ Construct a new Mkldnn Quantizer Config object.
-
void
SetScaleAlgo
(std::string op_type_name, std::string conn_name, ScaleAlgo algo)¶ Set the scale algo.
Specify a quantization algorithm for a connection (input/output) of the operator type.
- Parameters
[in] op_type_name
: the operator’s name.[in] conn_name
: name of the connection (input/output) of the operator.[in] algo
: the algorithm for computing scale.
-
ScaleAlgo
scale_algo
(const std::string &op_type_name, const std::string &conn_name) const¶ Get the scale algo.
Get the quantization algorithm for a connection (input/output) of the operator type.
- Return
the scale algo.
- Parameters
[in] op_type_name
: the operator’s name.[in] conn_name
: name of the connection (input/output) of the operator.
Set the warmup data.
Set the batch of data to be used for warm-up iteration.
- Parameters
[in] data
: batch of data.
-
std::shared_ptr<std::vector<PaddleTensor>>
warmup_data
() const¶ Get the warmup data.
Get the batch of data used for warm-up iteration.
- Return
the warm up data
-
void
SetWarmupBatchSize
(int batch_size)¶ Set the warmup batch size.
Set the batch size for warm-up iteration.
- Parameters
[in] batch_size
: warm-up batch size
-
int
warmup_batch_size
() const¶ Get the warmup batch size.
Get the batch size for warm-up iteration.
- Return
the warm up batch size
-
void
SetEnabledOpTypes
(std::unordered_set<std::string> op_list)¶ Set quantized op list.
In the quantization process, set the op list that supports quantization
- Parameters
[in] op_list
: List of quantized ops
-
const std::unordered_set<std::string> &
enabled_op_types
() const¶ Get quantized op list.
- Return
list of quantized ops
-
void
SetExcludedOpIds
(std::unordered_set<int> op_ids_list)¶ Set the excluded op ids.
- Parameters
[in] op_ids_list
: excluded op ids
-
const std::unordered_set<int> &
excluded_op_ids
() const¶ Get the excluded op ids.
- Return
exclude op ids
Protected Attributes
-
std::unordered_set<std::string>
enabled_op_types_
¶
-
std::unordered_set<int>
excluded_op_ids_
¶
-
std::shared_ptr<std::vector<PaddleTensor>>
warmup_data_
¶
-
int
warmup_bs_
= {1}¶
-