Esempio n. 1
0
 def generic(self, args, kws):
     [lhs, rhs] = args
     return signature(types.boolean, lhs, rhs)
Esempio n. 2
0
class Cuda_syncthreads_count(ConcreteTemplate):
    key = cuda.syncthreads_count
    cases = [signature(types.i4, types.i4)]
Esempio n. 3
0
 def generic(self, args, kws):
     assert not kws
     if all(isinstance(it, types.IterableType) for it in args):
         zip_type = types.ZipType(args)
         return signature(zip_type, *args)
Esempio n. 4
0
class Cuda_syncwarp(ConcreteTemplate):
    key = cuda.syncwarp
    cases = [signature(types.none, types.i4)]
Esempio n. 5
0
class Cuda_brev(ConcreteTemplate):
    key = cuda.brev
    cases = [
        signature(types.uint32, types.uint32),
        signature(types.uint64, types.uint64),
    ]
Esempio n. 6
0
 def generic(self, args, kws):
     assert not kws
     [va, vb] = args
     if isinstance(va, types.Array) and va == vb:
         return signature(va.copy(dtype=types.boolean), va, vb)
Esempio n. 7
0
class Cuda_threadfence_block(ConcreteTemplate):
    key = cuda.threadfence_block
    cases = [signature(types.none)]
Esempio n. 8
0
 def resolve_conjugate(self, ty, args, kws):
     assert not args
     assert not kws
     return signature(ty)
Esempio n. 9
0
 def resolve_item(self, ty, args, kws):
     assert not kws
     if not args:
         return signature(ty)
Esempio n. 10
0
 def generic(self, args, kws):
     assert not kws
     (val, ) = args
     if isinstance(val, (types.BaseTuple)):
         return signature(types.boolean, val)
Esempio n. 11
0
 def generic(self, args, kws):
     args = args[::-1]
     sig = self.context.resolve_function_type(operator.contains, args, kws)
     return signature(sig.return_type, *sig.args[::-1])
Esempio n. 12
0
    def generic(self, args, kws):
        assert not kws
        (seq, val) = args

        if isinstance(seq, (types.Sequence)):
            return signature(types.boolean, seq, val)
Esempio n. 13
0
 def generic(self, args, kws):
     assert not kws
     ptr, idx, val = args
     if isinstance(ptr, types.CPointer) and isinstance(idx, types.Integer):
         return signature(types.none, ptr, normalize_1d_index(idx),
                          ptr.dtype)
Esempio n. 14
0
class Slice(ConcreteTemplate):
    cases = [
        signature(types.slice2_type, types.intp),
        signature(types.slice2_type, types.none),
        signature(types.slice2_type, types.none, types.none),
        signature(types.slice2_type, types.none, types.intp),
        signature(types.slice2_type, types.intp, types.none),
        signature(types.slice2_type, types.intp, types.intp),
        signature(types.slice3_type, types.intp, types.intp, types.intp),
        signature(types.slice3_type, types.none, types.intp, types.intp),
        signature(types.slice3_type, types.intp, types.none, types.intp),
        signature(types.slice3_type, types.intp, types.intp, types.none),
        signature(types.slice3_type, types.intp, types.none, types.none),
        signature(types.slice3_type, types.none, types.intp, types.none),
        signature(types.slice3_type, types.none, types.none, types.intp),
        signature(types.slice3_type, types.none, types.none, types.none),
    ]
Esempio n. 15
0
def generic_hetero_real(self, args, kws):
    assert not args
    assert not kws
    if isinstance(self.this.dtype, (types.Integer, types.Boolean)):
        return signature(types.float64, recvr=self.this)
    return signature(self.this.dtype, recvr=self.this)
Esempio n. 16
0
 def generic(self, args, kws):
     assert not kws
     [ary, idx] = args
     out = get_array_index_type(ary, idx)
     if out is not None:
         return signature(out.result, ary, out.index)
Esempio n. 17
0
def generic_index(self, args, kws):
    assert not args
    assert not kws
    return signature(types.intp, recvr=self.this)
Esempio n. 18
0
 def resolve_copy(self, ary, args, kws):
     assert not args
     assert not kws
     retty = ary.copy(layout="C", readonly=False)
     return signature(retty)
Esempio n. 19
0
class Cuda_threadfence_device(ConcreteTemplate):
    key = cuda.threadfence
    cases = [signature(types.none)]
Esempio n. 20
0
 def resolve_sort(self, ary, args, kws):
     assert not args
     assert not kws
     if ary.ndim == 1:
         return signature(types.none)
Esempio n. 21
0
class Cuda_threadfence_system(ConcreteTemplate):
    key = cuda.threadfence_system
    cases = [signature(types.none)]
Esempio n. 22
0
 def resolve_flatten(self, ary, args, kws):
     # Only support no argument version (default order='C')
     assert not kws
     assert not args
     return signature(ary.copy(ndim=1, layout='C'))
