当前位置: 首页>>代码示例>>Python>>正文


Python sigutils.normalize_signature函数代码示例

本文整理汇总了Python中numba.sigutils.normalize_signature函数的典型用法代码示例。如果您正苦于以下问题:Python normalize_signature函数的具体用法?Python normalize_signature怎么用?Python normalize_signature使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了normalize_signature函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: compile

    def compile(self, sig):
        with self._compile_lock:
            args, return_type = sigutils.normalize_signature(sig)
            # Don't recompile if signature already exists
            existing = self.overloads.get(tuple(args))
            if existing is not None:
                return existing

            # Try to load from disk cache
            cres = self._cache.load_overload(sig, self.targetctx)
            if cres is not None:
                # XXX fold this in add_overload()? (also see compiler.py)
                if not cres.objectmode and not cres.interpmode:
                    self.targetctx.insert_user_function(cres.entry_point,
                                                   cres.fndesc, [cres.library])
                self.add_overload(cres)
                return cres.entry_point

            flags = compiler.Flags()
            self.targetdescr.options.parse_as_flags(flags, self.targetoptions)

            cres = compiler.compile_extra(self.typingctx, self.targetctx,
                                          self.py_func,
                                          args=args, return_type=return_type,
                                          flags=flags, locals=self.locals)

            # Check typing error if object mode is used
            if cres.typing_error is not None and not flags.enable_pyobject:
                raise cres.typing_error

            self.add_overload(cres)
            self._cache.save_overload(sig, cres)
            return cres.entry_point
开发者ID:GaZ3ll3,项目名称:numba,代码行数:33,代码来源:dispatcher.py

示例2: compile

    def compile(self, sig):
        with self._compile_lock:
            # XXX this is mostly duplicated from Dispatcher.
            flags = self.flags
            args, return_type = sigutils.normalize_signature(sig)

            # Don't recompile if signature already exists
            # (e.g. if another thread compiled it before we got the lock)
            existing = self.overloads.get(tuple(args))
            if existing is not None:
                return existing.entry_point

            assert not flags.enable_looplift, "Enable looplift flags is on"
            cres = compiler.compile_ir(typingctx=self.typingctx,
                                       targetctx=self.targetctx,
                                       func_ir=self.func_ir,
                                       args=args, return_type=return_type,
                                       flags=flags, locals=self.locals,
                                       lifted=(),
                                       lifted_from=self.lifted_from)

            # Check typing error if object mode is used
            if cres.typing_error is not None and not flags.enable_pyobject:
                raise cres.typing_error

            self.add_overload(cres)
            return cres.entry_point
开发者ID:FedericoStra,项目名称:numba,代码行数:27,代码来源:dispatcher.py

示例3: __init__

    def __init__(self, pyfunc, signature):
        self.py_func = pyfunc
        self.signature = signature
        self.name = pyfunc.__name__

        # recreate for each UDF, as linking is destructive to the
        # precompiled module
        impala_typing = impala_typing_context()
        impala_targets = ImpalaTargetContext(impala_typing)

        args, return_type = sigutils.normalize_signature(signature)
        flags = Flags()
        flags.set('no_compile')
        self._cres = compile_extra(typingctx=impala_typing,
                                   targetctx=impala_targets, func=pyfunc,
                                   args=args, return_type=return_type,
                                   flags=flags, locals={})
        llvm_func = impala_targets.finalize(self._cres.llvm_func, return_type,
                                            args)
        self.llvm_func = llvm_func
        # numba_module = llvm_func.module
        self.llvm_module = llvm_func.module
        # link in the precompiled module
        # bc it's destructive, load a fresh version
        precompiled = lc.Module.from_bitcode(
            pkgutil.get_data("impala.udf", "precompiled/impyla.bc"))
        self.llvm_module.link_in(precompiled)
开发者ID:awleblang,项目名称:impyla,代码行数:27,代码来源:__init__.py

示例4: convert_types

def convert_types(restype, argtypes):
    # eval type string
    if sigutils.is_signature(restype):
        assert argtypes is None
        argtypes, restype = sigutils.normalize_signature(restype)

    return restype, argtypes
开发者ID:CaptainAL,项目名称:Spyder,代码行数:7,代码来源:decorators.py

