예제 #1
0
def build_executor(py_ufunc, pyast_function, operands,
                   aterm_subgraph_root, strategy='chunked'):
    """ Build a ufunc and an wrapping executor from a Python AST """
    result_dtype = unannotate_dtype(aterm_subgraph_root)
    operand_dtypes = map(unannotate_dtype, operands)

    vectorizer = Vectorize(py_ufunc)
    vectorizer.add(restype=minitype(result_dtype),
                   argtypes=map(minitype, operand_dtypes))
    ufunc = vectorizer.build_ufunc()

    # Get a string of the operation for debugging
    return_stat = pyast_function.body[0]
    operation = getsource(return_stat.value)

    # TODO: build an executor tree and substitute where we can evaluate
    executor = executors.ElementwiseLLVMExecutor(
        strategy,
        ufunc,
        operand_dtypes,
        result_dtype,
        operation=operation,
    )

    return executor
예제 #2
0
def build_executor(py_ufunc,
                   pyast_function,
                   operands,
                   aterm_subgraph_root,
                   strategy='chunked'):
    """ Build a ufunc and an wrapping executor from a Python AST """
    result_dtype = unannotate_dtype(aterm_subgraph_root)
    operand_dtypes = map(unannotate_dtype, operands)

    vectorizer = Vectorize(py_ufunc)
    vectorizer.add(restype=minitype(result_dtype),
                   argtypes=map(minitype, operand_dtypes))
    ufunc = vectorizer.build_ufunc()

    # Get a string of the operation for debugging
    return_stat = pyast_function.body[0]
    operation = getsource(return_stat.value)

    # TODO: build an executor tree and substitute where we can evaluate
    executor = executors.ElementwiseLLVMExecutor(
        strategy,
        ufunc,
        operand_dtypes,
        result_dtype,
        operation=operation,
    )

    return executor
예제 #3
0
def build_executor(py_ufunc, operands, aterm_subgraph_root):
    """ Build a ufunc and an wrapping executor from a Python AST """
    result_dtype = unannotate_dtype(aterm_subgraph_root)
    operand_dtypes = map(unannotate_dtype, operands)

    vectorizer = Vectorize(py_ufunc)
    vectorizer.add(restype=minitype(result_dtype),
                   argtypes=map(minitype, operand_dtypes))
    ufunc = vectorizer.build_ufunc()

    # TODO: build an executor tree and substitute where we can evaluate
    executor = executors.ElementwiseLLVMExecutor(
        ufunc,
        operand_dtypes,
        result_dtype,
    )

    return executor
예제 #4
0
from numba.decorators import jit
from numba import *
from numpy import sqrt
from numpy import log
from numpy import exp
f, d = f4, f8



import pyfits

def logThreshold(img_mat):
    return 10*log(img_mat+10)+10


bv = Vectorize(logThreshold, backend='bytecode')
bv.add(restype=f, argtypes=[f])
b_poly_d = bv.build_ufunc()


pv = Vectorize(logThreshold, target='parallel', backend='bytecode')
pv.add(restype=f, argtypes=[f])
p_poly_d = pv.build_ufunc()

    



f1 = pyfits.getdata('fpC-003836-r3-0254.fit')
iterNum = 10