neural_compressor.utils.utility
quantization auto-tuning config system.
This file specifies default config options for quantization auto-tuning tool. User should not change values in this file. Instead, user should write a config file (in yaml) and use cfg_from_file(yaml_file) to load it and override the default options.
Module Contents
Classes
Lazy import python module till use. |
|
Get CPU Info. |
|
Not displayed in API Docs. |
|
The statistics printer. |
|
Mode: Quantization, Benchmark or Pruning. |
|
Access the global model. |
Functions
|
Check whether version1 is less than version2. |
|
Check whether version1 is greater than version2. |
|
Check whether version1 is equal to version2. |
|
Check whether version1 is greater than version2 or is equal to it. |
|
Check whether version1 is less than version2 or is equal to it. |
|
Not displayed in API Docs. |
|
Limit the time for context execution. |
|
Recursively finds size of objects. |
|
Compute the sparsity. |
|
Make another temporary copy of the file. |
|
Check whether two dicts are same except for those ignored keys. |
|
Get the elapsed time for decorated functions. |
|
Collect layer histogram for arr and combine it with old histogram. |
|
Get the histogram of the tensor data. |
|
Get all the fp32 data. |
|
Get tuning history. |
|
Get offline recover tuned model. |
|
Get the array of the string. |
|
Dequantize the weight with min-max filter tensors. |
|
Dequantize the data with the scale_info. |
|
Load data from local pkl file. |
|
Dump data to local as pkl file. |
|
Set the random seed in config. |
|
Set the workspace in config. |
|
Set the resume_from in config. |
|
Set the tensorboard in config. |
|
Show process full memory. |
- neural_compressor.utils.utility.version1_lt_version2(version1, version2)[source]
Check whether version1 is less than version2.
- neural_compressor.utils.utility.version1_gt_version2(version1, version2)[source]
Check whether version1 is greater than version2.
- neural_compressor.utils.utility.version1_eq_version2(version1, version2)[source]
Check whether version1 is equal to version2.
- neural_compressor.utils.utility.version1_gte_version2(version1, version2)[source]
Check whether version1 is greater than version2 or is equal to it.
- neural_compressor.utils.utility.version1_lte_version2(version1, version2)[source]
Check whether version1 is less than version2 or is equal to it.
- class neural_compressor.utils.utility.LazyImport(module_name)[source]
Lazy import python module till use.
- neural_compressor.utils.utility.singleton(cls)[source]
Not displayed in API Docs.
Singleton decorater.
- neural_compressor.utils.utility.get_size(obj, seen=None)[source]
Recursively finds size of objects.
- neural_compressor.utils.utility.compute_sparsity(tensor)[source]
Compute the sparsity.
- Parameters:
tensor – Tensorflow or Pytorch tensor
- Returns:
(the original tensor size, number of zero elements, number of non-zero elements)
- neural_compressor.utils.utility.fault_tolerant_file(name)[source]
Make another temporary copy of the file.
- neural_compressor.utils.utility.equal_dicts(d1, d2, compare_keys=None, ignore_keys=None)[source]
Check whether two dicts are same except for those ignored keys.
- neural_compressor.utils.utility.dump_elapsed_time(customized_msg='')[source]
Get the elapsed time for decorated functions.
- Parameters:
customized_msg (string, optional) – The parameter passed to decorator. Defaults to None.
- neural_compressor.utils.utility.combine_histogram(old_hist, arr)[source]
Collect layer histogram for arr and combine it with old histogram.
- neural_compressor.utils.utility.get_tensor_histogram(tensor_data, bins=2048)[source]
Get the histogram of the tensor data.
- neural_compressor.utils.utility.get_tuning_history(tuning_history_path)[source]
Get tuning history.
- Parameters:
tuning_history_path – The tuning history path, which need users to assign
- neural_compressor.utils.utility.recover(fp32_model, tuning_history_path, num, **kwargs)[source]
Get offline recover tuned model.
- Parameters:
fp32_model – Input model path
tuning_history_path – The tuning history path, which needs user to assign
num – tune index
- neural_compressor.utils.utility.DequantizeWeight(weight_tensor, min_filter_tensor, max_filter_tensor)[source]
Dequantize the weight with min-max filter tensors.
- neural_compressor.utils.utility.Dequantize(data, scale_info)[source]
Dequantize the data with the scale_info.
- class neural_compressor.utils.utility.CaptureOutputToFile(tmp_file_path, stream=sys.stderr)[source]
Not displayed in API Docs.
Capture the output to file.
- class neural_compressor.utils.utility.Statistics(data, header, field_names, output_handle=logger.info)[source]
The statistics printer.
- neural_compressor.utils.utility.load_data_from_pkl(path, filename)[source]
Load data from local pkl file.
- Parameters:
path – The directory to load data
filename – The filename to load
- neural_compressor.utils.utility.dump_data_to_local(data, path, filename)[source]
Dump data to local as pkl file.
- Parameters:
data – Data used to dump
path – The directory to save data
filename – The filename to dump
- Returns:
loaded data
- neural_compressor.utils.utility.set_resume_from(resume_from: str)[source]
Set the resume_from in config.