[dynamic-training] Add dynamic training using derivatives
[platform/core/ml/nntrainer.git] / nntrainer / tensor / blas_interface.h
1 // SPDX-License-Identifier: Apache-2.0
2 /**
3  * Copyright (C) 2020 Jijoong Moon <jijoong.moon@samsung.com>
4  *
5  * @file        blas_interface.h
6  * @date        28 Aug 2020
7  * @see         https://github.com/nnstreamer/nntrainer
8  * @author      Jijoong Moon <jijoong.moon@samsung.com>
9  * @bug         No known bugs except for NYI items
10  * @brief       This is dummy header for blas support
11  *
12  */
13
14 #ifndef __BLAS_INTERFACE_H_
15 #define __BLAS_INTERFACE_H_
16 #ifdef __cplusplus
17
18 #ifdef USE_BLAS
19 extern "C" {
20 #include <cblas.h>
21 }
22 #else
23 enum CBLAS_ORDER { CblasRowMajor = 101, CblasColMajor = 102 };
24
25 enum CBLAS_TRANSPOSE {
26   CblasNoTrans = 111,
27   CblasTrans = 112,
28   CblasConjTrans = 113
29 };
30 #endif
31
32 #ifdef USE_CUBLAS
33 #include <helper_cuda.h>
34 #include <helper_functions.h>
35 #endif
36
37 namespace nntrainer {
38
39 void sscal(const int N, const float alpha, float *X, const int incX);
40
41 float snrm2(const int N, const float *X, const int incX);
42
43 void scopy(const unsigned int N, const float *X, const int incX, float *Y,
44            const int intY);
45
46 float sdot(const unsigned int N, const float *X, const unsigned int incX,
47            const float *Y, const unsigned int incY);
48
49 void saxpy(const unsigned int N, const float alpha, const float *X,
50            const int incX, float *Y, const int incY);
51
52 void sgemm(CBLAS_ORDER order, CBLAS_TRANSPOSE TransA, CBLAS_TRANSPOSE TransB,
53            const unsigned int M, const unsigned int N, const unsigned int K,
54            const float alpha, const float *A, const unsigned int lda,
55            const float *B, const unsigned int ldb, const float beta, float *C,
56            const unsigned int ldc);
57
58 void sgemv(CBLAS_ORDER order, CBLAS_TRANSPOSE TransA, const unsigned int M,
59            const unsigned int N, const float alpha, const float *A,
60            const unsigned int lda, const float *X, const int incX,
61            const float beta, float *Y, const int incY);
62
63 unsigned int isamax(const unsigned int N, const float *X, const int incX);
64
65 } /* namespace nntrainer */
66 #endif /* __cplusplus */
67 #endif /* __BLAS_INTERFACE_H__ */