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

[CPU][Ref] Fix Reduce ops to produce stable (zero val) output for empty input #27423

Closed

Conversation

mitruska
Copy link
Contributor

@mitruska mitruska commented Nov 6, 2024

Details:

  • Fix Reduce ops to produce stable output (filled with zeroes instead of random values) for an empty input:
    including update of CPU and reference implementations.

  • Such behavior has been requested for NNCF

  • Originally random values has been produced, because common shape inference of the Reduce can produce non empty output shape for an empty input, for example Reduce with keep_dims=False:
    InputShape{2, 0}, reduce_axes=1, OutputShape{2}

  • Common CPU Reduce::isExecutable was returning False for an empty input tensor (with 0 dim in the input Shape), and the Reduce::execute has not been executed at all for such case.
    The proposal of updated behavior is to return False for an empty output shape (with 0 dim in the output Shape),
    but when the input is empty, but the output is not, the output will be filled with 0.

Note: This change is considered as partially backward compatible with relatively low risk. Some of the Reduce ops already has defined default value other than zero in reference. Unifying the default value to be zero for all Reduce ops, makes onnx reduce prod and reduce min with empty input tests fail: logs

Alternatively Reduce ops common shape_inference can be updated:

  • A. To produce empty output for empty input and keep 0 dim in the output shape even if requested by "axes" to be reduced.
    or
  • B. Throw an error when reduction over 0 dimension is detected.

But those options are currently considered as not backward compatible, and would require new version of each Reduce* op.

Tickets:

  • 117469

@github-actions github-actions bot added category: Core OpenVINO Core (aka ngraph) category: CPU OpenVINO CPU plugin category: transformations OpenVINO Runtime library - Transformations category: TEMPLATE OpenVINO Template plugin labels Nov 6, 2024
@mitruska mitruska changed the title [CPU][Ref] Fix Reduce ops to produce stable output for empty input [CPU][Ref] Fix Reduce ops to produce stable (zero val) output for empty input Nov 6, 2024
@mitruska mitruska closed this Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Core OpenVINO Core (aka ngraph) category: CPU OpenVINO CPU plugin category: TEMPLATE OpenVINO Template plugin category: transformations OpenVINO Runtime library - Transformations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant