neural_compressor.strategy.utils.utility

Tuning utility.

Classes

QuantType

Quantization type.

QuantOptions

Option Class for Quantization.

OrderedDefaultDict

Ordered default dict.

ClassRegister

Class register.

Functions

preprocess_user_cfg(op_user_cfg)

Preprocess the op user config for weight only.

extract_data_type(→ str)

Extract data type and signed from data type.

reverted_data_type(→ str)

Revert the data type.

get_adaptor_name(adaptor)

Get adaptor name.

build_slave_faker_model()

Slave does not have a model, so construct a fake model.

Module Contents

class neural_compressor.strategy.utils.utility.QuantType[source]

Quantization type.

class neural_compressor.strategy.utils.utility.QuantOptions(quant_type=1)[source]

Option Class for Quantization.

This class is used for configuring global variable related to quantization. The global variable quant_options is created with this class.

Parameters:

quant_type (int) – Quantization type. Default value is 1.

neural_compressor.strategy.utils.utility.preprocess_user_cfg(op_user_cfg: Dict)[source]

Preprocess the op user config for weight only.

Parameters:

op_user_cfg – The original user config.

Example

op_user_cfg = {‘activation’: {‘bits’: [4]}} op_user_cfg_modified = {‘activation’: {‘bits’: [4], ‘group_size’: [32]}}

Returns:

The modified config.

class neural_compressor.strategy.utils.utility.OrderedDefaultDict[source]

Ordered default dict.

neural_compressor.strategy.utils.utility.extract_data_type(data_type: str) str[source]

Extract data type and signed from data type.

Parameters:

data_type – The original data type such as uint8, int8.

Returns:

(signed or unsigned, data type without signed)

neural_compressor.strategy.utils.utility.reverted_data_type(signed_flag: str, data_type: str) str[source]

Revert the data type.

neural_compressor.strategy.utils.utility.get_adaptor_name(adaptor)[source]

Get adaptor name.

Parameters:

adaptor – adaptor instance.

neural_compressor.strategy.utils.utility.build_slave_faker_model()[source]

Slave does not have a model, so construct a fake model.

Returns:

a class object where all properties and methods are virtual.

Return type:

object

class neural_compressor.strategy.utils.utility.ClassRegister[source]

Class register.