示例5: add

    def add(self, sig=None, argtypes=None, restype=None):
        # Handle argtypes
        if argtypes is not None:
            warnings.warn("Keyword argument argtypes is deprecated",
                          DeprecationWarning)
            assert sig is None
            if restype is None:
                sig = tuple(argtypes)
            else:
                sig = restype(*argtypes)
        del argtypes
        del restype

        # compile core as device function
        args, return_type = sigutils.normalize_signature(sig)
        devfnsig = signature(return_type, *args)

        funcname = self.pyfunc.__name__
        kernelsource = self._get_kernel_source(self._kernel_template,
                                               devfnsig, funcname)
        corefn, return_type = self._compile_core(devfnsig)
        glbl = self._get_globals(corefn)
        sig = signature(types.void, *([a[:] for a in args] + [return_type[:]]))
        _exec(kernelsource, glbl)

        stager = glbl['__vectorized_%s' % funcname]
        kernel = self._compile_kernel(stager, sig)

        argdtypes = tuple(to_dtype(t) for t in devfnsig.args)
        resdtype = to_dtype(return_type)
        self.kernelmap[tuple(argdtypes)] = resdtype, kernel
开发者ID:GaZ3ll3,项目名称:numba,代码行数:31,代码来源:deviceufunc.py

示例6: compile

    def compile(self, sig, locals={}, **targetoptions):
        with self._compile_lock():
            locs = self.locals.copy()
            locs.update(locals)

            topt = self.targetoptions.copy()
            topt.update(targetoptions)

            flags = compiler.Flags()
            self.targetdescr.options.parse_as_flags(flags, topt)

            glctx = self.targetdescr
            typingctx = glctx.typing_context
            targetctx = glctx.target_context

            args, return_type = sigutils.normalize_signature(sig)

            # Don't recompile if signature already exist.
            existing = self.overloads.get(tuple(args))
            if existing is not None:
                return existing.entry_point

            cres = compiler.compile_extra(typingctx, targetctx, self.py_func,
                                          args=args, return_type=return_type,
                                          flags=flags, locals=locs)

            # Check typing error if object mode is used
            if cres.typing_error is not None and not flags.enable_pyobject:
                raise cres.typing_error

            self.add_overload(cres)
            return cres.entry_point
开发者ID:jiaxu825,项目名称:numba,代码行数:32,代码来源:dispatcher.py

示例7: compile

    def compile(self, sig):
        with self._compile_lock:
            args, return_type = sigutils.normalize_signature(sig)
            # Don't recompile if signature already exists
            # (e.g. if another thread compiled it before we got the lock)
            existing = self.overloads.get(tuple(args))
            if existing is not None:
                return existing

            flags = compiler.Flags()
            self.targetdescr.options.parse_as_flags(flags, self.targetoptions)

            cres = compiler.compile_extra(
                self.typingctx,
                self.targetctx,
                self.py_func,
                args=args,
                return_type=return_type,
                flags=flags,
                locals=self.locals,
            )

            # Check typing error if object mode is used
            if cres.typing_error is not None and not flags.enable_pyobject:
                raise cres.typing_error

            self.add_overload(cres)
            return cres.entry_point
开发者ID:ymarfoq,项目名称:outilACVDesagregation,代码行数:28,代码来源:dispatcher.py

示例8: get_pipeline

 def get_pipeline(self, sig, library=None):
     if library is None:
         library = self.library
     args, return_type = sigutils.normalize_signature(sig)
     return compiler.Pipeline(self.typingctx, self.targetctx,
                              self.library, args, return_type,
                              self.flags, self.locals)
开发者ID:jriehl,项目名称:sandbox,代码行数:7,代码来源:despatcher.py

示例9: compile

    def compile(self, sig, locals={}, **targetoptions):
        locs = self.locals.copy()
        locs.update(locals)

        topt = self.targetoptions.copy()
        topt.update(targetoptions)

        flags = compiler.Flags()
        self.targetdescr.options.parse_as_flags(flags, topt)
        flags.set("no_compile")
        flags.set("no_cpython_wrapper")
        flags.set("error_model", "numpy")
        # Disable loop lifting
        # The feature requires a real python function
        flags.unset("enable_looplift")

        typingctx = self.targetdescr.typing_context
        targetctx = self.targetdescr.target_context

        args, return_type = sigutils.normalize_signature(sig)

        cres = compiler.compile_extra(typingctx, targetctx, self.py_func,
                                      args=args, return_type=return_type,
                                      flags=flags, locals=locals)

        self.overloads[cres.signature] = cres
        return cres
开发者ID:Alexhuszagh,项目名称:numba,代码行数:27,代码来源:ufuncbuilder.py

