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.
The current implementation of
Blob::Reshape
has a check to ensure that Blob sizes do not exceedINT_MAX
that goes awry whenever the size of the Blob is 0. (More precisely, the check causes a floating point exception if a 0 appears in the shape anywhere except for the last element.) This PR disables that check ifcount_ == 0
.While this seems a little silly upon first glance, I think there is a very real use case for supporting this behavior. I'm training a detection network that uses ground truth boxes, which are typically represented by 5 values, but some images have no ground truth boxes at all. In this case, having a ground truth blob of shape (0, 5) seems perfectly sensible to me.
This PR also includes a simple test that reshapes a Blob to shape (0, 5), which would have failed prior to the fix.