Skip to content

[FBC] Support models without the batch dimension - #4149

Open
darshil929 wants to merge 2 commits into
openvinotoolkit:developfrom
darshil929:fbc-no-batch-dim
Open

[FBC] Support models without the batch dimension#4149
darshil929 wants to merge 2 commits into
openvinotoolkit:developfrom
darshil929:fbc-no-batch-dim

Conversation

@darshil929

Copy link
Copy Markdown
Contributor

Changes

  • get_mean_statistic_collector (common and OpenVINO builders) accepts an optional input_rank argument. For input_rank == 1 the mean branch uses RawReducer, since a 1D activation has no batch dimension and its elements are already the per channel values; the MeanAggregator then averages them across samples. The default None keeps the current reducer selection for every existing caller.
  • FastBiasCorrection.get_statistic_points passes the statically known input and output ranks to the collectors, forwarded by mean_statistic_collector in all four backends.
  • FastBiasCorrection._get_bias_shift skips mean_per_channel for 1D outputs of the extracted submodel, since they are already per channel data.
  • The OneDimMM case from [BC] Use atleast_1d to enable models with no batch dimention #3479 is enabled in the FBC test template, which parametrizes it across the OpenVINO, Torch, Torch FX and ONNX backend tests.

Reason for changes

FastBiasCorrection crashes for models without the batch dimension. On current develop the crash happens in _get_fp_outputs (TypeError: iteration over a 0-d tensor), and behind it sits the IndexError from the issue in create_input_data. The root cause is that the statistics pipeline treats axis 0 as the batch axis, so a 1D activation gets its only axis averaged away and the per channel statistics collapse to a scalar. Selecting the reducer by rank where the collectors are built fixes the statistics at the source and keeps BiasCorrection and all other users of the builders unchanged.

Related tickets

#3481

Tests

  • test_update_bias[OneDimMM] passes on all four backends against the reference biases introduced with [BC] Use atleast_1d to enable models with no batch dimention #3479
  • Full FastBiasCorrection and BiasCorrection suites pass on OpenVINO, Torch, Torch FX and ONNX; BiasCorrection results are unchanged
  • tests/common and the statistics collector suites pass; pre-commit checks pass

@darshil929
darshil929 requested a review from a team as a code owner July 20, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant