예제 #1
0
    def _register(self):
        from numba.core.typing.templates import (make_intrinsic_template,
                                                 infer_global)

        template = make_intrinsic_template(self, self._defn, self._name)
        infer(template)
        infer_global(self, types.Function(template))
예제 #2
0
 def decorate(overload_func):
     template = make_overload_template(func, overload_func, opts, strict,
                                       inline, prefer_literal)
     infer(template)
     if callable(func):
         infer_global(func, types.Function(template))
     return overload_func
예제 #3
0
    def decorate(typing_func):
        def generic(self):
            return typing_func(self.context)

        name = "%s_CallableTemplate" % (func_name, )
        bases = (CallableTemplate, )
        class_dict = dict(key=func, generic=generic)
        template = type(name, bases, class_dict)
        infer(template)
        if callable(func):
            infer_global(func, types.Function(template))
        return typing_func
예제 #4
0
파일: builtins.py 프로젝트: zsoltc89/numba
        signature(types.range_state32_type, types.int32, types.int32,
                  types.int32),
        signature(types.range_state64_type, types.int64),
        signature(types.range_state64_type, types.int64, types.int64),
        signature(types.range_state64_type, types.int64, types.int64,
                  types.int64),
        signature(types.unsigned_range_state64_type, types.uint64),
        signature(types.unsigned_range_state64_type, types.uint64,
                  types.uint64),
        signature(types.unsigned_range_state64_type, types.uint64,
                  types.uint64, types.uint64),
    ]


for func in RANGE_ITER_OBJECTS:
    infer_global(func, typing_key=range)(Range)

infer_global(prange, typing_key=prange)(Range)
infer_global(internal_prange, typing_key=internal_prange)(Range)


@infer
class GetIter(AbstractTemplate):
    key = "getiter"

    def generic(self, args, kws):
        assert not kws
        [obj] = args
        if isinstance(obj, types.IterableType):
            # Raise this here to provide a very specific message about this
            # common issue, delaying the error until later leads to something
예제 #5
0

# FIXME_Numba#6781: due to overlapping of overload_methods for Numba TypeRef
# we have to use our new SdcTypeRef to type objects created from types.Type
# (i.e. ConcurrentDict meta-type). This should be removed once it's fixed.
def sdc_make_new_typeref_class():
    class SdcTypeRef(types.Dummy):
        """Reference to a type.

        Used when a type is passed as a value.
        """
        def __init__(self, instance_type):
            self.instance_type = instance_type
            super(SdcTypeRef,
                  self).__init__('sdc_typeref[{}]'.format(self.instance_type))

    @register_model(SdcTypeRef)
    class SdcTypeRefModel(models.OpaqueModel):
        def __init__(self, dmm, fe_type):

            models.OpaqueModel.__init__(self, dmm, fe_type)

    return SdcTypeRef


ConcurrentDictTypeRef = sdc_make_new_typeref_class()
MultiIndexTypeRef = sdc_make_new_typeref_class()

infer_global(ConcurrentDict, ConcurrentDictTypeRef(ConcurrentDictType))
infer_global(pd.MultiIndex, MultiIndexTypeRef(MultiIndexType))