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

remove njit from simple functions #754

Merged
merged 2 commits into from
Jan 12, 2024
Merged

remove njit from simple functions #754

merged 2 commits into from
Jan 12, 2024

Conversation

jmoralez
Copy link
Member

@jmoralez jmoralez commented Jan 9, 2024

Contributes to #753 by removing the njit decorator from functions that can be fast with just numpy. Also removes the season_length argument from _repeat_val_seas, since it can be inferred from the size of the season_vals.

Below are some benchmarks for the non-trivial functions, some increase its runtime but they're all in microseconds, so the impact wouldn't be noticeable (even with many series).

_intervals

x = np.random.randint(low=0, high=100, size=10_000).astype(np.float32)
%timeit _intervals(x)
main this PR
43 µs 38 µs

_chunk_sums

x = np.random.rand(10_000)
%timeit _chunk_sums(x, 5)
%timeit _chunk_sums(x, 10)
%timeit _chunk_sums(x, 20)
chunk_size main this PR
5 10 µs 35 µs
10 7 µs 23 µs
20 6 µs 13 µs

_seasonal_window_average

x = np.random.rand(10_000)
h = 100
fitted = False
season_length = 52
%timeit _seasonal_window_average(x, h, fitted, season_length, 10)
%timeit _seasonal_window_average(x, h, fitted, season_length, 20)
%timeit _seasonal_window_average(x, h, fitted, season_length, 50)
window_size main this PR
10 6 µs 20 µs
20 8 µs 20 µs
50 15 µs 19 µs

_repeat_val_seas

seas_vals = np.random.rand(24)
%timeit _repeat_val_seas(seas_vals, 500)
main this PR
3 µs 5 µs

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@jmoralez jmoralez marked this pull request as ready for review January 9, 2024 18:10
Copy link
Member

@AzulGarza AzulGarza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome @jmoralez. LGTM :)

statsforecast/utils.py Show resolved Hide resolved
@jmoralez jmoralez merged commit ddbf943 into main Jan 12, 2024
17 checks passed
@jmoralez jmoralez deleted the remove-njit-simple branch January 12, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants