cublas_wrappers.h 3.2 KB
Newer Older
aiss's avatar
aiss committed
1
2
3
4
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0

// DeepSpeed Team
aiss's avatar
aiss committed
5

6
7
8
9
10
11
12
#pragma once

#include <assert.h>
#include <cublas_v2.h>
#include <cuda.h>
#include <cuda_fp16.h>
#include <cuda_runtime.h>
aiss's avatar
aiss committed
13
#ifndef __HIP_PLATFORM_HCC__
14
#include <mma.h>
aiss's avatar
aiss committed
15
#endif
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>

int cublas_gemm_ex(cublasHandle_t handle,
                   cublasOperation_t transa,
                   cublasOperation_t transb,
                   int m,
                   int n,
                   int k,
                   const float* alpha,
                   const float* beta,
                   const float* A,
                   const float* B,
                   float* C,
aiss's avatar
aiss committed
29
30
31
#ifdef __HIP_PLATFORM_HCC__
                   rocblas_gemm_algo algo = rocblas_gemm_algo_standard);
#else
32
                   cublasGemmAlgo_t algo = CUBLAS_GEMM_DEFAULT);
aiss's avatar
aiss committed
33
#endif
34
35
36
37
38
39
40
41
42
43
44
45

int cublas_gemm_ex(cublasHandle_t handle,
                   cublasOperation_t transa,
                   cublasOperation_t transb,
                   int m,
                   int n,
                   int k,
                   const float* alpha,
                   const float* beta,
                   const __half* A,
                   const __half* B,
                   __half* C,
aiss's avatar
aiss committed
46
47
48
#ifdef __HIP_PLATFORM_HCC__
                   rocblas_gemm_algo algo = rocblas_gemm_algo_standard);
#else
49
                   cublasGemmAlgo_t algo = CUBLAS_GEMM_DEFAULT_TENSOR_OP);
aiss's avatar
aiss committed
50
#endif
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

int cublas_strided_batched_gemm(cublasHandle_t handle,
                                int m,
                                int n,
                                int k,
                                const float* alpha,
                                const float* beta,
                                const float* A,
                                const float* B,
                                float* C,
                                cublasOperation_t op_A,
                                cublasOperation_t op_B,
                                int stride_A,
                                int stride_B,
                                int stride_C,
                                int batch,
aiss's avatar
aiss committed
67
68
69
#ifdef __HIP_PLATFORM_HCC__
                                rocblas_gemm_algo algo = rocblas_gemm_algo_standard);
#else
70
                                cublasGemmAlgo_t algo = CUBLAS_GEMM_DEFAULT);
aiss's avatar
aiss committed
71
#endif
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

int cublas_strided_batched_gemm(cublasHandle_t handle,
                                int m,
                                int n,
                                int k,
                                const float* alpha,
                                const float* beta,
                                const __half* A,
                                const __half* B,
                                __half* C,
                                cublasOperation_t op_A,
                                cublasOperation_t op_B,
                                int stride_A,
                                int stride_B,
                                int stride_C,
                                int batch,
aiss's avatar
aiss committed
88
89
90
#ifdef __HIP_PLATFORM_HCC__
                                rocblas_gemm_algo algo = rocblas_gemm_algo_standard);
#else
91
                                cublasGemmAlgo_t algo = CUBLAS_GEMM_DEFAULT_TENSOR_OP);
aiss's avatar
aiss committed
92
#endif