Repository navigation
Conversation
The default mapping passed C_out as in_channels and C_in / groups as out_channels. With groups=1 the forward pass stayed correct because the weight is overwritten afterwards, but the module attributes were swapped. With groups > 1 the constructor could raise "out_channels must be divisible by groups", so a depthwise NIR node could not be imported. Use in_channels = weight.shape[1] * groups and out_channels = weight.shape[0], and add tests for depthwise and grouped convolutions.
This branch has not been deployed
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.
Problem
_default_map_conv1dand_default_map_conv2dpass the weight dimensions totorch.nn.Conv1d/Conv2din the wrong order:C_outis used asin_channelsandC_in / groupsasout_channels.With
groups=1the forward pass is still correct, because the weight isoverwritten afterwards, but
in_channelsandout_channelsof the module areswapped. With
groups > 1the constructor can fail, so a valid depthwise NIRnode cannot be imported with
DEFAULT_MAP:Fix
Use
in_channels = weight.shape[1] * groupsandout_channels = weight.shape[0],which is the layout
torch.nn.Conv1d/Conv2duse for their own weight.Tests
test_map_conv1d_nodeandtest_map_conv2d_nodenow checkin_channelsand
out_channels.convolutions compare the mapped module with
torch.nn.functional.conv1d/conv2d.Before the fix: 8 failed. After:
83 passed, 2 skippedon the full suite, onWindows (Python 3.10 to 3.13) and Linux (Python 3.10 and 3.13), with nir 1.0.8
and torch CPU.
ruff checkpasses.Notes
The new tests use
input_shape=None, so they do not depend onneuromorphs/NIR#204.