Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore total of status bar #2606

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions nncf/common/tensor_statistics/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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:
Expand All @@ -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)
Expand Down
Loading