def Tdot(self, fn, dtype):
from pyculib.blas.binding import cuBlas
x = np.random.random(10).astype(dtype)
y = np.random.random(10).astype(dtype)
d_x = cuda.to_device(x)
d_y = cuda.to_device(y)
blas = cuBlas()
got = getattr(blas, fn)(x.size, d_x, 1, d_y, 1)
if fn.endswith('c'):
exp = np.vdot(x, y)
else:
exp = np.dot(x, y)
self.assertTrue(np.allclose(got, exp))
评论列表
文章目录