Skip to content
Advertisement

Tag: numba

Create np.array filled with zero arrays

I’m trying to initialize an “empty” array with each elements containing t_list a 8×8 np.zeros array : t_list = np.zeros((8,8), dtype=np.float32) I would now want to have a np.array with multiple t_list at each indexes: result = np.array((t_list, t_list, …., tlist)) I would like to be able to control the number of time t_list is in result. I know that

Why does this code fail to compile with Numba?

I have a sample code that illustrates my issue. If you run: It will fail with: argsort is supposed to argsort on the last axis. Essentially it should give me: I thought copying the arr2 array (with copy()) could solve as it would make the array contiguous in memory (instead of a view), but it fails with the same message

(JIT) Compilation of Python code with FFI library calls

I’m using Python with a library that uses cppyy to get access to a ton of C++ functions natively in Python. However, the calls to cppyy methods take a lot of time, and looping in Python with a library call means that overhead becomes a serious issue. Here’s an example of what I mean: This code would be really fast

Find minimum difference between two vectors with numba

I’ve tried to optimize searching for minimum value between two numpy vectors with numba. There is speed up and result is correct until I use prange and parallel=True option. I understand that the issue is in sharing variables min_val, tmp, min_val_idx_a, min_val_idx_b during parallel execution (maybe with parallel threads). Is there way to overcome the problem and use numba in

Is there a better way to use cython when looking to speed up Python?

I have a large numpy array with the following structure: I’m using cython to try and speed up the processing as much as possible. The argument dataset in the code below is the above array. However, when running the above code with and without cython I get the following times: without cython: 0:00:00.945872 with cython: 0:00:00.561925 Any ideas how I

Using typed dictionaries in ahead of time compilation in numba

I’m trying to use ahead of time compilation in numba on a function that takes a numba typed dictionary as its input. The file compiles without errors, but when I load the resulting module I get an error: An example function that produces the same error is: This function will be called by another function in the compiled code. Answer

Python square brackets between function name and arguments: func[…](…)

I was learning how to accelerate python computations on GPU from this notebook, where one line confuses me: Here, mandel_kernel is a decorated (by cuda.jit) function, griddim and blockdim are tuples of length 2: griddim=(32,16), blockdim=(32,8). Is this square brackets in between function name and argument list part of python syntax, or something specific to the cuda.jit decoration? Answer This

Advertisement