Skip to content
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

Avoid zero-initialization of packing buffers #70

Merged
merged 1 commit into from
Mar 30, 2024

Conversation

robertknight
Copy link
Owner

@robertknight robertknight commented Mar 30, 2024

Avoid overhead from zeroing memory when prepacking matrix inputs by allowing the packing functions to write to uninitialized memory. The packing functions guarantee that the entire buffer passed to them is initialized when they return.

In a TTS demo using Tacotron2 1, which uses an LSTM-based decoder, this reduces the "real-time factor" (degree of slowdown over real-time generation) from ~1.9x to ~1.65x.

TODO:

  • Make sure only the portion of buffers that we expect to use is passed to packing functions. Vec::spare_capacity_mut can in theory return a larger capacity than we asked for.
  • Review the safety comments

Footnotes

  1. https://github.com/robertknight/xd-tts

Avoid overhead from zeroing memory when prepacking matrix inputs by allowing the
packing functions to write to uninitialized memory.

In a TTS demo using Tacotron2 [^1], which uses an LSTM-based decoder, this
reduces the "real-time factor" (degree of slowdown over real-time generation)
from ~1.9x to ~1.65x.

[^1]: https://github.com/robertknight/xd-tts
@robertknight robertknight marked this pull request as ready for review March 30, 2024 10:37
@robertknight robertknight merged commit ae2b8da into main Mar 30, 2024
2 checks passed
@robertknight robertknight deleted the gemm-pack-uninit-2 branch March 30, 2024 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant