Visualize and Debug Numba compiled code in Jupyter
Project description
numba-inspector
View Numba compiled code in Jupyter
Quickstart
Installation
Fork then clone the repository:
$ git clone git@github.com:<username>/numba-inspector.git
%%numba magic command
%load_ext numba_inspector
%%numba --bytecode
from numba import njit
@njit
def func(x,y):
if x:
x=x+1
if y:
y=y+1
else:
y=y-1
else:
x=x-1
if y:
y=y+1
else:
y=y-1
return x+y
func(1,2)
%%numba --ptx
from numba import cuda
import numpy as np
@cuda.jit(lineinfo=True)
def increment_by_one(an_array):
# Thread id in a 1D block
tx = cuda.threadIdx.x
# Block id in a 1D grid
ty = cuda.blockIdx.x
# Block width, i.e. number of threads per block
bw = cuda.blockDim.x
# Compute flattened index inside the array
pos = tx + ty * bw
if pos < an_array.size: # Check array boundaries
an_array[pos] += 1
a = np.arange(4096,dtype=np.float32)
d_a = cuda.to_device(a)
blocks = 32
threads = 128
increment_by_one[blocks, threads](d_a)
cuda.synchronize()
d_a.copy_to_host()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
numba_inspector-0.0.3.tar.gz
(11.8 kB
view hashes)
Built Distribution
Close
Hashes for numba_inspector-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49e2cc393b4fc71cb19bd3086291f1fc7a7b483c8f4739a6a5442e990d631cdf |
|
MD5 | 1241ca8044f45a2c05105ac37cdee9c3 |
|
BLAKE2b-256 | f1681c8788ee8ee11d5b56da5d967e72b249d7c5c7264cf57cf310bac6e94bde |