neural_compressor.tensorflow.utils.utility
Module Contents
Classes
Get CPU Info. |
|
The statistics printer. |
|
Not displayed in API Docs. |
|
Lazy import python module till use. |
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. |
|
Decorator function to register algorithms in the algos_mapping dictionary. |
|
Get the dot key's item in nested dict |
Check if the Intel® Extension for TensorFlow has been installed. |
|
|
Get the elapsed time for decorated functions. |
|
Collect layer histogram for arr and combine it with old histogram. |
|
Get all the fp32 data. |
|
Get the histogram of the tensor data. |
|
Dequantize the data with the scale_info. |
|
Dequantize the weight with min-max filter tensors. |
|
Dump data to local as pkl file. |
|
Load data from local pkl file. |
|
Not displayed in API Docs. |
|
A Decorator to disable tf random seed. |
|
Check if the input model is Sequential or Functional model. |
- neural_compressor.tensorflow.utils.utility.version1_lt_version2(version1, version2)[source]
Check whether version1 is less than version2.
- neural_compressor.tensorflow.utils.utility.version1_gt_version2(version1, version2)[source]
Check whether version1 is greater than version2.
- neural_compressor.tensorflow.utils.utility.version1_eq_version2(version1, version2)[source]
Check whether version1 is equal to version2.
- neural_compressor.tensorflow.utils.utility.version1_gte_version2(version1, version2)[source]
Check whether version1 is greater than version2 or is equal to it.
- neural_compressor.tensorflow.utils.utility.version1_lte_version2(version1, version2)[source]
Check whether version1 is less than version2 or is equal to it.
- neural_compressor.tensorflow.utils.utility.register_algo(name)[source]
Decorator function to register algorithms in the algos_mapping dictionary.
- Usage example:
@register_algo(name=example_algo) def example_algo(model: tf.keras.Model, quant_config: StaticQuantConfig) -> tf.keras.Model:
…
- Parameters:
name (str) – The name under which the algorithm function will be registered.
- Returns:
The decorator function to be used with algorithm functions.
- Return type:
decorator
- neural_compressor.tensorflow.utils.utility.deep_get(dictionary, keys, default=None)[source]
- Get the dot key’s item in nested dict
eg person = {‘person’:{‘name’:{‘first’:’John’}}} deep_get(person, “person.name.first”) will output ‘John’.
- Parameters:
dictionary (dict) – The dict object to get keys
keys (dict) – The deep keys
default (object) – The return item if key not exists
- Returns:
the item of the deep dot keys
- Return type:
item
- neural_compressor.tensorflow.utils.utility.itex_installed()[source]
Check if the Intel® Extension for TensorFlow has been installed.
- neural_compressor.tensorflow.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.tensorflow.utils.utility.combine_histogram(old_hist, arr)[source]
Collect layer histogram for arr and combine it with old histogram.
- neural_compressor.tensorflow.utils.utility.get_tensor_histogram(tensor_data, bins=2048)[source]
Get the histogram of the tensor data.
- neural_compressor.tensorflow.utils.utility.Dequantize(data, scale_info)[source]
Dequantize the data with the scale_info.
- neural_compressor.tensorflow.utils.utility.dequantize_weight(weight_tensor, min_filter_tensor, max_filter_tensor)[source]
Dequantize the weight with min-max filter tensors.
- neural_compressor.tensorflow.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.tensorflow.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.tensorflow.utils.utility.singleton(cls)[source]
Not displayed in API Docs.
Singleton decorator.
- neural_compressor.tensorflow.utils.utility.disable_random(seed=1)[source]
A Decorator to disable tf random seed.
- neural_compressor.tensorflow.utils.utility.valid_keras_format(model)[source]
Check if the input model is Sequential or Functional model.
- class neural_compressor.tensorflow.utils.utility.Statistics(data, header, field_names, output_handle=logger.info)[source]
The statistics printer.