neural_compressor.utils
¶
Utils: provide useful methods and auxiliary functionalities.
Submodules¶
neural_compressor.utils.collect_layer_histogram
neural_compressor.utils.constant
neural_compressor.utils.create_obj_from_config
neural_compressor.utils.kl_divergence
neural_compressor.utils.load_huggingface
neural_compressor.utils.logger
neural_compressor.utils.options
neural_compressor.utils.pytorch
neural_compressor.utils.utility
Package Contents¶
Classes¶
The collector of the histogram by layer. |
Functions¶
|
Output log with the level as a parameter. |
|
Output log with the info level. |
|
Output log with the debug level. |
|
Output log with the warning level. |
|
Output log with the warining level (Alias of the method warn). |
|
Output log with the error level. |
|
Output log with the fatal level. |
- class neural_compressor.utils.LayerHistogramCollector(num_bins=8001, layer_tensor=None, include_layer=None, logger=None)¶
Bases:
object
The collector of the histogram by layer.
Saves layer histogram in a dict with layer names as keys and lists of NDArrays as values. The collected histogram will be used for calculating the optimal thresholds for quantization using KL divergence.
- collect()¶
Collect layer output NDArrays as a callback function.
- neural_compressor.utils.log(level, msg, *args, **kwargs)¶
Output log with the level as a parameter.
- neural_compressor.utils.info(msg, *args, **kwargs)¶
Output log with the info level.
- neural_compressor.utils.debug(msg, *args, **kwargs)¶
Output log with the debug level.
- neural_compressor.utils.warn(msg, *args, **kwargs)¶
Output log with the warning level.
- neural_compressor.utils.warning(msg, *args, **kwargs)¶
Output log with the warining level (Alias of the method warn).
- neural_compressor.utils.error(msg, *args, **kwargs)¶
Output log with the error level.
- neural_compressor.utils.fatal(msg, *args, **kwargs)¶
Output log with the fatal level.