def grab_byte(typingctx, data, offset):
    # returns a byte at a given offset in data
    def impl(context, builder, signature, args):
        data, idx = args
        ptr = builder.bitcast(data, ir.IntType(8).as_pointer())
        ch = builder.load(builder.gep(ptr, [idx]))
        return ch

    sig = types.uint8(types.voidptr, types.intp)
    return sig, impl
Exemple #2
0
def _Py_CHARMASK(ch):
    """
    Equivalent to the CPython macro `Py_CHARMASK()`, masks off all but the
    lowest 256 bits of ch.
    """
    return types.uint8(ch) & types.uint8(0xff)
Exemple #3
0
        def parallel_xargsort_arithm_impl(arr, ascending=True):
            index = numpy.empty(shape=len(arr), dtype=numpy.int64)
            sort_f(index.ctypes, arr.ctypes, len(arr), types.uint8(ascending))

            return index
Exemple #4
0
def node_loss(tree, node, idx_sample):

    c = uint8(tree.samples.labels[idx_sample])
    sc = node_score(tree, node, c)
    # TODO: benchmark different logarithms
    return -log(sc)
Exemple #5
0
def node_is_dirac(tree, idx_node, y_t):
    c = uint8(y_t)
    n_samples = tree.nodes.n_samples[idx_node]
    count = tree.nodes.counts[idx_node, c]
    return n_samples == count
Exemple #6
0
def node_classifier_is_dirac(tree, idx_node, y_t):
    c = types.uint8(y_t)
    nodes = tree.nodes
    n_samples = nodes.n_samples[idx_node]
    count = nodes.counts[idx_node, c]
    return n_samples == count
Exemple #7
0
                    typed_name = f'{funcname}_{suffix}'
                jitted_func = njit(sig)(func)
                setattr(self, typed_name, jitted_func)

        return ncompiler


GrB_UnaryOp = OpContainer()
GrB_BinaryOp = OpContainer()

##################################
# Useful collections of signatures
##################################
_unary_bool = [nt.boolean(nt.boolean)]
_unary_int = [
    nt.uint8(nt.uint8),
    nt.int8(nt.int8),
    nt.uint16(nt.uint16),
    nt.int16(nt.int16),
    nt.uint32(nt.uint32),
    nt.int32(nt.int32),
    nt.uint64(nt.uint64),
    nt.int64(nt.int64)
]
_unary_float = [nt.float32(nt.float32), nt.float64(nt.float64)]
_unary_all = _unary_bool + _unary_int + _unary_float

_binary_bool = [nt.boolean(nt.boolean, nt.boolean)]
_binary_int = [
    nt.uint8(nt.uint8, nt.uint8),
    nt.int8(nt.int8, nt.int8),