Examples/tensorflow/quantization/ada_round.py
def aimet_adaround(sess: tf.Session, start_op_names: List[str], output_op_names: List[str],
                   data_set: tf.data.Dataset, working_dir: str, encoding_file_prefix: str) -> tf.Session:
    """
    Applies Adaround on the model.

    :param sess: The sess with graph to be evaluated
    :param start_op_names: The list of input op names of the sess.graph
    :param output_op_names: The list of output op names of the sess.graph
    :param data_set: Input data set
    :param working_dir: Dir to save encodings
    :param encoding_file_prefix: Prefix filename for encoding file
    :return: The sess with graph after BC applied
    """

    # Num of batches to use for adarounding
    num_batches = 5

    # Parameters used for adaround
    params = AdaroundParameters(data_set=data_set, num_batches=num_batches)

    # bitwidth to use for quantizing layer parameters in adaround. Value can be from 4 to 32.
    param_bw = 8

    # Quant scheme can be 'post_training_tf' or 'post_training_tf_enhanced'
    quant_scheme = QuantScheme.post_training_tf_enhanced

    after_adarounded_sess = Adaround.apply_adaround(sess, starting_op_names=start_op_names,
                                                    output_op_names=output_op_names, params=params,
                                                    path=working_dir, filename_prefix=encoding_file_prefix,
                                                    default_param_bw=param_bw,
                                                    default_quant_scheme=quant_scheme)

    return after_adarounded_sess

    Applies Adaround on the model.

    :param sess: The sess with graph to be evaluated
    :param start_op_names: The list of input op names of the sess.graph
    :param output_op_names: The list of output op names of the sess.graph
    :param data_set: Input data set
    :param working_dir: Dir to save encodings
    :param encoding_file_prefix: Prefix filename for encoding file
    :return: The sess with graph after BC applied
    
Applies Adaround on the model.
Applies Adaround on the model .
def aimet_adaround(sess: tf.Session, start_op_names: List[str], output_op_names: List[str],
                   data_set: tf.data.Dataset, working_dir: str, encoding_file_prefix: str) -> tf.Session:
    num_batches = 5
    params = AdaroundParameters(data_set=data_set, num_batches=num_batches)
    param_bw = 8
    quant_scheme = QuantScheme.post_training_tf_enhanced
    after_adarounded_sess = Adaround.apply_adaround(sess, starting_op_names=start_op_names,
                                                    output_op_names=output_op_names, params=params,
                                                    path=working_dir, filename_prefix=encoding_file_prefix,
                                                    default_param_bw=param_bw,
                                                    default_quant_scheme=quant_scheme)
    return after_adarounded_sess
def aimet_adaround ( sess : tf . Session , start_op_names : List [ str ] , output_op_names : List [ str ] , data_set : tf . data . Dataset , working_dir : str , encoding_file_prefix : str ) -> tf . Session : num_batches = 5 params = AdaroundParameters ( data_set = data_set , num_batches = num_batches ) param_bw = 8 quant_scheme = QuantScheme . post_training_tf_enhanced after_adarounded_sess = Adaround . apply_adaround ( sess , starting_op_names = start_op_names , output_op_names = output_op_names , params = params , path = working_dir , filename_prefix = encoding_file_prefix , default_param_bw = param_bw , default_quant_scheme = quant_scheme ) return after_adarounded_sess
Applies Adaround on the model.
Applies Adaround on the model .
"""
    Applies Adaround on the model.

    :param sess: The sess with graph to be evaluated
    :param start_op_names: The list of input op names of the sess.graph
    :param output_op_names: The list of output op names of the sess.graph
    :param data_set: Input data set
    :param working_dir: Dir to save encodings
    :param encoding_file_prefix: Prefix filename for encoding file
    :return: The sess with graph after BC applied
    """ # Num of batches to use for adarounding # Parameters used for adaround # bitwidth to use for quantizing layer parameters in adaround. Value can be from 4 to 32. # Quant scheme can be 'post_training_tf' or 'post_training_tf_enhanced'
The sess with graph after BC applied
The sess with graph after BC applied
sess
tf.Session
The sess with graph to be evaluated
The sess with graph to be evaluated
start_op_names
List[str]
The list of input op names of the sess.graph
The list of input op names of the sess . graph
output_op_names
List[str]
The list of output op names of the sess.graph
The list of output op names of the sess . graph
data_set
tf.data.Dataset
Input data set
Input data set
working_dir
str
Dir to save encodings
Dir to save encodings
encoding_file_prefix
str
Prefix filename for encoding file
Prefix filename for encoding file