示例#1
0
 def test_gemm_out(self, dtype):
     dtype = numpy.dtype(dtype)
     tol = self._tol[dtype.char.lower()]
     m, n, k = self.mnk
     a = self._make_matrix(m, k, self.transa, self.ordera, dtype)
     b = self._make_matrix(k, n, self.transb, self.orderb, dtype)
     c = self._make_matrix(m, n, 'N', self.orderc, dtype)
     alpha = 0.9
     beta = 0.8
     if dtype.char in 'FD':
         alpha = alpha - 1j * 0.7
         beta = beta - 1j * 0.6
     aa = self._trans_matrix(a, self.transa)
     bb = self._trans_matrix(b, self.transb)
     ref = alpha * aa.dot(bb) + beta * c
     if self.mode is not None:
         alpha = self.mode.array(alpha)
         beta = self.mode.array(beta)
     cublas.gemm(self.transa,
                 self.transb,
                 a,
                 b,
                 out=c,
                 alpha=alpha,
                 beta=beta)
     cupy.testing.assert_allclose(c, ref, rtol=tol, atol=tol)
示例#2
0
 def test_gemm(self, dtype):
     if not (self.mode is None and self.orderc == 'C'):
         pytest.skip()
     dtype = numpy.dtype(dtype)
     tol = self._tol[dtype.char.lower()]
     m, n, k = self.mnk
     a = self._make_matrix(m, k, self.transa, self.ordera, dtype)
     b = self._make_matrix(k, n, self.transb, self.orderb, dtype)
     aa = self._trans_matrix(a, self.transa)
     bb = self._trans_matrix(b, self.transb)
     ref = aa.dot(bb)
     c = cublas.gemm(self.transa, self.transb, a, b)
     cupy.testing.assert_allclose(c, ref, rtol=tol, atol=tol)