nncf/experimental/post_training/compression_builder.py
def apply(self, model: ModelType, dataloader: DataLoader, engine: Engine = None) -> ModelType:
        """
        Apply compression algorithms to the 'model'.
        1) Prepare the original model. This step is essential for some backends, e.g. ONNX
        2) Creates subalgorithms, which is essential for some composite algorithms such as PostTrainingQuantization
        2) Creates default Engine if it wasn't provided.
        3) Creates StatisticsAggregator.
        4) Get layers for statistics collection from algorithms.
        5) Collect all statistics.
        6) Apply algorithms.
        """

        if not self.algorithms:
            nncf_logger.info('There are no algorithms added. The original model will be returned.')
            return model

        backend = get_model_backend(model)
        modified_model = self._get_prepared_model_for_compression(model, backend)

        if engine is None:
            engine = self._create_engine(backend)

        for algorithm in self.algorithms:
            algorithm.create_subalgorithms(backend)

        statistics_aggregator = self._create_statistics_aggregator(engine, dataloader, backend)
        for algorithm in self.algorithms:
            layers_to_collect_statistics = algorithm.get_layers_for_statistics(modified_model)
            statistics_aggregator.register_layer_statistics(layers_to_collect_statistics)

        statistics_aggregator.collect_statistics(modified_model)

        for algorithm in self.algorithms:
            modified_model = algorithm.apply(modified_model, engine, statistics_aggregator.layers_statistics)
        return modified_model

        Apply compression algorithms to the 'model'.
        1) Prepare the original model. This step is essential for some backends, e.g. ONNX
        2) Creates subalgorithms, which is essential for some composite algorithms such as PostTrainingQuantization
        2) Creates default Engine if it wasn't provided.
        3) Creates StatisticsAggregator.
        4) Get layers for statistics collection from algorithms.
        5) Collect all statistics.
        6) Apply algorithms.
        
Apply compression algorithms to the 'model'.
1) Prepare the original model. This step is essential for some backends, e.g. ONNX
2) Creates subalgorithms, which is essential for some composite algorithms such as PostTrainingQuantization
2) Creates default Engine if it wasn't provided.
Apply compression algorithms to the ' model ' . 1 ) Prepare the original model . This step is essential for some backends e . g . ONNX 2 ) Creates subalgorithms which is essential for some composite algorithms such as PostTrainingQuantization 2 ) Creates default Engine if it wasn ' t provided .
def apply(self, model: ModelType, dataloader: DataLoader, engine: Engine = None) -> ModelType:
        if not self.algorithms:
            nncf_logger.info('There are no algorithms added. The original model will be returned.')
            return model
        backend = get_model_backend(model)
        modified_model = self._get_prepared_model_for_compression(model, backend)
        if engine is None:
            engine = self._create_engine(backend)
        for algorithm in self.algorithms:
            algorithm.create_subalgorithms(backend)
        statistics_aggregator = self._create_statistics_aggregator(engine, dataloader, backend)
        for algorithm in self.algorithms:
            layers_to_collect_statistics = algorithm.get_layers_for_statistics(modified_model)
            statistics_aggregator.register_layer_statistics(layers_to_collect_statistics)
        statistics_aggregator.collect_statistics(modified_model)
        for algorithm in self.algorithms:
            modified_model = algorithm.apply(modified_model, engine, statistics_aggregator.layers_statistics)
        return modified_model
def apply ( self , model : ModelType , dataloader : DataLoader , engine : Engine = None ) -> ModelType : if not self . algorithms : nncf_logger . info ( 'There are no algorithms added. The original model will be returned.' ) return model backend = get_model_backend ( model ) modified_model = self . _get_prepared_model_for_compression ( model , backend ) if engine is None : engine = self . _create_engine ( backend ) for algorithm in self . algorithms : algorithm . create_subalgorithms ( backend ) statistics_aggregator = self . _create_statistics_aggregator ( engine , dataloader , backend ) for algorithm in self . algorithms : layers_to_collect_statistics = algorithm . get_layers_for_statistics ( modified_model ) statistics_aggregator . register_layer_statistics ( layers_to_collect_statistics ) statistics_aggregator . collect_statistics ( modified_model ) for algorithm in self . algorithms : modified_model = algorithm . apply ( modified_model , engine , statistics_aggregator . layers_statistics ) return modified_model
Apply compression algorithms to the 'model'.
Apply compression algorithms to the ' model ' .
"""
        Apply compression algorithms to the 'model'.
        1) Prepare the original model. This step is essential for some backends, e.g. ONNX
        2) Creates subalgorithms, which is essential for some composite algorithms such as PostTrainingQuantization
        2) Creates default Engine if it wasn't provided.
        3) Creates StatisticsAggregator.
        4) Get layers for statistics collection from algorithms.
        5) Collect all statistics.
        6) Apply algorithms.
        """
self
model
ModelType
dataloader
DataLoader
engine
Engine