TrainingExtensions/torch/src/python/aimet_torch/cross_layer_equalization.py
def convert_layer_group_to_cls_sets(layer_group):
        """
        Helper function to convert a layer group to a list of cls sets
        :param layer_group: Given layer group to conver
        :return: List of cls sets
        """
        cls_sets = []

        prev_layer_to_scale = layer_group.pop(0)
        while layer_group:
            next_layer_to_scale = layer_group.pop(0)

            if next_layer_to_scale.groups > 1:

                if layer_group:
                    next_non_depthwise_conv_layer = layer_group.pop(0)
                    cls_sets.append((prev_layer_to_scale, next_layer_to_scale, next_non_depthwise_conv_layer))
                    prev_layer_to_scale = next_non_depthwise_conv_layer

            else:
                cls_sets.append((prev_layer_to_scale, next_layer_to_scale))
                prev_layer_to_scale = next_layer_to_scale

        return cls_sets

        Helper function to convert a layer group to a list of cls sets
        :param layer_group: Given layer group to conver
        :return: List of cls sets
        
Helper function to convert a layer group to a list of cls sets
Helper function to convert a layer group to a list of cls sets
def convert_layer_group_to_cls_sets(layer_group):
        cls_sets = []
        prev_layer_to_scale = layer_group.pop(0)
        while layer_group:
            next_layer_to_scale = layer_group.pop(0)
            if next_layer_to_scale.groups > 1:
                if layer_group:
                    next_non_depthwise_conv_layer = layer_group.pop(0)
                    cls_sets.append((prev_layer_to_scale, next_layer_to_scale, next_non_depthwise_conv_layer))
                    prev_layer_to_scale = next_non_depthwise_conv_layer
            else:
                cls_sets.append((prev_layer_to_scale, next_layer_to_scale))
                prev_layer_to_scale = next_layer_to_scale
        return cls_sets
def convert_layer_group_to_cls_sets ( layer_group ) : cls_sets = [ ] prev_layer_to_scale = layer_group . pop ( 0 ) while layer_group : next_layer_to_scale = layer_group . pop ( 0 ) if next_layer_to_scale . groups > 1 : if layer_group : next_non_depthwise_conv_layer = layer_group . pop ( 0 ) cls_sets . append ( ( prev_layer_to_scale , next_layer_to_scale , next_non_depthwise_conv_layer ) ) prev_layer_to_scale = next_non_depthwise_conv_layer else : cls_sets . append ( ( prev_layer_to_scale , next_layer_to_scale ) ) prev_layer_to_scale = next_layer_to_scale return cls_sets
Helper function to convert a layer group to a list of cls sets
Helper function to convert a layer group to a list of cls sets
"""
        Helper function to convert a layer group to a list of cls sets
        :param layer_group: Given layer group to conver
        :return: List of cls sets
        """
List of cls sets
List of cls sets
layer_group
Given layer group to conver
Given layer group to conver