提交 de3a411b authored 作者: Frederic Bastien's avatar Frederic Bastien

Make erfinv on CPU fast by using scipy as nfunc. We need to do this for other scipy elemwise too.

上级 404cea07
......@@ -2357,7 +2357,7 @@ def erfcx(a):
"""scaled complementary error function"""
@_scal_elemwise
@_scal_elemwise_with_nfunc('scipy.special.erfinv', 1, 1)
def erfinv(a):
"""inverse error function"""
......
......@@ -401,7 +401,14 @@ second dimension
nfunc_spec = getattr(scalar_op, 'nfunc_spec', None)
self.nfunc_spec = nfunc_spec
if nfunc_spec:
self.nfunc = getattr(np, nfunc_spec[0])
self.nfunc = getattr(np, nfunc_spec[0], None)
if self.nfunc is None:
# Not inside NumPy. So probably another package like scipy.
symb = 'scipy.special.erfinv'.split(".")
module = __import__('.'.join(symb[:-1]))
for sub in symb[1:-1]:
module = getattr(module, sub)
self.nfunc = getattr(module, symb[-1])
super(Elemwise, self).__init__(openmp=openmp)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论