Reduce dependency on padding
See original GitHub issueMany of our functions use padding to simplify vectorization of certain operations, eg:
in util.localmax
exists solely to make edge cases easy to handle in vectorized code.
This is good because the code is concise, readable, and fast. But it’s also bad because it invokes a full O(n)
memory copy for what is literally an edge case.
We should conduct a thorough audit of the library for this kind of thing – I don’t think there is very much of it – and replace pads with more careful code that can operate in place if possiible. Odds are good that this will require some numbafication if we have to replace vector ops with loops.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
How to automatically reduce or increase content padding ...
You may want to remove the padding/margin for any smaller screen sizes. Try like this: @media (max-width: 978px) { .container { padding:0; ...
Read more >spacing - How can I reduce padding after figure? - TeX
I recommend using more than just [h] for positioning. See Keeping tables/figures close to where they are mentioned. – Stefan Kottwitz ♢. Jul...
Read more >Oh Hey, Padding Percentage is Based on the Parent ...
I always thought that percentage padding was based on the element itself. So if an element is 1,000 pixels wide with padding-top: 50%...
Read more >Responsive Padding, Margin & Gutters With CSS Calc
Make your padding, margin, gutters, and other whitespace elements dynamic so they respond to match the screen size of the current device ...
Read more >A padding method to reduce edge effects for enhanced ...
Request PDF | A padding method to reduce edge effects for enhanced damage identification using wavelet analysis | Vibration response based ...
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
Adding this to the 0.10 docket - I expect what we’ll end up with is:
The rest of the identified pad usages seem either low-priority (few code paths touch them) or not worth the added code complexity to optimize.
Local min and max are higher priority because they get used as utility functions, eg within (p)yin and beat tracking. The optimization is easy to do and the payoff is substantial.
After a bit of reflection, I think we should remove this from the 0.9.2 milestone.
Getting STFT and friends #871 covered will pick up the vast majority of performance gains here, and the rest would make the code more complex than I’m really comfortable with. (Though TBH, not very many of these are easy modifications anyway.)
Thinking longer term, I think what would be most helpful here is an abstracted “padded array” class that divides up an ndarray into its padded regions and original region, similar to how a dask array divides up into chunks, where the original region is copy-by-reference. I don’t think this functionality belongs in librosa, but if it made its way into numpy (or a lightweight standalone package that we could depend on), that would be the best option all around IMO.