:orphan: :py:mod:`neural_compressor.tensorflow.utils.utility` ==================================================== .. py:module:: neural_compressor.tensorflow.utils.utility Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: neural_compressor.tensorflow.utils.utility.CpuInfo neural_compressor.tensorflow.utils.utility.Statistics neural_compressor.tensorflow.utils.utility.CaptureOutputToFile neural_compressor.tensorflow.utils.utility.LazyImport Functions ~~~~~~~~~ .. autoapisummary:: neural_compressor.tensorflow.utils.utility.version1_lt_version2 neural_compressor.tensorflow.utils.utility.version1_gt_version2 neural_compressor.tensorflow.utils.utility.version1_eq_version2 neural_compressor.tensorflow.utils.utility.version1_gte_version2 neural_compressor.tensorflow.utils.utility.version1_lte_version2 neural_compressor.tensorflow.utils.utility.register_algo neural_compressor.tensorflow.utils.utility.deep_get neural_compressor.tensorflow.utils.utility.itex_installed neural_compressor.tensorflow.utils.utility.dump_elapsed_time neural_compressor.tensorflow.utils.utility.combine_histogram neural_compressor.tensorflow.utils.utility.get_all_fp32_data neural_compressor.tensorflow.utils.utility.get_tensor_histogram neural_compressor.tensorflow.utils.utility.Dequantize neural_compressor.tensorflow.utils.utility.dequantize_weight neural_compressor.tensorflow.utils.utility.dump_data_to_local neural_compressor.tensorflow.utils.utility.load_data_from_pkl neural_compressor.tensorflow.utils.utility.singleton neural_compressor.tensorflow.utils.utility.disable_random neural_compressor.tensorflow.utils.utility.valid_keras_format .. py:function:: version1_lt_version2(version1, version2) Check whether version1 is less than version2. .. py:function:: version1_gt_version2(version1, version2) Check whether version1 is greater than version2. .. py:function:: version1_eq_version2(version1, version2) Check whether version1 is equal to version2. .. py:function:: version1_gte_version2(version1, version2) Check whether version1 is greater than version2 or is equal to it. .. py:function:: version1_lte_version2(version1, version2) Check whether version1 is less than version2 or is equal to it. .. py:function:: register_algo(name) 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: ... :param name: The name under which the algorithm function will be registered. :type name: str :returns: The decorator function to be used with algorithm functions. :rtype: decorator .. py:function:: deep_get(dictionary, keys, default=None) Get the dot key's item in nested dict eg person = {'person':{'name':{'first':'John'}}} deep_get(person, "person.name.first") will output 'John'. :param dictionary: The dict object to get keys :type dictionary: dict :param keys: The deep keys :type keys: dict :param default: The return item if key not exists :type default: object :returns: the item of the deep dot keys :rtype: item .. py:function:: itex_installed() Check if the IntelĀ® Extension for TensorFlow has been installed. .. py:function:: dump_elapsed_time(customized_msg='') Get the elapsed time for decorated functions. :param customized_msg: The parameter passed to decorator. Defaults to None. :type customized_msg: string, optional .. py:function:: combine_histogram(old_hist, arr) Collect layer histogram for arr and combine it with old histogram. .. py:function:: get_all_fp32_data(data) Get all the fp32 data. .. py:function:: get_tensor_histogram(tensor_data, bins=2048) Get the histogram of the tensor data. .. py:function:: Dequantize(data, scale_info) Dequantize the data with the scale_info. .. py:function:: dequantize_weight(weight_tensor, min_filter_tensor, max_filter_tensor) Dequantize the weight with min-max filter tensors. .. py:function:: dump_data_to_local(data, path, filename) Dump data to local as pkl file. :param data: Data used to dump :param path: The directory to save data :param filename: The filename to dump :returns: loaded data .. py:function:: load_data_from_pkl(path, filename) Load data from local pkl file. :param path: The directory to load data :param filename: The filename to load .. py:function:: singleton(cls) Not displayed in API Docs. Singleton decorator. .. py:function:: disable_random(seed=1) A Decorator to disable tf random seed. .. py:function:: valid_keras_format(model) Check if the input model is Sequential or Functional model. .. py:class:: CpuInfo Get CPU Info. .. py:class:: Statistics(data, header, field_names, output_handle=logger.info) The statistics printer. .. py:class:: CaptureOutputToFile(tmp_file_path, stream=sys.stderr) Not displayed in API Docs. Capture the output to file. .. py:class:: LazyImport(module_name) Lazy import python module till use.