Cache does not work when passing numpy arrays to objmode inside overload
See original GitHub issueReporting a bug
- I have tried using the latest released version of Numba (most recent is visible in the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
- I have included below a minimal working reproducer (if you are unsure how to write one see http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports).
Hello, I found this bug with cache=True
when using overloads. Replicator is below:
import numpy as np
import numba
from numba.extending import overload
def print_this(a, b):
print(a)
print(b)
def do_something(a, b):
print(a)
print(b)
@overload(do_something)
def overload_do_something(a, b):
def _do_something_impl(a, b):
with numba.objmode:
print_this(a, b)
return _do_something_impl
@numba.njit(cache=True)
def test_caching():
a = np.arange(20)
b = np.arange(50)
#a = 1 # works if pass this instead of numpy array
#b = 3
do_something(a, b)
test_caching()
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
A guide to using @overload - Numba
A common use case is to re-implement NumPy functions so that they can be called in @jit decorated code. This section discusses how...
Read more >Supported NumPy features - Numba documentation
NumPy arrays are directly supported in Numba. Access to NumPy arrays is very efficient, as indexing is lowered to direct memory accesses when...
Read more >numpy.load — NumPy v1.24 Manual
Loading files that contain object arrays uses the pickle module, which is not secure against erroneous or maliciously constructed data. Consider passing ......
Read more >Numba_051_release_demo - Jupyter Notebook - MyBinder
Caching of jit functions defined in closures. The new StructRef type for defining mutable pass-by-reference structures. NumPy enhancements. First, import the ...
Read more >c - cache numba jitted function with arguments include ...
It's just an example. And the my point is that how can I pass in other functions as argument and cache it. –...
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 Free
Top 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
Holding a reference to
env
https://github.com/numba/numba/blob/ebbae83720e6c29ef6fbb756298211d24869279f/numba/core/environment.py#L57 stops the segfault.Thanks @juanjgalvez for debugging it. A null pointer in Python C-API can be caused by a previous C-API failed and raised an exception. The code may have forgotten to check for the error.