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

Cubic numba proper compilation #4488

Merged
merged 34 commits into from
Jun 7, 2022
Merged

Conversation

zeffii
Copy link
Collaborator

@zeffii zeffii commented May 22, 2022

solves the signature issue, does not solve auto compilation for later reuse.

  • rewrites minor parts of the cubic function to match the subset of numpy that numba can reliably read
  • adds decorator and faux decorator
  • adds automatic signature generation (compilation step for diskstorage does not work yet!)

turns out that you can generate a signature automatically ( why the docs aren't explicit about this is baffling) by doing

import numba

def make_signature_tuple(*params):
    return tuple([numba.typeof(p) for p in params])

param_1 = np.array([[0.0, 0.1, 2.0], [1.0, 0.3, 2.0], [2.0, 0.1, 2.3]])   
param_2 = 3
param_n = np.array([0, 2, 3, 4, 12, 14])
params = param_1, param_2, param_n

print(make_signature_tuple(*params)
>>> (array(float64, 2d, C), int64, array(int32, 1d, C))

@zeffii
Copy link
Collaborator Author

zeffii commented May 23, 2022

with the caching argument set to True the function is definitely stored to disk (pickled..)

image

https://numba.readthedocs.io/en/stable/reference/envvars.html#numba-envvars-caching

using the sv wrapper for njit to store the result of njit locally in a function dictionary is faster (permanently!) than, purely importing numba.njit(cache=True) and applyin that to the function.

@zeffii
Copy link
Collaborator Author

zeffii commented May 30, 2022

@portnov what do you think of this PR. any improvement ideas?

@zeffii
Copy link
Collaborator Author

zeffii commented May 30, 2022

if we can get some consensus on this, i'm interested in applying numba to other areas too.

@zeffii
Copy link
Collaborator Author

zeffii commented Jun 7, 2022

I think this is the least invasive approach. njit is attempted if numba is found, else the function just passes through the wrapper unchanged.

@zeffii zeffii marked this pull request as ready for review June 7, 2022 10:38
@zeffii zeffii merged commit 7aef47b into master Jun 7, 2022
@zeffii zeffii deleted the cubic_numba_proper_compilation branch June 7, 2022 10:39
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