From 06f8a1ed3ff661f9b48d2d3ddb5ecad7b21161fb Mon Sep 17 00:00:00 2001 From: Aleksei Kashapov Date: Wed, 27 Mar 2024 12:03:56 +0100 Subject: [PATCH] Restore total of status bar (#2606) ### Changes Restore total number of iterations for StatisticsAggregator after https://github.com/openvinotoolkit/nncf/pull/2197 ### Reason for changes N/A ### Related tickets 136892 ### Tests Manually tested on yolov8 sample for OV. Before: ![image](https://github.com/openvinotoolkit/nncf/assets/32935044/6a1292ef-cf00-4571-bbe7-92acc36b44f4) After: ![image](https://github.com/openvinotoolkit/nncf/assets/32935044/aa5c1f6d-c4f8-4d6c-86d0-15a34bc9f86e) --- nncf/common/tensor_statistics/aggregator.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/nncf/common/tensor_statistics/aggregator.py b/nncf/common/tensor_statistics/aggregator.py index 910b359bff0..62b0b371cb6 100644 --- a/nncf/common/tensor_statistics/aggregator.py +++ b/nncf/common/tensor_statistics/aggregator.py @@ -17,7 +17,6 @@ from nncf.common import factory from nncf.common.graph.graph import NNCFGraph from nncf.common.graph.transformations.layout import TransformationLayout -from nncf.common.logging.logger import nncf_logger from nncf.common.logging.track_progress import track from nncf.common.tensor import NNCFTensor from nncf.common.tensor_statistics.statistic_point import StatisticPointsContainer @@ -29,9 +28,6 @@ EMPTY_DATASET_ERROR = ( "Calibration dataset must not be empty. Please provide calibration dataset with at least one sample." ) -ITERATIONS_NUMBER_WARNING = ( - "The number of iterations for statistics collection is bigger than the length of the dataset." -) class StatisticsAggregator(ABC): @@ -46,16 +42,13 @@ def __init__(self, dataset: Dataset): def _get_iterations_number(self) -> Optional[int]: """ - Returns number of iterations, output number is less than min(self.stat_subset_size, dataset_length). + Returns number of iterations. :return: Number of iterations for statistics collection. """ dataset_length = self.dataset.get_length() if dataset_length and self.stat_subset_size: - if self.stat_subset_size > dataset_length: - nncf_logger.warning(ITERATIONS_NUMBER_WARNING) - return dataset_length - return self.stat_subset_size + return min(dataset_length, self.stat_subset_size) return dataset_length or self.stat_subset_size def collect_statistics(self, model: TModel, graph: NNCFGraph) -> None: @@ -78,7 +71,7 @@ def collect_statistics(self, model: TModel, graph: NNCFGraph) -> None: empty_statistics = True for input_data in track( islice(self.dataset.get_inference_data(), iterations_number), - total=self.stat_subset_size, + total=iterations_number, description="Statistics collection", ): outputs = engine.infer(input_data)