numba.npyufunc package

Submodules

numba.npyufunc.decorators module

class numba.npyufunc.decorators.GUVectorize

Bases: object

target_registry = {'cpu': <class 'numba.npyufunc.ufuncbuilder.GUFuncBuilder'>}
class numba.npyufunc.decorators.Vectorize

Bases: object

target_registry = {'cpu': <class 'numba.npyufunc.ufuncbuilder.UFuncBuilder'>}
numba.npyufunc.decorators.guvectorize(ftylist, signature[, target='cpu'[, **kws]])

A decorator to create numpy generialized-ufunc object from Numba compiled code.

ftylist: iterable
An iterable of type signatures, which are either function type object or a string describing the function type.
signature: str
A NumPy generialized-ufunc signature. e.g. “(m, n), (n, p)->(m, p)”
target: str
A string for code generation target. Defaults to “cpu”.

A NumPy generialized universal-function

@guvectorize([‘void(int32[:,:], int32[:,:], int32[:,:])’,
‘void(float32[:,:], float32[:,:], float32[:,:])’], ‘(x, y),(x, y)->(x, y)’)
def add_2d_array(a, b):
for i in range(c.shape[0]):
for j in range(c.shape[1]):
c[i, j] = a[i, j] + b[i, j]
numba.npyufunc.decorators.vectorize(ftylist[, target='cpu'[, **kws]])

A decorator to create numpy ufunc object from Numba compiled code.

ftylist: iterable
An iterable of type signatures, which are either function type object or a string describing the function type.
target: str
A string for code generation target. Default to “cpu”.

A NumPy universal function

@vectorize([‘float32(float32, float32)’,
‘float64(float64, float64)’])
def sum(a, b):
return a + b

numba.npyufunc.sigparse module

numba.npyufunc.sigparse.parse_signature(sig)

Parse generalized ufunc signature.

NOTE: ‘,’ (COMMA) is a delimiter; not separator.
This means trailing comma is legal.

numba.npyufunc.ufuncbuilder module

class numba.npyufunc.ufuncbuilder.GUFuncBuilder(py_func, signature, targetoptions={})

Bases: object

add(sig=None, argtypes=None, restype=None)
build(cres)

Returns (dtype numbers, function ptr, EnviornmentObject)

build_ufunc()
class numba.npyufunc.ufuncbuilder.UFuncBuilder(py_func, targetoptions={})

Bases: object

add(sig=None, argtypes=None, restype=None)
build(cres)
build_ufunc()
class numba.npyufunc.ufuncbuilder.UFuncDispatcher(py_func, locals={}, targetoptions={})

Bases: object

compile(sig, locals={}, **targetoptions)
targetdescr = <numba.npyufunc.ufuncbuilder.UFuncTarget object at 0x1083e1ad0>
class numba.npyufunc.ufuncbuilder.UFuncTarget

Bases: numba.targets.registry.CPUTarget

options

alias of UFuncTargetOptions

class numba.npyufunc.ufuncbuilder.UFuncTargetOptions

Bases: numba.targets.options.TargetOptions

OPTIONS = {'forceobj': <type 'bool'>, 'nopython': <type 'bool'>}

numba.npyufunc.wrappers module

class numba.npyufunc.wrappers.GUArrayArg(context, builder, args, dims, steps, i, step_offset, typ, syms, sym_dim)

Bases: object

next(i)
class numba.npyufunc.wrappers.UArrayArg(context, builder, args, steps, i, argtype)

Bases: object

load(ind)
load_aligned(ind)
load_direct(offset)
store(value, ind)
store_aligned(value, ind)
store_direct(value, offset)
numba.npyufunc.wrappers.build_fast_loop_body(context, func, builder, arrays, out, offsets, store_offset, signature, ind)
numba.npyufunc.wrappers.build_gufunc_wrapper(context, func, signature, sin, sout, fndesc)
numba.npyufunc.wrappers.build_slow_loop_body(context, func, builder, arrays, out, offsets, store_offset, signature)
numba.npyufunc.wrappers.build_ufunc_wrapper(context, func, signature)

Wrap the scalar function with a loop that iterates over the arguments

Module contents