提交 92d795e7 authored 作者: James Bergstra's avatar James Bergstra 提交者: Frederic

blas.py - first round opts insert gemv_no_inplace

上级 4c6b567e
...@@ -1417,9 +1417,7 @@ def local_gemm_to_ger(node): ...@@ -1417,9 +1417,7 @@ def local_gemm_to_ger(node):
rval = ger(z, a, xv, yv) rval = ger(z, a, xv, yv)
return [rval] return [rval]
elif bval == 0: # GER on zeros_like should be faster than GEMM elif bval == 0: # GER on zeros_like should be faster than GEMM
zeros = T.alloc( zeros = T.zeros([x.shape[0], y.shape[1]], x.dtype)
numpy.asarray(0, dtype=x.dtype),
x.shape[0], y.shape[1])
rval = ger(zeros, a, xv, yv) rval = ger(zeros, a, xv, yv)
return [rval] return [rval]
else: else:
...@@ -1445,20 +1443,20 @@ def local_dot22_to_ger_or_gemv(node): ...@@ -1445,20 +1443,20 @@ def local_dot22_to_ger_or_gemv(node):
xv = x.dimshuffle(0) xv = x.dimshuffle(0)
yv = y.dimshuffle(1) yv = y.dimshuffle(1)
zeros = T.alloc(numpy.asarray(0, dtype=x.dtype), x.shape[0], y.shape[1]) zeros = T.zeros([x.shape[0], y.shape[1]], dtype=x.dtype)
rval = ger(zeros, one, xv, yv) rval = ger(zeros, one, xv, yv)
return [rval] return [rval]
if xb[0] and not yb[0] and not yb[1]: if xb[0] and not yb[0] and not yb[1]:
# x is vector, y is matrix so try gemv # x is vector, y is matrix so try gemv
xv = x.dimshuffle(1) xv = x.dimshuffle(1)
zeros = T.alloc(numpy.asarray(0, dtype=x.dtype), y.shape[1]) zeros = T.zeros([y.shape[1]], x.dtype)
rval = gemv_inplace(zeros, one, y.T, xv, one) rval = gemv_no_inplace(zeros, one, y.T, xv, one)
return [rval.dimshuffle('x', 0)] return [rval.dimshuffle('x', 0)]
if not xb[0] and not xb[1] and yb[1]: if not xb[0] and not xb[1] and yb[1]:
# x is matrix, y is vector, try gemv # x is matrix, y is vector, try gemv
yv = y.dimshuffle(0) yv = y.dimshuffle(0)
zeros = T.alloc(numpy.asarray(0, dtype=x.dtype), x.shape[0]) zeros = T.zeros([x.shape[0]], dtype=x.dtype)
rval = gemv_inplace(zeros, one, x, yv, one) rval = gemv_no_inplace(zeros, one, x, yv, one)
return [rval.dimshuffle(0, 'x')] return [rval.dimshuffle(0, 'x')]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论