TrainingExtensions/torch/src/python/aimet_torch/cross_layer_equalization.py
def scale_model(model: torch.nn.Module, input_shapes: Union[Tuple, List[Tuple]]) -> List[ClsSetInfo]:
        """
        Uses cross-layer scaling to scale all applicable layers in the given model

        :param model: Model to scale
        :param input_shapes: Input shape for the model (can be one or multiple inputs)
        :return: CLS information for each CLS set
        """

        device = get_device(model)
        model.cpu()

        # Find layer groups
        graph_search = GraphSearchUtils(model, input_shapes)
        layer_groups = graph_search.find_layer_groups_to_scale()

        # Find cls sets from the layer groups
        cls_sets = []
        for layer_group in layer_groups:
            cls_set = GraphSearchUtils.convert_layer_group_to_cls_sets(layer_group)
            cls_sets += cls_set

        # Scale the CLS sets
        scale_factors = CrossLayerScaling.scale_cls_sets(cls_sets)

        # Find if there were relu activations between layers of each cls set
        is_relu_activation_in_cls_sets = graph_search.is_relu_activation_present_in_cls_sets(cls_sets)

        # Convert to a list of cls-set-info elements
        cls_set_info_list = CrossLayerScaling.create_cls_set_info_list(cls_sets, scale_factors,
                                                                       is_relu_activation_in_cls_sets)

        model.to(device=device)
        return cls_set_info_list

        Uses cross-layer scaling to scale all applicable layers in the given model

        :param model: Model to scale
        :param input_shapes: Input shape for the model (can be one or multiple inputs)
        :return: CLS information for each CLS set
        
Uses cross-layer scaling to scale all applicable layers in the given model
Uses cross - layer scaling to scale all applicable layers in the given model
def scale_model(model: torch.nn.Module, input_shapes: Union[Tuple, List[Tuple]]) -> List[ClsSetInfo]:
        device = get_device(model)
        model.cpu()
        graph_search = GraphSearchUtils(model, input_shapes)
        layer_groups = graph_search.find_layer_groups_to_scale()
        cls_sets = []
        for layer_group in layer_groups:
            cls_set = GraphSearchUtils.convert_layer_group_to_cls_sets(layer_group)
            cls_sets += cls_set
        scale_factors = CrossLayerScaling.scale_cls_sets(cls_sets)
        is_relu_activation_in_cls_sets = graph_search.is_relu_activation_present_in_cls_sets(cls_sets)
        cls_set_info_list = CrossLayerScaling.create_cls_set_info_list(cls_sets, scale_factors,
                                                                       is_relu_activation_in_cls_sets)
        model.to(device=device)
        return cls_set_info_list
def scale_model ( model : torch . nn . Module , input_shapes : Union [ Tuple , List [ Tuple ] ] ) -> List [ ClsSetInfo ] : device = get_device ( model ) model . cpu ( ) graph_search = GraphSearchUtils ( model , input_shapes ) layer_groups = graph_search . find_layer_groups_to_scale ( ) cls_sets = [ ] for layer_group in layer_groups : cls_set = GraphSearchUtils . convert_layer_group_to_cls_sets ( layer_group ) cls_sets += cls_set scale_factors = CrossLayerScaling . scale_cls_sets ( cls_sets ) is_relu_activation_in_cls_sets = graph_search . is_relu_activation_present_in_cls_sets ( cls_sets ) cls_set_info_list = CrossLayerScaling . create_cls_set_info_list ( cls_sets , scale_factors , is_relu_activation_in_cls_sets ) model . to ( device = device ) return cls_set_info_list
Uses cross-layer scaling to scale all applicable layers in the given model
Uses cross - layer scaling to scale all applicable layers in the given model
"""
        Uses cross-layer scaling to scale all applicable layers in the given model

        :param model: Model to scale
        :param input_shapes: Input shape for the model (can be one or multiple inputs)
        :return: CLS information for each CLS set
        """ # Find layer groups # Find cls sets from the layer groups # Scale the CLS sets # Find if there were relu activations between layers of each cls set # Convert to a list of cls-set-info elements
CLS information for each CLS set
CLS information for each CLS set
model
torch.nn.Module
Model to scale
Model to scale
input_shapes
Union[Tuple, List[Tuple]]
Input shape for the model (can be one or multiple inputs)
Input shape for the model ( can be one or multiple inputs )