示例10: add

    def add(self, sig=None, argtypes=None, restype=None):
        # Handle argtypes
        if argtypes is not None:
            warnings.warn("Keyword argument argtypes is deprecated",
                          DeprecationWarning)
            assert sig is None
            if restype is None:
                sig = tuple(argtypes)
            else:
                sig = restype(*argtypes)

        # Do compilation
        # Return CompileResult to test
        cres = self.nb_func.compile(sig)

        args, return_type = sigutils.normalize_signature(sig)

        if return_type is None:
            if cres.objectmode:
                # Object mode is used and return type is not specified
                raise TypeError("return type must be specified for object mode")
            else:
                return_type = cres.signature.return_type

        assert return_type != types.pyobject
        sig = return_type(*args)
        # Store the final signature
        self._sigs.append(sig)
        self._cres[sig] = cres
        return cres
开发者ID:pombreda,项目名称:numba,代码行数:30,代码来源:ufuncbuilder.py

示例11: compile

    def compile(self, sig, locals={}, **targetoptions):
        locs = self.locals.copy()
        locs.update(locals)

        topt = self.targetoptions.copy()
        topt.update(targetoptions)

        if topt.get('nopython', True) == False:
            raise TypeError("nopython option must be False")
        topt['nopython'] = True

        flags = compiler.Flags()
        flags.set("no_compile")
        self.targetdescr.options.parse_as_flags(flags, topt)

        typingctx = self.targetdescr.typing_context
        targetctx = self.targetdescr.target_context

        args, return_type = sigutils.normalize_signature(sig)

        cres = compiler.compile_extra(typingctx, targetctx, self.py_func,
                                      args=args, return_type=return_type,
                                      flags=flags, locals=locals)

        self.overloads[cres.signature] = cres
        return cres
开发者ID:B-Rich,项目名称:numba,代码行数:26,代码来源:ufuncbuilder.py

示例12: compile

    def compile(self, sig):
        # Use cache and compiler in a critical section
        with compiler.lock_compiler:
            # Use counter to track recursion compilation depth
            with self._compiling_counter:
                # XXX this is mostly duplicated from Dispatcher.
                flags = self.flags
                args, return_type = sigutils.normalize_signature(sig)

                # Don't recompile if signature already exists
                # (e.g. if another thread compiled it before we got the lock)
                existing = self.overloads.get(tuple(args))
                if existing is not None:
                    return existing.entry_point

                assert not flags.enable_looplift, "Enable looplift flags is on"
                # Clone IR to avoid mutation in rewrite pass
                cloned_func_ir = self.func_ir.copy()
                cres = compiler.compile_ir(typingctx=self.typingctx,
                                           targetctx=self.targetctx,
                                           func_ir=cloned_func_ir,
                                           args=args, return_type=return_type,
                                           flags=flags, locals=self.locals,
                                           lifted=(),
                                           lifted_from=self.lifted_from)

                # Check typing error if object mode is used
                if cres.typing_error is not None and not flags.enable_pyobject:
                    raise cres.typing_error

                self.add_overload(cres)
                return cres.entry_point
开发者ID:yuguen,项目名称:numba,代码行数:32,代码来源:dispatcher.py

示例13: compile

 def compile(self, py_func, sig, library=None):
     if library is None:
         library = self.library
     args, return_type = sigutils.normalize_signature(sig)
     return compiler.compile_extra(self.typingctx, self.targetctx,
                                   py_func, args=args,
                                   return_type=return_type,
                                   flags=self.flags, locals=self.locals,
                                   library=library)
开发者ID:jriehl,项目名称:sandbox,代码行数:9,代码来源:despatcher.py

示例14: export

    def export(self, exported_name, sig):
        """
        Mark a function for exporting in the extension module.
        """
        fn_args, fn_retty = sigutils.normalize_signature(sig)
        sig = typing.signature(fn_retty, *fn_args)
        if exported_name in self._exported_functions:
            raise KeyError("duplicated export symbol %s" % (exported_name))

        def decorator(func):
            entry = ExportEntry(exported_name, sig, func)
            self._exported_functions[exported_name] = entry
            return func

        return decorator
开发者ID:denfromufa,项目名称:numba,代码行数:15,代码来源:cc.py

示例15: __init__

    def __init__(self, pyfunc, signature):
        self.py_func = pyfunc
        self.signature = signature
        self.name = pyfunc.__name__

        args, return_type = sigutils.normalize_signature(signature)
        flags = Flags()
        flags.set('no_compile')
        self._cres = compile_extra(typingctx=impala_typing,
                                   targetctx=impala_targets, func=pyfunc,
                                   args=args, return_type=return_type,
                                   flags=flags, locals={})
        llvm_func = impala_targets.finalize(self._cres.llvm_func, return_type,
                                            args)
        self.llvm_func = llvm_func
        self.llvm_module = llvm_func.module
开发者ID:B-Rich,项目名称:numba,代码行数:16,代码来源:impala.py


注:本文中的numba.sigutils.normalize_signature函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。