Route Pytorch Conv1D/2D with groups == channels to depthwise conv - #1524
Merged
Conversation
HamzaEzzRa
marked this pull request as ready for review
August 11, 2026 16:16
JanFSchulte
approved these changes
Aug 12, 2026
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.
Description
Similar to the Keras issue solved in #1486, Pytorch Conv1D/2D where
groups == in_channels == out_channelsis not routed to the correctDepthwiseConvcodegen path. Since Pytorch doesn't have a built-inDepthwiseConvlayer, the only way I know to express this operation is to change a standard Convgroupsto matchin_channelsandout_channels, which the pytorch_to_hls.py converter strictly rejects.This patch relaxes the condition in
pytorch_to_hls.pyto includegroups > 1 and groups == in_channels == out_channelsas a valid configuration, then routes to the correctDepthwiseConv1D/2Dgraph layer inside convolution.py and reshapes to(depth_multiplier, n_chan, *kernel_size)withdepth_multiplier = 1for the depthwise conv.Type of change
Tests
Added two tests:
test/pytest/test_depthconv1d_pytorch.pytest/pytest/test_depthconv2d_pytorch.pyBoth are similar to the existing
test_depthconv1d.pyandtest_depthconv2d.py, with code adapted fromtest_pytorch_api.pyfor Pytorch compatibility. Vivado and Vitis tests passed, but I don't have Catapult installed in my system to verify its backend.Test Configuration:
Same pytest configuration as the existing
test_depthconv1d.pyandtest_depthconv2d.pyrespectively.pytest test/pytest/test_depthconv*d_pytorch.pyChecklist
pre-commiton the files I edited or added.