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

Update aggregator.py #2995

Merged
merged 11 commits into from
Oct 17, 2024
13 changes: 10 additions & 3 deletions nncf/common/tensor_statistics/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from nncf.data.dataset import DataItem
from nncf.data.dataset import Dataset
from nncf.data.dataset import ModelInput
from nncf.common.logging import nncf_logger
zina-cs marked this conversation as resolved.
Show resolved Hide resolved

TensorType = TypeVar("TensorType")
TModel = TypeVar("TModel")
Expand Down Expand Up @@ -70,7 +71,9 @@ def collect_statistics(self, model: TModel, graph: NNCFGraph) -> None:
engine = factory.EngineFactory.create(model_with_outputs)

iterations_number = self._get_iterations_number()
empty_statistics = True

zina-cs marked this conversation as resolved.
Show resolved Hide resolved
processed_samples = 0

for input_data in track( # type: ignore
islice(self.dataset.get_inference_data(), iterations_number),
total=iterations_number,
Expand All @@ -79,9 +82,13 @@ def collect_statistics(self, model: TModel, graph: NNCFGraph) -> None:
outputs = engine.infer(input_data)
processed_outputs = self._process_outputs(outputs)
self._register_statistics(processed_outputs, merged_statistics)
empty_statistics = False
if empty_statistics:
processed_samples += 1

zina-cs marked this conversation as resolved.
Show resolved Hide resolved
if processed_samples == 0:
raise nncf.ValidationError(EMPTY_DATASET_ERROR)

zina-cs marked this conversation as resolved.
Show resolved Hide resolved
if subset_size > processed_samples:
zina-cs marked this conversation as resolved.
Show resolved Hide resolved
nncf_logger.warning(f"Dataset contains only {processed_samples} samples, smaller than the requested subset size {subset_size}.")
zina-cs marked this conversation as resolved.
Show resolved Hide resolved

def register_statistic_points(self, statistic_points: StatisticPointsContainer) -> None:
"""
Expand Down
Loading