本文整理汇总了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)
示例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)
示例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()
示例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)
示例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)
示例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)
示例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
示例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
示例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()
示例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)
示例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)
示例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)
示例13: next
def next(self, i):
self.array.data = cgutils.pointer_add(self.builder,
self.array.data, self.core_step)
示例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)
示例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)