X Tutup
Skip to content

Commit 8595c86

Browse files
committed
Changing af_blas_transpose to af_transpose_t
- AF_NO_TRANSPOSE --> AF_NO_TRANS - AF_TRANSPOSE --> AF_TRANS - AF_CONJUGATE_TRANSPOSE --> AF_CONJ_TRANS
1 parent e0e57e0 commit 8595c86

File tree

13 files changed

+81
-81
lines changed

13 files changed

+81
-81
lines changed

include/af/blas.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ extern "C" {
2424
/**
2525
\ingroup blas_func_matmul
2626
*/
27-
28-
typedef enum af_transpose_enum {
29-
AF_NO_TRANSPOSE,
30-
AF_TRANSPOSE,
31-
AF_CONJUGATE_TRANSPOSE
32-
} af_blas_transpose;
3327
#ifdef __cplusplus
3428
}
3529
#endif
@@ -52,8 +46,8 @@ namespace af
5246
\ingroup blas_func_matmul
5347
*/
5448
AFAPI array matmul(const array &lhs, const array &rhs,
55-
af_blas_transpose optLhs = AF_NO_TRANSPOSE,
56-
af_blas_transpose optRhs = AF_NO_TRANSPOSE);
49+
af_transpose_t optLhs = AF_NO_TRANS,
50+
af_transpose_t optRhs = AF_NO_TRANS);
5751

5852
/**
5953
\brief Matrix multiply on two arrays
@@ -108,8 +102,8 @@ namespace af
108102
\ingroup blas_func_dot
109103
*/
110104
AFAPI array dot (const array &lhs, const array &rhs,
111-
af_blas_transpose optLhs = AF_NO_TRANSPOSE,
112-
af_blas_transpose optRhs = AF_NO_TRANSPOSE);
105+
af_transpose_t optLhs = AF_NO_TRANS,
106+
af_transpose_t optRhs = AF_NO_TRANS);
113107

114108
/**
115109
\brief Transposes a matrix
@@ -150,7 +144,7 @@ extern "C" {
150144
*/
151145
AFAPI af_err af_matmul( af_array *out ,
152146
const af_array lhs, const af_array rhs,
153-
af_blas_transpose optLhs, af_blas_transpose optRhs);
147+
af_transpose_t optLhs, af_transpose_t optRhs);
154148

155149

