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: 9 additions & 4 deletions nncf/common/tensor_statistics/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from nncf.common import factory
from nncf.common.graph.graph import NNCFGraph
from nncf.common.graph.transformations.layout import TransformationLayout
from nncf.common.logging 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 Down Expand Up @@ -68,9 +69,8 @@ def collect_statistics(self, model: TModel, graph: NNCFGraph) -> None:
transformation_layout = self._get_transformation_layout_extra_outputs(merged_statistics)
model_with_outputs: TModel = model_transformer.transform(transformation_layout)
engine = factory.EngineFactory.create(model_with_outputs)

iterations_number = self._get_iterations_number()
empty_statistics = True
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 +79,14 @@ 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
if processed_samples == 0:
raise nncf.ValidationError(EMPTY_DATASET_ERROR)
if self.stat_subset_size is not None and self.stat_subset_size > processed_samples:
nncf_logger.warning(
f"Dataset contains only {processed_samples} samples, "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@l-bat, @eaidova, @nikita-savelyevv please check that this is not impact NNCF examples, OpenVINO notebooks and optimum-intel.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zina-cs Could you please provide subset_size to the nncf.quantize in the following examples?

  1. https://github.com/openvinotoolkit/nncf/tree/develop/examples/post_training_quantization/openvino:
    • anomaly_stfpm_quantize_with_accuracy_control - subset_size=109
    • yolov8 - subset_size=128
    • yolov8_quantize_with_accuracy_control - subset_size=128
  2. https://github.com/openvinotoolkit/nncf/tree/develop/examples/post_training_quantization/onnx/yolov8_quantize_with_accuracy_control - subset_size=128
  3. https://github.com/openvinotoolkit/nncf/tree/develop/examples/post_training_quantization/torch/ssd300_vgg16 - subset_size=128

f"smaller than the requested subset size {self.stat_subset_size}."
)

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