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

refac: optimize WelfordStatistics update and finalization #325

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

federico-carrara
Copy link
Collaborator

Description

This PR replaces the current inefficient implementation of Welford statustics update and finalization with a faster numpy based implementation.

  • What: Refactored methods in running_stats.py.
  • Why: Performance.
  • How: Replacing for loops and list comprehensions with numpy vectorized ops.

Notes

No tests are there at the moment. However results provided by refactored code match the ones using the old version.


Please ensure your PR meets the following requirements:

  • Code builds and passes tests locally, including doctests
  • New tests have been added (for bug fixes/features)
  • Pre-commit passes
  • PR to the documentation exists (for bug fixes / features)

@CatEek CatEek self-requested a review December 12, 2024 09:46
@federico-carrara
Copy link
Collaborator Author

Realized that outputs do not perfectly match with previous approach. I'll have a second look before merging

@federico-carrara
Copy link
Collaborator Author

Issues with tests + bug in the std computation are now solved.

In the future memory efficiency can be improved, the delta tensors actually take a lot of memory for large images (spectral or 3D).

@federico-carrara federico-carrara merged commit 6eb3627 into main Dec 12, 2024
18 checks passed
@federico-carrara federico-carrara deleted the fc/refac/optimize_welford branch December 12, 2024 10:56
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.

2 participants