STFT/ISTFT pre-allocate output buffers
See original GitHub issueDescription
STFT allocates an output buffer, but sometimes you might want to have it compute directly into an existing buffer. For example, in griffin-lim, the method alternates stft/istft for each iterate, which is then discarded. It would be better if we could give it an out=
variable, which it would use instead of allocating a new buffer; this way, we could cut down on redundant memory allocations.
If the shape and/or dtype doesn’t line up, then it should throw an exception.
Issue Analytics
- State:
- Created 4 years ago
- Comments:24 (24 by maintainers)
Top Results From Across the Web
How do I pre-allocate an output buffer for the decoder?
To pre-allocate your own buffer, you should: Declare a pointer that will reference the buffer you wish to allocate. (This pointer can either...
Read more >Preallocation - MATLAB & Simulink
Loops that incrementally increase the size of an array each time through the loop can adversely affect performance and memory use.
Read more >Preallocating contiguous DMA buffers on Windows
Technical Document #3: Preallocating contiguous DMA buffers on Windows. The WinDriver DMA APIs do not limit the size of allocated DMA buffers.
Read more >Pytorch - why does preallocating memory cause "trying to ...
RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, finally shook out the bugs in istft:
Minimal-copy / pre-allocated istft
The savings are … non-existent. For a similar benchmark to the above, we get about 20ms and 5-10MB reduction in footprint. So, not nothing, but maybe not worth all the effort?
It does pass the following battery of tests though:
Punting this to 0.10 due to unanticipated API breakage.