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

CGemv handles 0-size arguments properly.

上级 b3aa3073
......@@ -332,7 +332,7 @@ def gemv_c_code(aa, xx, yy, zz, alpha, beta, destructive, fail):
int Sz = %(zz)s->strides[0] / elemsize;
int Sy = %(yy)s->strides[0] / elemsize;
if (1)
if (Nx0 * Nx1)
{
if (%(xx)s->strides[0] == elemsize)
{
......@@ -398,7 +398,18 @@ def gemv_c_code(aa, xx, yy, zz, alpha, beta, destructive, fail):
// pair of for loops.
assert (0);
}
} // if(1)
}
else if (dbeta != 1.0)
{
// the matrix has at least one dim of length 0
// so we do this loop, which either iterates over 0 elements
// or else it does the right thing for length-0 x.
dtype_%(zz)s * zptr = (dtype_%(zz)s*)(%(zz)s->data);
for (int i = 0; i < Nx0; ++i)
{
zptr[i * Sz] *= dbeta;
}
}
}
""" % locals()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论