Repository navigation
[v2] fix len when x.shape[1] != x_len.max - #44
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
s3tokenizer/model_v2.py (1)
332-337: Tiex_slenupdates to actual conv strides for future‑proofing
x_slenfor the second stage currently usesself.stridein the length formula, whileconv2has a hard‑codedstride=2. This is correct for the currentS3TokenizerV2configuration (wherestrideis passed as 2), but it bakes in an implicit assumption thatself.stride == self.conv2.stride[0]. For robustness ifAudioEncoderV2is ever reused with a different initial stride, consider deriving these lengths from the conv modules themselves, e.g.:- x_slen = (T + 2 - 1 * (3 - 1) - 1) // self.stride + 1 + x_slen = (T + 2 * self.conv1.padding[0] + - self.conv1.dilation[0] * (self.conv1.kernel_size[0] - 1) + - 1) // self.conv1.stride[0] + 1 - x_slen = (x_slen + 2 - 1 * (3 - 1) - 1) // self.stride + 1 + x_slen = (x_slen + 2 * self.conv2.padding[0] + - self.conv2.dilation[0] * (self.conv2.kernel_size[0] - 1) + - 1) // self.conv2.stride[0] + 1This keeps
x_slenmechanically consistent with whatever conv parameters are configured.Please double‑check that these formulas still match the intended conv shapes if you adjust kernel/stride/padding in future.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
s3tokenizer/model_v2.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
s3tokenizer/model_v2.py (1)
s3tokenizer/utils.py (1)
make_non_pad_mask(270-307)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: unit-test (ubuntu-22.04, 3.10.16)
🔇 Additional comments (1)
s3tokenizer/model_v2.py (1)
328-337: Masking and length tracking now correctly align with padded time dimensionsUsing
T = x.shape[-1]and passing it asmax_lenintomake_non_pad_mask(x_len, T)ensures the initial mask always has time lengthT, even whenx_len.max()is smaller due to padding. The introduction ofx_slento mirror conv output lengths from the paddedTand reusing it asmax_lenin subsequentmake_non_pad_mask(x_len, x_slen)calls keeps mask shapes in lockstep with both Conv1d stages. This directly resolves the shape mismatch whenx.shape[-1] != x_len.max()while preserving the existingx_lenformulas used downstream.
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.