/usr/local/lib64/python3.6/site-packages/torch/include/ATen/cuda
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/ATen/cuda/CUDABlas.h (11001B)
#pragma once
/*
Provides a subset of CUDA BLAS functions as templates:
gemm
(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c,
ldc)
gemv(transa, m, n, alpha, a, lda, x, incx, beta, y, incy)
dot(n, x, incx, y, incy, result)
where Dtype is double, float, at::Half or at::BFloat16 (ROCm, NOT for dot).
The functions are available in at::cuda::blas namespace.
*/
#include
namespace at {
namespace cuda {
namespace blas {
// RAII guard that sets the CuBLAS pointer mode and restores it to
// its previous value when the guard is destroyed
class PointerModeGuard {
public:
PointerModeGuard(cublasHandle_t handle, cublasPointerMode_t mode) :
handle(handle) {
TORCH_CUDABLAS_CHECK(cublasGetPointerMode(handle, &previous_mode));
TORCH_CUDABLAS_CHECK(cublasSetPointerMode(handle, mode));
}
~PointerModeGuard() {
cublasSetPointerMode(handle, previous_mode);
}
private:
cublasHandle_t handle;
cublasPointerMode_t previous_mode;
};
/* LEVEL 3 BLAS FUNCTIONS */
#define CUDABLAS_GEMM_ARGTYPES(Dtype) \
char transa, char transb, int64_t m, int64_t n, int64_t k, Dtype alpha, \
const Dtype *a, int64_t lda, const Dtype *b, int64_t ldb, Dtype beta, \
Dtype *c, int64_t ldc
template
inline void gemm(CUDABLAS_GEMM_ARGTYPES(Dtype)) {
AT_ERROR("at::cuda::blas::gemm: not implemented for ", typeid(Dtype).name());
}
template <>
void gemm(CUDABLAS_GEMM_ARGTYPES(double));
template <>
void gemm(CUDABLAS_GEMM_ARGTYPES(float));
#if !defined(__HIP_PLATFORM_HCC__) || (defined(__HIP_PLATFORM_HCC__) && TORCH_HIP_VERSION >= 210)
template <>
void gemm>(CUDABLAS_GEMM_ARGTYPES(c10::complex));
#endif
#if !defined(__HIP_PLATFORM_HCC__) || (defined(__HIP_PLATFORM_HCC__) && TORCH_HIP_VERSION >= 210)
template <>
void gemm>(CUDABLAS_GEMM_ARGTYPES(c10::complex));
#endif
template <>
void gemm(CUDABLAS_GEMM_ARGTYPES(at::Half));
#if defined(__HIP_PLATFORM_HCC__) || defined(CUDA_VERSION) && CUDA_VERSION >= 11000
template <>
void gemm(CUDABLAS_GEMM_ARGTYPES(at::BFloat16));
#endif
#define CUDABLAS_BGEMM_ARGTYPES(Dtype) \
char transa, char transb, int64_t m, int64_t n, int64_t k, Dtype alpha, \
const Dtype *a, int64_t lda, int64_t stridea, \
const Dtype *b, int64_t ldb, int64_t strideb, \
Dtype beta, Dtype *c, int64_t ldc, int64_t stridec, int64_t num_batches
template
inline void bgemm(CUDABLAS_BGEMM_ARGTYPES(Dtype)) {
AT_ERROR("at::cuda::blas::bgemm: not implemented for ", typeid(Dtype).name());
}
template <>
void bgemm(CUDABLAS_BGEMM_ARGTYPES(double));
template <>
void bgemm(CUDABLAS_BGEMM_ARGTYPES(float));
template <>
void bgemm>(CUDABLAS_BGEMM_ARGTYPES(c10::complex));
template <>
void bgemm>(CUDABLAS_BGEMM_ARGTYPES(c10::complex));
template <>
void bgemm(CUDABLAS_BGEMM_ARGTYPES(at::Half));
#if defined(__HIP_PLATFORM_HCC__) || defined(CUDA_VERSION) && CUDA_VERSION >= 11000
template <>
void bgemm(CUDABLAS_BGEMM_ARGTYPES(at::BFloat16));
#endif
#define CUDABLAS_TRSM_ARGTYPES(Dtype) \
cublasHandle_t handle, cublasSideMode_t side, cublasFillMode_t uplo, \
cublasOperation_t trans, cublasDiagType_t diag, int m, int n, \
const Dtype *alpha, const Dtype *A, int lda, Dtype *B, int ldb
template
inline void trsm(CUDABLAS_TRSM_ARGTYPES(Dtype)) {
TORCH_INTERNAL_ASSERT(false, "at::cuda::blas::trsm: not implemented for ", typeid(Dtype).name());
}
template <>
void trsm(CUDABLAS_TRSM_ARGTYPES(float));
template <>
void trsm(CUDABLAS_TRSM_ARGTYPES(double));
template <>
void trsm>(CUDABLAS_TRSM_ARGTYPES(c10::complex));
template <>
void trsm>(CUDABLAS_TRSM_ARGTYPES(c10::complex));
#define CUDABLAS_TRSM_BATCHED_ARGTYPES(Dtype) \
cublasHandle_t handle, cublasSideMode_t side, cublasFillMode_t uplo, \
cublasOperation_t trans, cublasDiagType_t diag, int m, int n, \
const Dtype *alpha, Dtype *A[], int lda, Dtype *B[], int ldb, \
int batchCount
template
inline void trsmBatched(CUDABLAS_TRSM_BATCHED_ARGTYPES(Dtype)) {
TORCH_INTERNAL_ASSERT(
false,
"at::cuda::blas::trsmBatched: not implemented for ",
typeid(Dtype).name());
}
template <>
void trsmBatched(CUDABLAS_TRSM_BATCHED_ARGTYPES(float));
template <>
void trsmBatched(CUDABLAS_TRSM_BATCHED_ARGTYPES(double));
template <>
void trsmBatched>(CUDABLAS_TRSM_BATCHED_ARGTYPES(c10::complex));
template <>
void trsmBatched>(CUDABLAS_TRSM_BATCHED_ARGTYPES(c10::complex));
/* LEVEL 2 BLAS FUNCTIONS */
#define CUDABLAS_GEMV_ARGTYPES(Dtype) \
char trans, int64_t m, int64_t n, Dtype alpha, const Dtype *a, int64_t lda, \
const Dtype *x, int64_t incx, Dtype beta, Dtype *y, int64_t incy
template
inline void gemv(CUDABLAS_GEMV_ARGTYPES(Dtype)) {
AT_ERROR("at::cuda::blas::gemv: not implemented for ", typeid(Dtype).name());
}
template <>
void gemv(CUDABLAS_GEMV_ARGTYPES(double));
template <>
void gemv(CUDABLAS_GEMV_ARGTYPES(float));
#if !defined(__HIP_PLATFORM_HCC__) || (defined(__HIP_PLATFORM_HCC__) && TORCH_HIP_VERSION >= 210)
template <>
void gemv>(CUDABLAS_GEMV_ARGTYPES(c10::complex));
template <>
void gemv>(CUDABLAS_GEMV_ARGTYPES(c10::complex));
#endif
template <>
void gemv(CUDABLAS_GEMV_ARGTYPES(at::Half));
#if defined(__HIP_PLATFORM_HCC__) || defined(CUDA_VERSION) && CUDA_VERSION >= 11000
template <>
void gemv(CUDABLAS_GEMV_ARGTYPES(at::BFloat16));
#endif
/* LEVEL 1 BLAS FUNCTIONS */
#define CUDABLAS_DOT_ARGTYPES(Dtype) \
cublasHandle_t handle, int n, const Dtype *x, int incx, const Dtype *y, \
int incy, Dtype *result
template
inline void dot(CUDABLAS_DOT_ARGTYPES(Dtype)) {
AT_ERROR("at::cuda::blas::dot: not implemented for ", typeid(Dtype).name());
}
template <>
void dot(CUDABLAS_DOT_ARGTYPES(double));
template <>
void dot(CUDABLAS_DOT_ARGTYPES(float));
template <>
void dot(CUDABLAS_DOT_ARGTYPES(at::Half));
template <>
void dot(CUDABLAS_DOT_ARGTYPES(at::BFloat16));
template <>
void dot>(CUDABLAS_DOT_ARGTYPES(c10::complex));
template <>
void dot>(CUDABLAS_DOT_ARGTYPES(c10::complex));
template
inline void vdot(CUDABLAS_DOT_ARGTYPES(Dtype)) {
AT_ERROR("at::cuda::blas::vdot: not implemented for ", typeid(Dtype).name());
}
template <>
void vdot>(CUDABLAS_DOT_ARGTYPES(c10::complex));
template <>
void vdot>(CUDABLAS_DOT_ARGTYPES(c10::complex));
// This guards blocks use of getrsBatched, geqrfBatched, getrfBatched, getriBatched on platforms other than cuda
#ifdef CUDART_VERSION
#define CUDABLAS_GETRS_ARGTYPES(Dtype) \
cublasHandle_t handle, cublasOperation_t trans, \
int n, int nrhs, Dtype** dA_array, int lda, int* ipiv_array, \
Dtype** dB_array, int ldb, int* info_array, int batchsize
template
void getrsBatched(CUDABLAS_GETRS_ARGTYPES(Dtype)) {
TORCH_INTERNAL_ASSERT(false, "at::cuda::blas::getrsBatched: not implemented for ",
typeid(Dtype).name());
}
template<>
void getrsBatched(CUDABLAS_GETRS_ARGTYPES(float));
template<>
void getrsBatched(CUDABLAS_GETRS_ARGTYPES(double));
template<>
void getrsBatched>(CUDABLAS_GETRS_ARGTYPES(c10::complex));
template<>
void getrsBatched>(CUDABLAS_GETRS_ARGTYPES(c10::complex));
#define CUDABLAS_GEQRF_BATCHED_ARGTYPES(Dtype) \
cublasHandle_t handle, int m, int n, Dtype **A_array, int lda, \
Dtype **tau_array, int *info, int batchsize
template
void geqrfBatched(CUDABLAS_GEQRF_BATCHED_ARGTYPES(Dtype)) {
TORCH_INTERNAL_ASSERT(
false,
"at::cuda::blas::geqrfBatched: not implemented for ",
typeid(Dtype).name());
}
template <>
void geqrfBatched(CUDABLAS_GEQRF_BATCHED_ARGTYPES(float));
template <>
void geqrfBatched(CUDABLAS_GEQRF_BATCHED_ARGTYPES(double));
template <>
void geqrfBatched>(
CUDABLAS_GEQRF_BATCHED_ARGTYPES(c10::complex));
template <>
void geqrfBatched>(
CUDABLAS_GEQRF_BATCHED_ARGTYPES(c10::complex));
#define CUDABLAS_GETRF_ARGTYPES(Dtype) \
int n, Dtype** dA_array, int ldda, int* ipiv_array, int* info_array, int batchsize
template
void getrfBatched(CUDABLAS_GETRF_ARGTYPES(Dtype)) {
TORCH_CHECK(false, "at::cuda::blas::getrfBatched: not implemented for ", typeid(Dtype).name());
}
template<>
void getrfBatched(CUDABLAS_GETRF_ARGTYPES(float));
template<>
void getrfBatched(CUDABLAS_GETRF_ARGTYPES(double));
template<>
void getrfBatched>(CUDABLAS_GETRF_ARGTYPES(c10::complex));
template<>
void getrfBatched>(CUDABLAS_GETRF_ARGTYPES(c10::complex));
#define CUDABLAS_GETRI_ARGTYPES(Dtype) \
int n, Dtype** dA_array, int ldda, int* ipiv_array, Dtype** dC_array, int lddc, int* info_array, int batchsize
template
void getriBatched(CUDABLAS_GETRI_ARGTYPES(Dtype)) {
TORCH_CHECK(false, "at::cuda::blas::getriBatched: not implemented for ", typeid(Dtype).name());
}
template<>
void getriBatched(CUDABLAS_GETRI_ARGTYPES(float));
template<>
void getriBatched(CUDABLAS_GETRI_ARGTYPES(double));
template<>
void getriBatched>(CUDABLAS_GETRI_ARGTYPES(c10::complex));
template<>
void getriBatched>(CUDABLAS_GETRI_ARGTYPES(c10::complex));
#define CUDABLAS_GELS_BATCHED_ARGTYPES(Dtype) \
cublasHandle_t handle, cublasOperation_t trans, int m, int n, int nrhs, Dtype** dA_array, int ldda, Dtype** dC_array, int lddc, int* info, int *devInfoArray, int batchSize
template
void gelsBatched(CUDABLAS_GELS_BATCHED_ARGTYPES(Dtype)) {
TORCH_INTERNAL_ASSERT(false, "at::cuda::blas::gelsBatched: not implemented for ", typeid(Dtype).name());
}
template<>
void gelsBatched(CUDABLAS_GELS_BATCHED_ARGTYPES(double));
template<>
void gelsBatched(CUDABLAS_GELS_BATCHED_ARGTYPES(float));
template<>
void gelsBatched>(CUDABLAS_GELS_BATCHED_ARGTYPES(c10::complex));
template<>
void gelsBatched>(CUDABLAS_GELS_BATCHED_ARGTYPES(c10::complex));
#endif // CUDART_VERSION
} // namespace blas
} // namespace cuda
} // namespace at