def generic(self, args, kws): [lhs, rhs] = args return signature(types.boolean, lhs, rhs)
class Cuda_syncthreads_count(ConcreteTemplate): key = cuda.syncthreads_count cases = [signature(types.i4, types.i4)]
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)
class Cuda_syncwarp(ConcreteTemplate): key = cuda.syncwarp cases = [signature(types.none, types.i4)]
class Cuda_brev(ConcreteTemplate): key = cuda.brev cases = [ signature(types.uint32, types.uint32), signature(types.uint64, types.uint64), ]
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)
class Cuda_threadfence_block(ConcreteTemplate): key = cuda.threadfence_block cases = [signature(types.none)]
def resolve_conjugate(self, ty, args, kws): assert not args assert not kws return signature(ty)
def resolve_item(self, ty, args, kws): assert not kws if not args: return signature(ty)
def generic(self, args, kws): assert not kws (val, ) = args if isinstance(val, (types.BaseTuple)): return signature(types.boolean, val)
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])
def generic(self, args, kws): assert not kws (seq, val) = args if isinstance(seq, (types.Sequence)): return signature(types.boolean, seq, val)
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)
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), ]
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)
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)
def generic_index(self, args, kws): assert not args assert not kws return signature(types.intp, recvr=self.this)
def resolve_copy(self, ary, args, kws): assert not args assert not kws retty = ary.copy(layout="C", readonly=False) return signature(retty)
class Cuda_threadfence_device(ConcreteTemplate): key = cuda.threadfence cases = [signature(types.none)]
def resolve_sort(self, ary, args, kws): assert not args assert not kws if ary.ndim == 1: return signature(types.none)
class Cuda_threadfence_system(ConcreteTemplate): key = cuda.threadfence_system cases = [signature(types.none)]
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'))
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) ]
def generic_homog(self, args, kws): assert not args assert not kws return signature(self.this.dtype, recvr=self.this)
class Cuda_syncthreads(ConcreteTemplate): key = cuda.syncthreads cases = [signature(types.none)]
def generic_expand(self, args, kws): assert not args assert not kws return signature(_expand_integer(self.this.dtype), recvr=self.this)
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)
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)
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)
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)