neural_compressor.tensorflow.utils.utility
The utility functions and classes for Tensorflow.
Classes
Get CPU Info. |
|
Not displayed in API Docs. |
|
TF-Slim nets factory. |
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. |
|
Not displayed in API Docs. |
|
A Decorator to disable tf random seed. |
|
Check if the input model is Sequential or Functional model. |
Module Contents
- 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.
- Usage example:
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.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.