fix(pruning): normalize a negative channel axis#45
Open
eyupcanakman wants to merge 1 commit into
Open
Conversation
ChannelStructured(axis=-1) pruned the wrong channels. _compute_channel_mask compared each dim index against the raw axis when building its reduce list, so a negative axis excluded nothing and the per-channel L1 norms collapsed to a scalar. Normalize the axis first, matching PerChannelGranularity, and reject an out-of-range axis with ValueError rather than letting it reach the reduction.
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.
ChannelStructured(axis=-1)prunes the wrong channels._compute_channel_maskcompares each dim index against the raw axis when building its reduce list. A negative axis never matches, so nothing is excluded and the per-channel L1 norms collapse to a scalar. With one channel kept, channel 0 survives regardless. With more than one the call fails:Positive axes work. The fix normalizes the axis first, matching
PerChannelGranularity, which documents and resolves negative indexing. An out-of-range axis now raisesValueError, since one addition leaves values below-ndimstill negative. The tests coverLinearandConv2dweights and the rejected range.