neural_compressor.utils

Utils: provide useful methods and auxiliary functionalities.

Submodules

Package Contents

Classes

LayerHistogramCollector

The collector of the histogram by layer.

Functions

log(level, msg, *args, **kwargs)

Output log with the level as a parameter.

info(msg, *args, **kwargs)

Output log with the info level.

debug(msg, *args, **kwargs)

Output log with the debug level.

warn(msg, *args, **kwargs)

Output log with the warning level.

warning(msg, *args, **kwargs)

Output log with the warining level (Alias of the method warn).

error(msg, *args, **kwargs)

Output log with the error level.

fatal(msg, *args, **kwargs)

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.