• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python cgutils.pointer_add函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: load_direct

 def load_direct(self, byteoffset):
     """
     Generic load from the given *byteoffset*.  load_aligned() is
     preferred if possible.
     """
     ptr = cgutils.pointer_add(self.builder, self.dataptr, byteoffset)
     return self.context.unpack_value(self.builder, self.fe_type, ptr)
开发者ID:MatthieuDartiailh,项目名称:numba,代码行数:7,代码来源:wrappers.py


示例2: access_member

 def access_member(member_offset):
     # Access member by byte offset
     offset = c.context.get_constant(types.uintp, member_offset)
     llvoidptr = ir.IntType(8).as_pointer()
     ptr = cgutils.pointer_add(c.builder, val, offset)
     casted = c.builder.bitcast(ptr, llvoidptr.as_pointer())
     return c.builder.load(casted)
开发者ID:FedericoStra,项目名称:numba,代码行数:7,代码来源:boxing.py


示例3: get_array_at_offset

    def get_array_at_offset(self, ind):
        context = self.context
        builder = self.builder

        arytyp = types.Array(dtype=self.dtype, ndim=self.ndim, layout="A")
        arycls = context.make_array(arytyp)

        array = arycls(context, builder)
        offseted_data = cgutils.pointer_add(self.builder,
                                            self.data,
                                            self.builder.mul(self.core_step,
                                                             ind))
        if not self.as_scalar:
            shape = cgutils.pack_array(builder, self.shape)
            strides = cgutils.pack_array(builder, self.strides)
        else:
            one = context.get_constant(types.intp, 1)
            zero = context.get_constant(types.intp, 0)
            shape = cgutils.pack_array(builder, [one])
            strides = cgutils.pack_array(builder, [zero])

        itemsize = context.get_abi_sizeof(context.get_data_type(self.dtype))
        context.populate_array(array,
                               data=builder.bitcast(offseted_data,
                                                    array.data.type),
                               shape=shape,
                               strides=strides,
                               itemsize=context.get_constant(types.intp,
                                                             itemsize),
                               meminfo=None)

        return array._getvalue()
开发者ID:GaZ3ll3,项目名称:numba,代码行数:32,代码来源:wrappers.py


示例4: iternext_specific

            def iternext_specific(self, context, builder, arrty, arr, result):
                zero = context.get_constant(types.intp, 0)
                one = context.get_constant(types.intp, 1)

                ndim = arrty.ndim
                nitems = arr.nitems

                index = builder.load(self.index)
                is_valid = builder.icmp(lc.ICMP_SLT, index, nitems)
                result.set_valid(is_valid)

                with cgutils.if_likely(builder, is_valid):
                    ptr = builder.load(self.pointer)
                    value = context.unpack_value(builder, arrty.dtype, ptr)
                    if kind == 'flat':
                        result.yield_(value)
                    else:
                        # ndenumerate(): fetch and increment indices
                        indices = self.indices
                        idxvals = [builder.load(cgutils.gep(builder, indices, dim))
                                   for dim in range(ndim)]
                        idxtuple = cgutils.pack_array(builder, idxvals)
                        result.yield_(
                            cgutils.make_anonymous_struct(builder, [idxtuple, value]))
                        _increment_indices_array(context, builder, arrty, arr, indices)

                    index = builder.add(index, one)
                    builder.store(index, self.index)
                    ptr = cgutils.pointer_add(builder, ptr, self.stride)
                    builder.store(ptr, self.pointer)
开发者ID:PierreBizouard,项目名称:numba,代码行数:30,代码来源:arrayobj.py


示例5: get_generator_state

 def get_generator_state(self, builder, genptr, return_type):
     """
     From the given *genptr* (a pointer to a _dynfunc.Generator object),
     get a pointer to its state area.
     """
     return cgutils.pointer_add(
         builder, genptr, _dynfunc._impl_info['offsetof_generator_state'],
         return_type=return_type)
开发者ID:digideskio,项目名称:numba,代码行数:8,代码来源:cpu.py


示例6: get_env_body

 def get_env_body(self, builder, envptr):
     """
     From the given *envptr* (a pointer to a _dynfunc.Environment object),
     get a EnvBody allowing structured access to environment fields.
     """
     body_ptr = cgutils.pointer_add(
         builder, envptr, _dynfunc._impl_info['offset_env_body'])
     return EnvBody(self, builder, ref=body_ptr, cast_ref=True)