156150
/**
@@ -167,7 +161,7 @@ extern "C" {
167161

168162
AFAPI af_err af_dot( af_array *out,
169163
const af_array lhs, const af_array rhs,
170-
af_blas_transpose optLhs, af_blas_transpose optRhs);
164+
af_transpose_t optLhs, af_transpose_t optRhs);
171165

172166
/**
173167
\brief Transposes a matrix

include/af/defines.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ typedef enum {
153153
AF_SOLVE_BLKDIAG = 8192
154154
} af_solve_t;
155155

156+
typedef enum {
157+
AF_NO_TRANS,
158+
AF_TRANS,
159+
AF_CONJ_TRANS
160+
} af_transpose_t;
161+
156162
// Below enum is purely added for example purposes
157163
// it doesn't and shoudn't be used anywhere in the
158164
// code. No Guarantee's provided if it is used.

src/api/c/blas.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@
1919

2020
template<typename T>
2121
static inline af_array matmul(const af_array lhs, const af_array rhs,
22-
af_blas_transpose optLhs, af_blas_transpose optRhs)
22+
af_transpose_t optLhs, af_transpose_t optRhs)
2323
{
2424
return getHandle(detail::matmul<T>(getArray<T>(lhs), getArray<T>(rhs), optLhs, optRhs));
2525
}
2626

2727
template<typename T>
2828
static inline af_array dot(const af_array lhs, const af_array rhs,
29-
af_blas_transpose optLhs, af_blas_transpose optRhs)
29+
af_transpose_t optLhs, af_transpose_t optRhs)
3030
{
3131
return getHandle(detail::dot<T>(getArray<T>(lhs), getArray<T>(rhs), optLhs, optRhs));
3232
}
3333

3434
af_err af_matmul( af_array *out,
3535
const af_array lhs, const af_array rhs,
36-
af_blas_transpose optLhs, af_blas_transpose optRhs)
36+
af_transpose_t optLhs, af_transpose_t optRhs)
3737
{
3838
using namespace detail;
3939

@@ -47,8 +47,8 @@ af_err af_matmul( af_array *out,
4747
TYPE_ASSERT(lhs_type == rhs_type);
4848
af_array output = 0;
4949

50-
int aColDim = (optLhs == AF_NO_TRANSPOSE) ? 1 : 0;
51-
int bRowDim = (optRhs == AF_NO_TRANSPOSE) ? 0 : 1;
50+
int aColDim = (optLhs == AF_NO_TRANS) ? 1 : 0;
51+
int bRowDim = (optRhs == AF_NO_TRANS) ? 0 : 1;
5252

5353
DIM_ASSERT(1, lhsInfo.dims()[aColDim] == rhsInfo.dims()[bRowDim]);
5454

@@ -67,7 +67,7 @@ af_err af_matmul( af_array *out,
6767

6868
af_err af_dot( af_array *out,
6969
const af_array lhs, const af_array rhs,
70-
af_blas_transpose optLhs, af_blas_transpose optRhs)
70+
af_transpose_t optLhs, af_transpose_t optRhs)
7171
{
7272
using namespace detail;
7373

src/api/cpp/blas.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace af
1515
{
1616
array matmul(const array &lhs, const array &rhs,
17-
af_blas_transpose optLhs, af_blas_transpose optRhs)
17+
af_transpose_t optLhs, af_transpose_t optRhs)
1818
{
1919
af_array out = 0;
2020
AF_THROW(af_matmul(&out, lhs.get(), rhs.get(), optLhs, optRhs));
@@ -25,28 +25,28 @@ namespace af
2525
{
2626
af_array out = 0;
2727
AF_THROW(af_matmul(&out, lhs.get(), rhs.get(),
28-
AF_NO_TRANSPOSE, AF_TRANSPOSE));
28+
AF_NO_TRANS, AF_TRANS));
2929
return array(out);
3030
}
3131

3232
array matmulTN(const array &lhs, const array &rhs)
3333
{
3434
af_array out = 0;
3535
AF_THROW(af_matmul(&out, lhs.get(), rhs.get(),
36-
AF_TRANSPOSE, AF_NO_TRANSPOSE));
36+
AF_TRANS, AF_NO_TRANS));
3737
return array(out);
3838
}
3939

4040
array matmulTT(const array &lhs, const array &rhs)
4141
{
4242
af_array out = 0;
4343
AF_THROW(af_matmul(&out, lhs.get(), rhs.get(),
44-
AF_TRANSPOSE, AF_TRANSPOSE));
44+
AF_TRANS, AF_TRANS));
4545
return array(out);
4646
}
4747

4848
array dot (const array &lhs, const array &rhs,
49-
af_blas_transpose optLhs, af_blas_transpose optRhs)
49+
af_transpose_t optLhs, af_transpose_t optRhs)
5050
{
5151
af_array out = 0;
5252
AF_THROW(af_dot(&out, lhs.get(), rhs.get(), optLhs, optRhs));

src/backend/cpu/blas.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ getScale()
9797
}
9898

9999
CBLAS_TRANSPOSE
100-
toCblasTranspose(af_blas_transpose opt)
100+
toCblasTranspose(af_transpose_t opt)
101101
{
102102
CBLAS_TRANSPOSE out = CblasNoTrans;
103103
switch(opt) {
104-
case AF_NO_TRANSPOSE : out = CblasNoTrans; break;
105-
case AF_TRANSPOSE : out = CblasTrans; break;
106-
case AF_CONJUGATE_TRANSPOSE : out = CblasConjTrans; break;
107-
default : AF_ERROR("INVALID af_blas_transpose", AF_ERR_INVALID_ARG);
104+
case AF_NO_TRANS : out = CblasNoTrans; break;
105+
case AF_TRANS : out = CblasTrans; break;
106+
case AF_CONJ_TRANS : out = CblasConjTrans; break;
107+
default : AF_ERROR("INVALID af_transpose_t", AF_ERR_INVALID_ARG);
108108
}
109109
return out;
110110
}
@@ -143,7 +143,7 @@ struct cblas_types<cdouble> {
143143

144144
template<typename T>
145145
Array<T> matmul(const Array<T> &lhs, const Array<T> &rhs,
146-
af_blas_transpose optLhs, af_blas_transpose optRhs)
146+
af_transpose_t optLhs, af_transpose_t optRhs)
147147
{
148148
CBLAS_TRANSPOSE lOpts = toCblasTranspose(optLhs);
149149
CBLAS_TRANSPOSE rOpts = toCblasTranspose(optRhs);
@@ -187,7 +187,7 @@ Array<T> matmul(const Array<T> &lhs, const Array<T> &rhs,
187187

188188
template<typename T>
189189
Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
190-
af_blas_transpose optLhs, af_blas_transpose optRhs)
190+
af_transpose_t optLhs, af_transpose_t optRhs)
191191
{
192192
int N = lhs.dims()[0];
193193

@@ -206,7 +206,7 @@ Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
206206

207207
#define INSTANTIATE_BLAS(TYPE) \
208208
template Array<TYPE> matmul<TYPE>(const Array<TYPE> &lhs, const Array<TYPE> &rhs, \
209-
af_blas_transpose optLhs, af_blas_transpose optRhs);
209+
af_transpose_t optLhs, af_transpose_t optRhs);
210210

211211
INSTANTIATE_BLAS(float)
212212
INSTANTIATE_BLAS(cfloat)
@@ -215,7 +215,7 @@ INSTANTIATE_BLAS(cdouble)
215215

216216
#define INSTANTIATE_DOT(TYPE) \
217217
template Array<TYPE> dot<TYPE>(const Array<TYPE> &lhs, const Array<TYPE> &rhs, \
218-
af_blas_transpose optLhs, af_blas_transpose optRhs);
218+
af_transpose_t optLhs, af_transpose_t optRhs);
219219

220220
INSTANTIATE_DOT(float)
221221
INSTANTIATE_DOT(double)

src/backend/cpu/blas.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ namespace cpu
2828

2929
template<typename T>
3030
Array<T> matmul(const Array<T> &lhs, const Array<T> &rhs,
31-
af_blas_transpose optLhs, af_blas_transpose optRhs);
31+
af_transpose_t optLhs, af_transpose_t optRhs);
3232
template<typename T>
3333
Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
34-
af_blas_transpose optLhs, af_blas_transpose optRhs);
34+
af_transpose_t optLhs, af_transpose_t optRhs);
3535

3636
}

src/backend/cuda/blas.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ namespace cuda
2525
using cublas::getHandle;
2626

2727
cublasOperation_t
28-
toCblasTranspose(af_blas_transpose opt)
28+
toCblasTranspose(af_transpose_t opt)
2929
{
3030
cublasOperation_t out = CUBLAS_OP_N;
3131
switch(opt) {
32-
case AF_NO_TRANSPOSE : out = CUBLAS_OP_N; break;
33-
case AF_TRANSPOSE : out = CUBLAS_OP_T; break;
34-
case AF_CONJUGATE_TRANSPOSE : out = CUBLAS_OP_C; break;
35-
default : AF_ERROR("INVALID af_blas_transpose", AF_ERR_INVALID_ARG);
32+
case AF_NO_TRANS : out = CUBLAS_OP_N; break;
33+
case AF_TRANS : out = CUBLAS_OP_T; break;
34+
case AF_CONJ_TRANS : out = CUBLAS_OP_C; break;
35+
default : AF_ERROR("INVALID af_transpose_t", AF_ERR_INVALID_ARG);
3636
}
3737
return out;
3838
}
@@ -117,7 +117,7 @@ using namespace std;
117117

118118
template<typename T>
119119
Array<T> matmul(const Array<T> &lhs, const Array<T> &rhs,
120-
af_blas_transpose optLhs, af_blas_transpose optRhs)
120+
af_transpose_t optLhs, af_transpose_t optRhs)
121121
{
122122
cublasOperation_t lOpts = toCblasTranspose(optLhs);
123123
cublasOperation_t rOpts = toCblasTranspose(optRhs);
@@ -170,7 +170,7 @@ Array<T> matmul(const Array<T> &lhs, const Array<T> &rhs,
170170

171171
template<typename T>
172172
Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
173-
af_blas_transpose optLhs, af_blas_transpose optRhs)
173+
af_transpose_t optLhs, af_transpose_t optRhs)
174174
{
175175
int N = lhs.dims()[0];
176176

@@ -186,7 +186,7 @@ Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
186186
}
187187

188188
template<typename T>
189-
void trsm(const Array<T> &lhs, Array<T> &rhs, af_blas_transpose trans,
189+
void trsm(const Array<T> &lhs, Array<T> &rhs, af_transpose_t trans,
190190
bool is_upper, bool is_left, bool is_unit)
191191
{
192192
//dim4 lDims = lhs.dims();
@@ -214,7 +214,7 @@ void trsm(const Array<T> &lhs, Array<T> &rhs, af_blas_transpose trans,
214214

215215
#define INSTANTIATE_BLAS(TYPE) \
216216
template Array<TYPE> matmul<TYPE>(const Array<TYPE> &lhs, const Array<TYPE> &rhs, \
217-
af_blas_transpose optLhs, af_blas_transpose optRhs);
217+
af_transpose_t optLhs, af_transpose_t optRhs);
218218

219219
INSTANTIATE_BLAS(float)
220220
INSTANTIATE_BLAS(cfloat)
@@ -223,14 +223,14 @@ INSTANTIATE_BLAS(cdouble)
223223

224224
#define INSTANTIATE_DOT(TYPE) \
225225
template Array<TYPE> dot<TYPE>(const Array<TYPE> &lhs, const Array<TYPE> &rhs, \
226-
af_blas_transpose optLhs, af_blas_transpose optRhs);
226+
af_transpose_t optLhs, af_transpose_t optRhs);
227227

228228
INSTANTIATE_DOT(float)
229229
INSTANTIATE_DOT(double)
230230

231231
#define INSTANTIATE_TRSM(TYPE) \
232232
template void trsm<TYPE>(const Array<TYPE> &lhs, Array<TYPE> &rhs, \
233-
af_blas_transpose trans, bool is_upper, bool is_left, bool is_unit);
233+
af_transpose_t trans, bool is_upper, bool is_left, bool is_unit);
234234

235235
INSTANTIATE_TRSM(float)
236236
INSTANTIATE_TRSM(cfloat)

src/backend/cuda/blas.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ namespace cuda
1616

1717
template<typename T>
1818
Array<T> matmul(const Array<T> &lhs, const Array<T> &rhs,
19-
af_blas_transpose optLhs, af_blas_transpose optRhs);
19+
af_transpose_t optLhs, af_transpose_t optRhs);
2020

2121
template<typename T>
2222
Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
23-
af_blas_transpose optLhs, af_blas_transpose optRhs);
23+
af_transpose_t optLhs, af_transpose_t optRhs);
2424

2525
template<typename T>
26-
void trsm(const Array<T> &lhs, Array<T> &rhs, af_blas_transpose trans = AF_NO_TRANSPOSE,
26+
void trsm(const Array<T> &lhs, Array<T> &rhs, af_transpose_t trans = AF_NO_TRANS,
2727
bool is_upper = false, bool is_left = true, bool is_unit = false);
2828

2929
}

src/backend/cuda/solve.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ Array<T> leastSquares(const Array<T> &a, const Array<T> &b)
245245

246246
// Bt = tri_solve(R1, B);
247247
B.resetDims(dim4(M, K));
248-
trsm<T>(A, B, AF_CONJUGATE_TRANSPOSE, true, true, false);
248+
trsm<T>(A, B, AF_CONJ_TRANS, true, true, false);
249249

250250
// Bpad = pad(Bt, ..)
251251
B.resetDims(dim4(N, K));
@@ -312,7 +312,7 @@ Array<T> leastSquares(const Array<T> &a, const Array<T> &b)
312312
// tri_solve(R1, Bt)
313313
A.resetDims(dim4(N, N));
314314
B.resetDims(dim4(N, K));
315-
trsm(A, B, AF_NO_TRANSPOSE, true, true, false);
315+
trsm(A, B, AF_NO_TRANS, true, true, false);
316316
}
317317
return B;
318318
}

src/backend/opencl/blas.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ using std::runtime_error;
3030
using std::to_string;
3131

3232
clblasTranspose
33-
toClblasTranspose(af_blas_transpose opt)
33+
toClblasTranspose(af_transpose_t opt)
3434
{
3535
clblasTranspose out = clblasNoTrans;
3636
switch(opt) {
37-
case AF_NO_TRANSPOSE : out = clblasNoTrans; break;
38-
case AF_TRANSPOSE : out = clblasTrans; break;
39-
case AF_CONJUGATE_TRANSPOSE : out = clblasConjTrans; break;
40-
default : AF_ERROR("INVALID af_blas_transpose", AF_ERR_INVALID_ARG);
37+
case AF_NO_TRANS : out = clblasNoTrans; break;
38+
case AF_TRANS : out = clblasTrans; break;
39+
case AF_CONJ_TRANS : out = clblasConjTrans; break;
40+
default : AF_ERROR("INVALID af_transpose_t", AF_ERR_INVALID_ARG);
4141
}
4242
return out;
4343
}
@@ -76,7 +76,7 @@ BLAS_FUNC(dot, double, D)
7676

7777
template<typename T>
7878
Array<T> matmul(const Array<T> &lhs, const Array<T> &rhs,
79-
af_blas_transpose optLhs, af_blas_transpose optRhs)
79+
af_transpose_t optLhs, af_transpose_t optRhs)
8080
{
8181
initBlas();
8282
clblasTranspose lOpts = toClblasTranspose(optLhs);
@@ -135,7 +135,7 @@ Array<T> matmul(const Array<T> &lhs, const Array<T> &rhs,
135135

136136
template<typename T>
137137
Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
138-
af_blas_transpose optLhs, af_blas_transpose optRhs)
138+
af_transpose_t optLhs, af_transpose_t optRhs)
139139
{
140140
initBlas();
141141

@@ -157,7 +157,7 @@ Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
157157

158158
#define INSTANTIATE_BLAS(TYPE) \
159159
template Array<TYPE> matmul<TYPE>(const Array<TYPE> &lhs, const Array<TYPE> &rhs, \
160-
af_blas_transpose optLhs, af_blas_transpose optRhs);
160+
af_transpose_t optLhs, af_transpose_t optRhs);
161161

162162
INSTANTIATE_BLAS(float)
163163
INSTANTIATE_BLAS(cfloat)
@@ -166,11 +166,11 @@ INSTANTIATE_BLAS(cdouble)
166166

167167
#define INSTANTIATE_DOT(TYPE) \
168168
template Array<TYPE> dot<TYPE>(const Array<TYPE> &lhs, const Array<TYPE> &rhs, \
169-
af_blas_transpose optLhs, af_blas_transpose optRhs);
169+
af_transpose_t optLhs, af_transpose_t optRhs);
170170

171171
template<typename T>
172172
Array<T> dot(const Array<T> &lhs, const Array<T> &rhs,
173-
af_blas_transpose optLhs, af_blas_transpose optRhs);
173+
af_transpose_t optLhs, af_transpose_t optRhs);
174174

175175
INSTANTIATE_DOT(float)
176176
INSTANTIATE_DOT(double)

0 commit comments

Comments
 (0)
X Tutup