File size: 577 Bytes
3662621 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | from cupy import _core
def create_math_ufunc(math_name, nargs, name, doc, support_complex=True):
assert 1 <= nargs <= 2
if nargs == 1:
types = ('e->e', 'f->f', 'd->d')
if support_complex:
types += ('F->F', 'D->D')
return _core.create_ufunc(
name, types, 'out0 = %s(in0)' % math_name, doc=doc)
else:
types = ('ee->e', 'ff->f', 'dd->d')
if support_complex:
types += ('FF->F', 'DD->D')
return _core.create_ufunc(
name, types, 'out0 = %s(in0, in1)' % math_name, doc=doc)
|