question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cache does not work when passing numpy arrays to objmode inside overload

See original GitHub issue

Reporting a bug

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:closed
  • Created 3 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
sklamcommented, Aug 13, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found