-
Notifications
You must be signed in to change notification settings - Fork 28.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make EncodecModel.decode ONNX exportable #29913
Conversation
n_frames = (length - self.kernel_size + self.padding_total) / self.stride + 1 | ||
ideal_length = ((torch.ceil(n_frames).to(torch.int64) - 1) * self.stride + (self.kernel_size - self.padding_total)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essentially, we need these ops to be on tensors and not on python types (hence the registration of buffers).
The .to(torch.int64)
is added because the produced ONNX model is wrong otherwise (try to concat the float ideal_length - length
with padding_total
, which is illegal
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can confirm this fixes the issue with the ONNX export (tested with transformers.js)!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
As per title. This is needed for the ONNX export of Musicgen e.g. for transformers.js
This removes an important warning:
where a padding length was previously hard-coded and applied here
transformers/src/transformers/models/encodec/modeling_encodec.py
Lines 149 to 160 in f01e160