| 1751 | } |
| 1752 | |
| 1753 | bool CUDABlas::DoBlasGemm( |
| 1754 | Stream *stream, blas::Transpose transa, |
| 1755 | blas::Transpose transb, uint64 m, uint64 n, uint64 k, |
| 1756 | float alpha, const DeviceMemory<Eigen::half> &a, int lda, |
| 1757 | const DeviceMemory<Eigen::half> &b, int ldb, float beta, |
| 1758 | DeviceMemory<Eigen::half> *c, int ldc) { |
| 1759 | cublasMath_t math_type = CUBLAS_DEFAULT_MATH; |
| 1760 | |
| 1761 | #if CUDA_VERSION < 11000 |
| 1762 | math_type = CUBLAS_TENSOR_OP_MATH; |
| 1763 | #endif |
| 1764 | |
| 1765 | VLOG(1) << absl::StrFormat( |
| 1766 | "doing cuBLAS SGEMM: at=%d bt=%d m=%u n=%u " |
| 1767 | "k=%u alpha=%f a=%p lda=%d b=%p ldb=%d beta=%f " |
| 1768 | "c=%p ldc=%d", |
| 1769 | static_cast<int>(transa), static_cast<int>(transb), m, n, k, alpha, |
| 1770 | a.opaque(), lda, b.opaque(), ldb, beta, c->opaque(), ldc); |
| 1771 | if (transa == blas::Transpose::kNoTranspose) { |
| 1772 | if (lda < static_cast<int64>(m)) { |
| 1773 | LOG(WARNING) << "GEMM lda was smaller than m (no transpose case); " |
| 1774 | "precondition violation"; |
| 1775 | } |
| 1776 | } else { |
| 1777 | if (lda < static_cast<int64>(k)) { |
| 1778 | LOG(WARNING) << "GEMM lda (" << lda << ") was smaller than k (" << k |
| 1779 | << ") (transpose case); precondition violation"; |
| 1780 | } |
| 1781 | } |
| 1782 | if (transb == blas::Transpose::kNoTranspose) { |
| 1783 | if (ldb < static_cast<int64>(k)) { |
| 1784 | LOG(WARNING) << "GEMM ldb (" << ldb << ") was smaller than k (" << k |
| 1785 | << ") (no transpose case); precondition violation"; |
| 1786 | } |
| 1787 | } else { |
| 1788 | if (ldb < static_cast<int64>(n)) { |
| 1789 | LOG(WARNING) << "GEMM ldb was smaller than n (transpose case); " |
| 1790 | "precondition violation"; |
| 1791 | } |
| 1792 | } |
| 1793 | |
| 1794 | #if CUDA_VERSION < 7050 |
| 1795 | LOG(ERROR) << "fp16 sgemm is not implemented in this cuBLAS version " |
| 1796 | << "(need at least CUDA 7.5)"; |
| 1797 | return false; |
| 1798 | #endif |
| 1799 | |
| 1800 | return DoBlasInternalImpl<Eigen::half>( |
| 1801 | cublasSgemmEx, stream, true /* = pointer_mode_host */, |
| 1802 | true /* = err_on_failure= */, CUDABlasTranspose(transa), |
| 1803 | CUDABlasTranspose(transb), m, n, k, &alpha, GpuMemory(a), |
| 1804 | SE_CUDA_DATA_HALF, lda, GpuMemory(b), SE_CUDA_DATA_HALF, ldb, &beta, |
| 1805 | GpuMemoryMutable(c), SE_CUDA_DATA_HALF, ldc); |
| 1806 | } |
| 1807 | |
| 1808 | bool CUDABlas::DoBlasGemm(Stream *stream, blas::Transpose transa, |
| 1809 | blas::Transpose transb, uint64 m, uint64 n, uint64 k, |
nothing calls this directly
no test coverage detected