[5676209][ONNX][Autocast] Add check for input bs vs calibration data bs #652
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Type of change: Bug fix
Overview: Autocast crashes if the input batch size in the ONNX model is different to the calibration data input batch size. For example: calibration data has shape
[10, 6, 3, 480, 800]and ONNX model has shape[1, 6, 3, 480, 800]. The quantization workflow interprets this as 10 calibration samples, so ideally, Autocast would also interpret them similarly. This PR just allows Autocast to exit gracefully with a custom message.Usage
Testing
See bug 5676209.
Before your PR is "Ready for review"
Additional Information
Original error:
polygraphy.exception.exception.PolygraphyException: Input tensor: image | Received incompatible shape: (10, 6, 3, 480, 800). Note: Expected a shape compatible with: BoundedShape([1, 6, 3, 480, 800], min=None, max=None)Autocast error:
ValueError: Input shape from 'image' does not match provided input shape: [1, 6, 3, 480, 800] vs [10, 6, 3, 480, 800]. Please make sure that your calibration data matches the ONNX input shapes.