nncf/experimental/torch/nas/bootstrapNAS/elasticity/elastic_width.py
def _generate_width_list(max_width: int, params: ElasticWidthParams) -> List[int]:
        """
        Generates list of available width values.
        There are two mutually exclusive modes: using `width_step` and using `width_multipliers`.
        The mode with `width_step` defines a step size for a generation of the elastic width search space - the list of
        all possible width values for each layer. The generation starts from the number of output channels in the
        original model and stops when it reaches whether a `min_width` width value or number of generated width values
        equal to `max_num_widths`.
        The mode with `width_multipliers` defines elastic width search space via a list of multipliers. All possible
        width values are obtained by multiplying the original width value with the values in the given list.
        The obtained values are rounded to the nearest smaller value divisible by alignment constant (e.g. 8).

        :param max_width: maximum value of width
        :param params: parameters to configure elastic width for the operation.
        :return: list of available width values.
        """
        ALIGNMENT_CONSTANT_FOR_MULTIPLIERS = 8
        width_list = []
        p = params
        if max_width <= p.min_width:
            width_list.append(max_width)
        elif not p.width_multipliers:
            width = max_width
            width_list.append(width)
            width -= p.width_step
            while width >= p.min_width:
                if p.max_num_widths == len(width_list):
                    break
                width_list.append(width)
                width -= p.width_step
        else:
            p.width_multipliers.sort(reverse=True)
            if p.width_multipliers[0] < 1:
                width_list.append(max_width)
            for multiplier in p.width_multipliers:
                if p.max_num_widths == len(width_list):
                    break
                if 0 >= multiplier > 1:
                    nncf_logger.warning("Wrong value for multiplier: {}. Skipping ".format(multiplier))
                    continue
                w = int(max_width * multiplier)
                w = w - (w % ALIGNMENT_CONSTANT_FOR_MULTIPLIERS)
                w = max(w, p.min_width)
                if w in width_list:
                    continue
                width_list.append(w)
        return width_list

        Generates list of available width values.
        There are two mutually exclusive modes: using `width_step` and using `width_multipliers`.
        The mode with `width_step` defines a step size for a generation of the elastic width search space - the list of
        all possible width values for each layer. The generation starts from the number of output channels in the
        original model and stops when it reaches whether a `min_width` width value or number of generated width values
        equal to `max_num_widths`.
        The mode with `width_multipliers` defines elastic width search space via a list of multipliers. All possible
        width values are obtained by multiplying the original width value with the values in the given list.
        The obtained values are rounded to the nearest smaller value divisible by alignment constant (e.g. 8).

        :param max_width: maximum value of width
        :param params: parameters to configure elastic width for the operation.
        :return: list of available width values.
        
Generates list of available width values.
There are two mutually exclusive modes: using `width_step` and using `width_multipliers`.
The mode with `width_step` defines a step size for a generation of the elastic width search space - the list of
all possible width values for each layer. The generation starts from the number of output channels in the
original model and stops when it reaches whether a `min_width` width value or number of generated width values
equal to `max_num_widths`.
The mode with `width_multipliers` defines elastic width search space via a list of multipliers. All possible
width values are obtained by multiplying the original width value with the values in the given list.
The obtained values are rounded to the nearest smaller value divisible by alignment constant .
Generates list of available width values . There are two mutually exclusive modes : using ` width_step ` and using ` width_multipliers ` . The mode with ` width_step ` defines a step size for a generation of the elastic width search space - the list of all possible width values for each layer . The generation starts from the number of output channels in the original model and stops when it reaches whether a ` min_width ` width value or number of generated width values equal to ` max_num_widths ` . The mode with ` width_multipliers ` defines elastic width search space via a list of multipliers . All possible width values are obtained by multiplying the original width value with the values in the given list . The obtained values are rounded to the nearest smaller value divisible by alignment constant .
def _generate_width_list(max_width: int, params: ElasticWidthParams) -> List[int]:
        ALIGNMENT_CONSTANT_FOR_MULTIPLIERS = 8
        width_list = []
        p = params
        if max_width <= p.min_width:
            width_list.append(max_width)
        elif not p.width_multipliers:
            width = max_width
            width_list.append(width)
            width -= p.width_step
            while width >= p.min_width:
                if p.max_num_widths == len(width_list):
                    break
                width_list.append(width)
                width -= p.width_step
        else:
            p.width_multipliers.sort(reverse=True)
            if p.width_multipliers[0] < 1:
                width_list.append(max_width)
            for multiplier in p.width_multipliers:
                if p.max_num_widths == len(width_list):
                    break
                if 0 >= multiplier > 1:
                    nncf_logger.warning("Wrong value for multiplier: {}. Skipping ".format(multiplier))
                    continue
                w = int(max_width * multiplier)
                w = w - (w % ALIGNMENT_CONSTANT_FOR_MULTIPLIERS)
                w = max(w, p.min_width)
                if w in width_list:
                    continue
                width_list.append(w)
        return width_list
def _generate_width_list ( max_width : int , params : ElasticWidthParams ) -> List [ int ] : ALIGNMENT_CONSTANT_FOR_MULTIPLIERS = 8 width_list = [ ] p = params if max_width <= p . min_width : width_list . append ( max_width ) elif not p . width_multipliers : width = max_width width_list . append ( width ) width -= p . width_step while width >= p . min_width : if p . max_num_widths == len ( width_list ) : break width_list . append ( width ) width -= p . width_step else : p . width_multipliers . sort ( reverse = True ) if p . width_multipliers [ 0 ] < 1 : width_list . append ( max_width ) for multiplier in p . width_multipliers : if p . max_num_widths == len ( width_list ) : break if 0 >= multiplier > 1 : nncf_logger . warning ( "Wrong value for multiplier: {}. Skipping " . format ( multiplier ) ) continue w = int ( max_width * multiplier ) w = w - ( w % ALIGNMENT_CONSTANT_FOR_MULTIPLIERS ) w = max ( w , p . min_width ) if w in width_list : continue width_list . append ( w ) return width_list
Generates list of available width values.
Generates list of available width values .
"""
        Generates list of available width values.
        There are two mutually exclusive modes: using `width_step` and using `width_multipliers`.
        The mode with `width_step` defines a step size for a generation of the elastic width search space - the list of
        all possible width values for each layer. The generation starts from the number of output channels in the
        original model and stops when it reaches whether a `min_width` width value or number of generated width values
        equal to `max_num_widths`.
        The mode with `width_multipliers` defines elastic width search space via a list of multipliers. All possible
        width values are obtained by multiplying the original width value with the values in the given list.
        The obtained values are rounded to the nearest smaller value divisible by alignment constant (e.g. 8).

        :param max_width: maximum value of width
        :param params: parameters to configure elastic width for the operation.
        :return: list of available width values.
        """
list of available width values.
list of available width values .
max_width
int
maximum value of width
maximum value of width
params
ElasticWidthParams
parameters to configure elastic width for the operation.
parameters to configure elastic width for the operation .