Examples/torch/compression/spatial_svd.py
def aimet_spatial_svd(model: torch.nn.Module,
                      evaluator: aimet_common.defs.EvalFunction):
    """
    Compresses the model using AIMET's Spatial SVD auto mode compression scheme.

    :param model: The model to compress
    :param evaluator: Evaluator used during compression
    :param data_loader: DataLoader used during compression
    :return: A tuple of compressed model and its statistics
    """

    # create the parameters for AIMET to compress on auto mode.
    # please refer to the API documentation for other schemes (i.e weight svd & channel prunning)
    # and mode (manual)
    greedy_params = aimet_torch.defs.GreedySelectionParameters(target_comp_ratio=Decimal(0.5),
                                                               num_comp_ratio_candidates=10)
    auto_params = aimet_torch.defs.SpatialSvdParameters.AutoModeParams(greedy_params,
                                                                       modules_to_ignore=[model.conv1])
    params = aimet_torch.defs.SpatialSvdParameters(aimet_torch.defs.SpatialSvdParameters.Mode.auto,
                                                   auto_params)

    scheme = CompressionScheme.spatial_svd
    metric = CostMetric.mac

    results = ModelCompressor.compress_model(model=model,
                                             eval_callback=evaluator,
                                             eval_iterations=10,
                                             input_shape=(1, 3, 224, 224),
                                             compress_scheme=scheme,
                                             cost_metric=metric,
                                             parameters=params)
    return results

    Compresses the model using AIMET's Spatial SVD auto mode compression scheme.

    :param model: The model to compress
    :param evaluator: Evaluator used during compression
    :param data_loader: DataLoader used during compression
    :return: A tuple of compressed model and its statistics
    
Compresses the model using AIMET's Spatial SVD auto mode compression scheme.
Compresses the model using AIMET ' s Spatial SVD auto mode compression scheme .
def aimet_spatial_svd(model: torch.nn.Module,
                      evaluator: aimet_common.defs.EvalFunction):
    greedy_params = aimet_torch.defs.GreedySelectionParameters(target_comp_ratio=Decimal(0.5),
                                                               num_comp_ratio_candidates=10)
    auto_params = aimet_torch.defs.SpatialSvdParameters.AutoModeParams(greedy_params,
                                                                       modules_to_ignore=[model.conv1])
    params = aimet_torch.defs.SpatialSvdParameters(aimet_torch.defs.SpatialSvdParameters.Mode.auto,
                                                   auto_params)
    scheme = CompressionScheme.spatial_svd
    metric = CostMetric.mac
    results = ModelCompressor.compress_model(model=model,
                                             eval_callback=evaluator,
                                             eval_iterations=10,
                                             input_shape=(1, 3, 224, 224),
                                             compress_scheme=scheme,
                                             cost_metric=metric,
                                             parameters=params)
    return results
def aimet_spatial_svd ( model : torch . nn . Module , evaluator : aimet_common . defs . EvalFunction ) : greedy_params = aimet_torch . defs . GreedySelectionParameters ( target_comp_ratio = Decimal ( 0.5 ) , num_comp_ratio_candidates = 10 ) auto_params = aimet_torch . defs . SpatialSvdParameters . AutoModeParams ( greedy_params , modules_to_ignore = [ model . conv1 ] ) params = aimet_torch . defs . SpatialSvdParameters ( aimet_torch . defs . SpatialSvdParameters . Mode . auto , auto_params ) scheme = CompressionScheme . spatial_svd metric = CostMetric . mac results = ModelCompressor . compress_model ( model = model , eval_callback = evaluator , eval_iterations = 10 , input_shape = ( 1 , 3 , 224 , 224 ) , compress_scheme = scheme , cost_metric = metric , parameters = params ) return results
Compresses the model using AIMET's Spatial SVD auto mode compression scheme.
Compresses the model using AIMET ' s Spatial SVD auto mode compression scheme .
"""
    Compresses the model using AIMET's Spatial SVD auto mode compression scheme.

    :param model: The model to compress
    :param evaluator: Evaluator used during compression
    :param data_loader: DataLoader used during compression
    :return: A tuple of compressed model and its statistics
    """ # create the parameters for AIMET to compress on auto mode. # please refer to the API documentation for other schemes (i.e weight svd & channel prunning) # and mode (manual)
A tuple of compressed model and its statistics
A tuple of compressed model and its statistics
model
torch.nn.Module
The model to compress
The model to compress
evaluator
aimet_common.defs.EvalFunction
Evaluator used during compression
Evaluator used during compression
data_loader
DataLoader used during compression
DataLoader used during compression