Fix BatchNormLayer::Reshape crash on 1-axis blobs#7101
Open
Chessing234 wants to merge 1 commit intoBVLC:masterfrom
Open
Fix BatchNormLayer::Reshape crash on 1-axis blobs#7101Chessing234 wants to merge 1 commit intoBVLC:masterfrom
Chessing234 wants to merge 1 commit intoBVLC:masterfrom
Conversation
The guard condition uses num_axes() >= 1, but shape(1) requires at least 2 axes. With exactly 1 axis, shape(1) calls CanonicalAxisIndex(1) which triggers CHECK_LT(1, 1) and aborts. LayerSetUp correctly handles this case with num_axes() == 1 at line 17. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Bug
In
BatchNormLayer::Reshape, line 54:When a blob has exactly 1 axis,
shape(1)callsCanonicalAxisIndex(1)which triggersCHECK_LT(1, 1)and aborts.Root cause
The guard should be
>= 2, not>= 1.LayerSetUp(lines 17-20) correctly handles 1-axis blobs by checkingnum_axes() == 1and settingchannels_ = 1without accessingshape(1).Fix
Changed
>= 1to>= 2to match the minimum axes needed forshape(1).🤖 Generated with Claude Code