Fix causal convolution padding for even dilated kernels - #1950
Open
YaoxinHuang wants to merge 2 commits into
Open
YaoxinHuang wants to merge 2 commits into
YaoxinHuang wants to merge 2 commits into
Conversation
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.
CausalConv1d(kernel_size=4, dilation=2)pads seven frames although its receptive field needs six, so both left and right modes produce an extra frame and fail the length assertion. This also prevents a causal HiFTResBlockfrom using an even kernel with an even dilation.Use
(kernel_size - 1) * dilationfor the padding. CPU regressions cover left/right output alignment, explicit context, causal direction, existing odd-kernel/dilation-one cases, and a realResBlockforward/backward pass.Validation:
python -m unittest discover -s tests -p test_causal_convolution.py -v— four methods pass on Python 3.10 / PyTorch 2.3.1 CPU; the original code reports 11 failures including subtests. Changed files pass the repository's flake8 settings. Full-repository flake8 reports the same 56 existing findings before and after the change; the workflow whitespace scans likewise match the baseline.Prepared and tested with Codex.