本文整理汇总了Python中numba.extending方法的典型用法代码示例。如果您正苦于以下问题:Python numba.extending方法的具体用法?Python numba.extending怎么用?Python numba.extending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numba
的用法示例。
在下文中一共展示了numba.extending方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_class_init
# 需要导入模块: import numba [as 别名]
# 或者: from numba import extending [as 别名]
def do_class_init(cls):
"""
Register generic method implementation.
"""
# this line is changed for __call__
@numba.extending.lower_builtin(cls.key, cls.key, types.VarArg(types.Any))
def method_impl(context, builder, sig, args):
typ = sig.args[0]
typing_context = context.typing_context
fnty = cls._get_function_type(typing_context, typ)
sig = cls._get_signature(typing_context, fnty, sig.args, {})
call = context.get_function(fnty, sig)
# Link dependent library
context.add_linking_libs(getattr(call, 'libs', ()))
return call(builder, args)
示例2: _resolve
# 需要导入模块: import numba [as 别名]
# 或者: from numba import extending [as 别名]
def _resolve(self, typ, attr):
if self._attr != attr:
return None
assert isinstance(typ, self.key)
class MethodTemplate(AbstractTemplate):
key = self.key # this line is changed for __call__
_inline = self._inline
_overload_func = staticmethod(self._overload_func)
_inline_overloads = self._inline_overloads
def generic(_, args, kws):
args = (typ,) + tuple(args)
fnty = self._get_function_type(self.context, typ)
sig = self._get_signature(self.context, fnty, args, kws)
sig = sig.replace(pysig=numba.extending.utils.pysignature(self._overload_func))
for template in fnty.templates:
self._inline_overloads.update(template._inline_overloads)
if sig is not None:
return sig.as_method()
return types.BoundFunction(MethodTemplate, typ)
示例3: is_alloc_callname
# 需要导入模块: import numba [as 别名]
# 或者: from numba import extending [as 别名]
def is_alloc_callname(func_name, mod_name):
"""
return true if function represents an array creation call
"""
return isinstance(mod_name, str) and ((mod_name == 'numpy'
and func_name in np_alloc_callnames)
or (func_name == 'empty_inferred'
and mod_name in ('numba.extending', 'numba.unsafe.ndarray'))
or (func_name == 'pre_alloc_string_array'
and mod_name == 'sdc.str_arr_ext')
or (func_name in ('alloc_str_list', 'alloc_list_list_str')
and mod_name == 'sdc.str_ext'))
示例4: overload_call
# 需要导入模块: import numba [as 别名]
# 或者: from numba import extending [as 别名]
def overload_call(typ, **kwargs):
def decorate(overload_func):
template = make_overload_attribute_template(
typ, '__call__', overload_func,
inline=kwargs.get('inline', 'never'),
base=_OverloadCallTemplate
)
numba.extending.infer_getattr(template)
numba.extending.overload(overload_func, **kwargs)(overload_func)
return overload_func
return decorate
示例5: value_type
# 需要导入模块: import numba [as 别名]
# 或者: from numba import extending [as 别名]
def value_type(self):
return self._scalar_type[:]
# The docs say we should use register a function to determine the numba type
# with `@numba.extending.typeof_impl.register(MultiVector)`, but this is way
# too slow (https://github.com/numba/numba/issues/5839). Instead, we use the
# undocumented `_numba_type_` attribute, and use our own cache. In future
# this may need to be a weak cache, but for now the objects are tiny anyway.