Esempio n. 23
0
class Cuda_vote_sync_intrinsic(ConcreteTemplate):
    key = cuda.vote_sync_intrinsic
    cases = [
        signature(types.Tuple((types.i4, types.b1)), types.i4, types.i4,
                  types.b1)
    ]
Esempio n. 24
0
def generic_homog(self, args, kws):
    assert not args
    assert not kws
    return signature(self.this.dtype, recvr=self.this)
Esempio n. 25
0
class Cuda_syncthreads(ConcreteTemplate):
    key = cuda.syncthreads
    cases = [signature(types.none)]
Esempio n. 26
0
def generic_expand(self, args, kws):
    assert not args
    assert not kws
    return signature(_expand_integer(self.this.dtype), recvr=self.this)
Esempio n. 27
0
    according to the integer typing NBEP.
    """
    bitwidth = choose_result_bitwidth(*inputs)
    signed = any(tp.signed for tp in inputs)
    return types.Integer.from_bitwidth(bitwidth, signed)


# The "machine" integer types to take into consideration for operator typing
# (according to the integer typing NBEP)
machine_ints = (sorted(set(
    (types.intp, types.int64))) + sorted(set((types.uintp, types.uint64))))

# Explicit integer rules for binary operators; smaller ints will be
# automatically upcast.
integer_binop_cases = tuple(
    signature(choose_result_int(op1, op2), op1, op2)
    for op1, op2 in itertools.product(machine_ints, machine_ints))


class BinOp(ConcreteTemplate):
    cases = list(integer_binop_cases)
    cases += [signature(op, op, op) for op in sorted(types.real_domain)]
    cases += [signature(op, op, op) for op in sorted(types.complex_domain)]


@infer_global(operator.add)
class BinOpAdd(BinOp):
    pass


@infer_global(operator.iadd)
Esempio n. 28
0
def sum_expand(self, args, kws):
    """
    sum can be called with or without an axis parameter, and with or without
    a dtype parameter
    """
    pysig = None
    if 'axis' in kws and 'dtype' not in kws:

        def sum_stub(axis):
            pass

        pysig = utils.pysignature(sum_stub)
        # rewrite args
        args = list(args) + [kws['axis']]
    elif 'dtype' in kws and 'axis' not in kws:

        def sum_stub(dtype):
            pass

        pysig = utils.pysignature(sum_stub)
        # rewrite args
        args = list(args) + [kws['dtype']]
    elif 'dtype' in kws and 'axis' in kws:

        def sum_stub(axis, dtype):
            pass

        pysig = utils.pysignature(sum_stub)
        # rewrite args
        args = list(args) + [kws['axis'], kws['dtype']]

    args_len = len(args)
    assert args_len <= 2
    if args_len == 0:
        # No axis or dtype parameter so the return type of the summation is a scalar
        # of the type of the array.
        out = signature(_expand_integer(self.this.dtype),
                        *args,
                        recvr=self.this)
    elif args_len == 1 and 'dtype' not in kws:
        # There is an axis parameter, either arg or kwarg
        if self.this.ndim == 1:
            # 1d reduces to a scalar
            return_type = self.this.dtype
        else:
            # the return type of this summation is  an array of dimension one
            # less than the input array.
            return_type = types.Array(dtype=_expand_integer(self.this.dtype),
                                      ndim=self.this.ndim - 1,
                                      layout='C')
        out = signature(return_type, *args, recvr=self.this)

    elif args_len == 1 and 'dtype' in kws:
        # No axis parameter so the return type of the summation is a scalar
        # of the dtype parameter.
        from .npydecl import parse_dtype
        dtype, = args
        dtype = parse_dtype(dtype)
        out = signature(dtype, *args, recvr=self.this)

    elif args_len == 2:
        # There is an axis and dtype parameter, either arg or kwarg
        from .npydecl import parse_dtype
        dtype = parse_dtype(args[1])
        return_type = dtype
        if self.this.ndim != 1:
            # 1d reduces to a scalar, 2d and above reduce dim by 1
            # the return type of this summation is  an array of dimension one
            # less than the input array.
            return_type = types.Array(dtype=return_type,
                                      ndim=self.this.ndim - 1,
                                      layout='C')
        out = signature(return_type, *args, recvr=self.this)
    else:
        pass
    return out.replace(pysig=pysig)
Esempio n. 29
0
 def generic(self, args, kws):
     assert not kws
     if len(args) == 1:
         it = args[0]
         if isinstance(it, types.IteratorType):
             return signature(it.yield_type, *args)
Esempio n. 30
0
 def generic(self, args, kws):
     assert not kws
     (arg1, arg2) = args
     if isinstance(arg1, types.Literal) and isinstance(arg2, types.Literal):
         return signature(types.boolean, arg1, arg2)