Skip to content

Commit 67eec46

Browse files
committed
fix: rely on compiler
1 parent 451c587 commit 67eec46

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

numba_cuda/numba/cuda/mathimpl.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
unarys += [("floor", "floorf", math.floor)]
2727
unarys += [("fabs", "fabsf", math.fabs)]
2828
unarys += [("exp", "expf", math.exp)]
29+
if sys.version_info >= (3, 11):
30+
unarys += [("exp2", "exp2f", math.exp2)]
2931
unarys += [("expm1", "expm1f", math.expm1)]
3032
unarys += [("erf", "erff", math.erf)]
3133
unarys += [("erfc", "erfcf", math.erfc)]
@@ -332,33 +334,6 @@ def tanhf_impl_fastmath():
332334
impl_unary_int(math.tanh, uint64, libdevice.tanh)
333335

334336

335-
if sys.version_info >= (3, 11):
336-
def impl_exp2(ty, libfunc):
337-
def lower_exp2_impl(context, builder, sig, args):
338-
def exp2_impl_inline_asm():
339-
fnty = ir.FunctionType(ir.FloatType(), [ir.FloatType()])
340-
if context.fastmath:
341-
asm = ir.InlineAsm(fnty, "ex2.approx.ftz.f32 $0, $1;", "=f,f")
342-
else:
343-
asm = ir.InlineAsm(fnty, "ex2.approx.f32 $0, $1;", "=f,f")
344-
return builder.call(asm, args)
345-
346-
if ty == float32:
347-
return exp2_impl_inline_asm()
348-
else:
349-
exp2_sig = typing.signature(ty, ty)
350-
libfunc_impl = context.get_function(libfunc, exp2_sig)
351-
return libfunc_impl(builder, args)
352-
353-
lower(math.exp2, ty)(lower_exp2_impl)
354-
355-
impl_exp2(types.float32, libdevice.exp2f)
356-
impl_exp2(types.float64, libdevice.exp2)
357-
358-
impl_unary_int(math.exp2, int64, libdevice.exp2)
359-
impl_unary_int(math.exp2, uint64, libdevice.exp2)
360-
361-
362337
# Complex power implementations - translations of _Py_c_pow from CPython
363338
# https://github.com/python/cpython/blob/a755410e054e1e2390de5830befc08fe80706c66/Objects/complexobject.c#L123-L151
364339
#

0 commit comments

Comments
 (0)