开发者ID:johandroid,项目名称:numba,代码行数:8,代码来源:cpu.py


示例7: get_env_from_closure

 def get_env_from_closure(self, builder, clo):
     """
     From the pointer *clo* to a _dynfunc.Closure, get a pointer
     to the enclosed _dynfunc.Environment.
     """
     clo_body_ptr = cgutils.pointer_add(
         builder, clo, _dynfunc._impl_info['offset_closure_body'])
     clo_body = ClosureBody(self, builder, ref=clo_body_ptr, cast_ref=True)
     return clo_body.env
开发者ID:johandroid,项目名称:numba,代码行数:9,代码来源:cpu.py


示例8: get_env_from_closure

    def get_env_from_closure(self, builder, clo):
        """
        From the pointer *clo* to a _dynfunc.Closure, get a pointer
        to the enclosed _dynfunc.Environment.
        """
        with cgutils.if_unlikely(builder, cgutils.is_null(builder, clo)):
            self.debug_print(builder, "Fatal error: missing _dynfunc.Closure")
            builder.unreachable()

        clo_body_ptr = cgutils.pointer_add(
            builder, clo, _dynfunc._impl_info['offsetof_closure_body'])
        clo_body = ClosureBody(self, builder, ref=clo_body_ptr, cast_ref=True)
        return clo_body.env
开发者ID:digideskio,项目名称:numba,代码行数:13,代码来源:cpu.py


示例9: load

    def load(self, context, builder, data, ind):
        arytyp = types.Array(dtype=self.dtype, ndim=self.ndim, layout="A")
        arycls = context.make_array(arytyp)

        array = arycls(context, builder)
        offseted_data = cgutils.pointer_add(builder,
                                            data,
                                            builder.mul(self.core_step,
                                                        ind))

        shape, strides = self._shape_and_strides(context, builder)

        itemsize = context.get_abi_sizeof(context.get_data_type(self.dtype))
        context.populate_array(array,
                               data=builder.bitcast(offseted_data,
                                                    array.data.type),
                               shape=shape,
                               strides=strides,
                               itemsize=context.get_constant(types.intp,
                                                             itemsize),
                               meminfo=None)

        return array._getvalue()
开发者ID:MatthieuDartiailh,项目名称:numba,代码行数:23,代码来源:wrappers.py


示例10: load_direct

 def load_direct(self, byteoffset):
     ptr = cgutils.pointer_add(self.builder, self.dataptr, byteoffset)
     return self.context.unpack_value(self.builder, self.fe_type, ptr)
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:3,代码来源:wrappers.py


示例11: store_direct

 def store_direct(self, value, offset):
     ptr = cgutils.pointer_add(self.builder, self.data, offset)
     assert ptr.type.pointee == value.type
     self.builder.store(value, ptr)
开发者ID:genba,项目名称:numba,代码行数:4,代码来源:wrappers.py


示例12: load_direct

 def load_direct(self, offset):
     ptr = cgutils.pointer_add(self.builder, self.data, offset)
     if self.byref:
         return ptr
     else:
         return self.builder.load(ptr)
开发者ID:genba,项目名称:numba,代码行数:6,代码来源:wrappers.py


示例13: next

 def next(self, i):
     self.array.data = cgutils.pointer_add(self.builder,
                                           self.array.data, self.core_step)
开发者ID:genba,项目名称:numba,代码行数:3,代码来源:wrappers.py


示例14: store_direct

 def store_direct(self, value, byteoffset):
     ptr = cgutils.pointer_add(self.builder, self.dataptr, byteoffset)
     self.context.pack_value(self.builder, self.fe_type, value, ptr)
开发者ID:MatthieuDartiailh,项目名称:numba,代码行数:3,代码来源:wrappers.py


示例15: set_member

 def set_member(member_offset, value):
     # Access member by byte offset
     offset = c.context.get_constant(types.uintp, member_offset)
     ptr = cgutils.pointer_add(c.builder, box, offset)
     casted = c.builder.bitcast(ptr, llvoidptr.as_pointer())
     c.builder.store(value, casted)
开发者ID:FedericoStra,项目名称:numba,代码行数:6,代码来源:boxing.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cgutils.unpack_tuple函数代码示例发布时间:2022-05-27
下一篇:
Python cgutils.pack_array函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap