TrainingExtensions/tensorflow/src/python/aimet_tensorflow/quantsim.py
def _remove_quantization_nodes_and_save_graph(self, path: str, filename_prefix: str):
        """
        This function removes the quantization nodes from quantized graph and saves it
        :param path: path where to store model pth and encodings
        :param filename_prefix: Prefix to use for filenames of the model pth and encodings files
        """
        vars_to_save = []
        with self.session.graph.as_default():
            for var in tf.compat.v1.global_variables():
                if not var.name[:-2].endswith(('_quantized', '_quantized_op_mode', '_quantized_quant_ref',
                                               '_quantized_encoding_min', '_quantized_encoding_max',
                                               '_quantized_bit_width', '_quantized_use_symmetric_encoding')):
                    vars_to_save.append(var)

            saver = tf.compat.v1.train.Saver(vars_to_save)
            saver.save(self.session, save_path=os.path.join(path, filename_prefix))
            shutil.copyfile(WORKING_DIR + 'orig_model_before_quantsim.meta',
                            os.path.join(path, filename_prefix) + '.meta')

        This function removes the quantization nodes from quantized graph and saves it
        :param path: path where to store model pth and encodings
        :param filename_prefix: Prefix to use for filenames of the model pth and encodings files
        
This function removes the quantization nodes from quantized graph and saves it
This function removes the quantization nodes from quantized graph and saves it
def _remove_quantization_nodes_and_save_graph(self, path: str, filename_prefix: str):
        vars_to_save = []
        with self.session.graph.as_default():
            for var in tf.compat.v1.global_variables():
                if not var.name[:-2].endswith(('_quantized', '_quantized_op_mode', '_quantized_quant_ref',
                                               '_quantized_encoding_min', '_quantized_encoding_max',
                                               '_quantized_bit_width', '_quantized_use_symmetric_encoding')):
                    vars_to_save.append(var)
            saver = tf.compat.v1.train.Saver(vars_to_save)
            saver.save(self.session, save_path=os.path.join(path, filename_prefix))
            shutil.copyfile(WORKING_DIR + 'orig_model_before_quantsim.meta',
                            os.path.join(path, filename_prefix) + '.meta')
def _remove_quantization_nodes_and_save_graph ( self , path : str , filename_prefix : str ) : vars_to_save = [ ] with self . session . graph . as_default ( ) : for var in tf . compat . v1 . global_variables ( ) : if not var . name [ : - 2 ] . endswith ( ( '_quantized' , '_quantized_op_mode' , '_quantized_quant_ref' , '_quantized_encoding_min' , '_quantized_encoding_max' , '_quantized_bit_width' , '_quantized_use_symmetric_encoding' ) ) : vars_to_save . append ( var ) saver = tf . compat . v1 . train . Saver ( vars_to_save ) saver . save ( self . session , save_path = os . path . join ( path , filename_prefix ) ) shutil . copyfile ( WORKING_DIR + 'orig_model_before_quantsim.meta' , os . path . join ( path , filename_prefix ) + '.meta' )
This function removes the quantization nodes from quantized graph and saves it
This function removes the quantization nodes from quantized graph and saves it
"""
        This function removes the quantization nodes from quantized graph and saves it
        :param path: path where to store model pth and encodings
        :param filename_prefix: Prefix to use for filenames of the model pth and encodings files
        """
self
path
str
path where to store model pth and encodings
path where to store model pth and encodings
filename_prefix
str
Prefix to use for filenames of the model pth and encodings files
Prefix to use for filenames of the model pth and encodings files