Expression Templates Library (ETL)
bias_batch_sum.hpp
Go to the documentation of this file.
1 //=======================================================================
2 // Copyright (c) 2014-2023 Baptiste Wicht
3 // Distributed under the terms of the MIT License.
4 // (See accompanying file LICENSE or copy at
5 // http://opensource.org/licenses/MIT)
6 //=======================================================================
7 
13 #pragma once
14 
15 #ifdef ETL_EGBLAS_MODE
16 
17 #include "etl/impl/cublas/cuda.hpp"
18 
19 #include <egblas.hpp>
20 
21 #endif
22 
23 namespace etl::impl::egblas {
24 
25 #ifdef EGBLAS_HAS_SBIAS_BATCH_SUM
26 static constexpr bool has_sbias_batch_sum = true;
27 #else
28 static constexpr bool has_sbias_batch_sum = false;
29 #endif
30 
40 inline void bias_batch_sum([[maybe_unused]] size_t b,
41  [[maybe_unused]] size_t n,
42  [[maybe_unused]] float* A,
43  [[maybe_unused]] size_t lda,
44  [[maybe_unused]] float* B,
45  [[maybe_unused]] size_t ldb) {
46 #ifdef EGBLAS_HAS_SBIAS_BATCH_SUM
47  inc_counter("egblas");
48  egblas_sbias_batch_sum(b, n, A, lda, B, ldb);
49 #else
50  cpp_unreachable("Invalid call to egblas::bias_batch_sum");
51 #endif
52 }
53 
54 #ifdef EGBLAS_HAS_DBIAS_BATCH_SUM
55 static constexpr bool has_dbias_batch_sum = true;
56 #else
57 static constexpr bool has_dbias_batch_sum = false;
58 #endif
59 
69 inline void bias_batch_sum([[maybe_unused]] size_t b,
70  [[maybe_unused]] size_t n,
71  [[maybe_unused]] double* A,
72  [[maybe_unused]] size_t lda,
73  [[maybe_unused]] double* B,
74  [[maybe_unused]] size_t ldb) {
75 #ifdef EGBLAS_HAS_DBIAS_BATCH_SUM
76  inc_counter("egblas");
77  egblas_dbias_batch_sum(b, n, A, lda, B, ldb);
78 #else
79  cpp_unreachable("Invalid call to egblas::bias_batch_sum");
80 #endif
81 }
82 
83 #ifdef EGBLAS_HAS_SBIAS_BATCH_MEAN
84 static constexpr bool has_sbias_batch_mean = true;
85 #else
86 static constexpr bool has_sbias_batch_mean = false;
87 #endif
88 
98 inline void bias_batch_mean([[maybe_unused]] size_t b,
99  [[maybe_unused]] size_t n,
100  [[maybe_unused]] float* A,
101  [[maybe_unused]] size_t lda,
102  [[maybe_unused]] float* B,
103  [[maybe_unused]] size_t ldb) {
104 #ifdef EGBLAS_HAS_SBIAS_BATCH_MEAN
105  inc_counter("egblas");
106  egblas_sbias_batch_mean(b, n, A, lda, B, ldb);
107 #else
108  cpp_unreachable("Invalid call to egblas::bias_batch_mean");
109 #endif
110 }
111 
112 #ifdef EGBLAS_HAS_DBIAS_BATCH_MEAN
113 static constexpr bool has_dbias_batch_mean = true;
114 #else
115 static constexpr bool has_dbias_batch_mean = false;
116 #endif
117 
127 inline void bias_batch_mean([[maybe_unused]] size_t b,
128  [[maybe_unused]] size_t n,
129  [[maybe_unused]] double* A,
130  [[maybe_unused]] size_t lda,
131  [[maybe_unused]] double* B,
132  [[maybe_unused]] size_t ldb) {
133 #ifdef EGBLAS_HAS_DBIAS_BATCH_MEAN
134  inc_counter("egblas");
135  egblas_dbias_batch_mean(b, n, A, lda, B, ldb);
136 #else
137  cpp_unreachable("Invalid call to egblas::bias_batch_mean");
138 #endif
139 }
140 
141 #ifdef EGBLAS_HAS_SBIAS_BATCH_VAR
142 static constexpr bool has_sbias_batch_var = true;
143 #else
144 static constexpr bool has_sbias_batch_var = false;
145 #endif
146 
156 inline void bias_batch_var([[maybe_unused]] size_t b,
157  [[maybe_unused]] size_t n,
158  [[maybe_unused]] float* A,
159  [[maybe_unused]] size_t lda,
160  [[maybe_unused]] float* B,
161  [[maybe_unused]] size_t ldb,
162  [[maybe_unused]] float* Y,
163  [[maybe_unused]] size_t ldy) {
164 #ifdef EGBLAS_HAS_SBIAS_BATCH_VAR
165  inc_counter("egblas");
166  egblas_sbias_batch_var(b, n, A, lda, B, ldb, Y, ldy);
167 #else
168  cpp_unreachable("Invalid call to egblas::bias_batch_var");
169 #endif
170 }
171 
172 #ifdef EGBLAS_HAS_DBIAS_BATCH_VAR
173 static constexpr bool has_dbias_batch_var = true;
174 #else
175 static constexpr bool has_dbias_batch_var = false;
176 #endif
177 
187 inline void bias_batch_var([[maybe_unused]] size_t b,
188  [[maybe_unused]] size_t n,
189  [[maybe_unused]] double* A,
190  [[maybe_unused]] size_t lda,
191  [[maybe_unused]] double* B,
192  [[maybe_unused]] size_t ldb,
193  [[maybe_unused]] double* Y,
194  [[maybe_unused]] size_t ldy) {
195 #ifdef EGBLAS_HAS_DBIAS_BATCH_VAR
196  inc_counter("egblas");
197  egblas_dbias_batch_var(b, n, A, lda, B, ldb, Y, ldy);
198 #else
199  cpp_unreachable("Invalid call to egblas::bias_batch_var");
200 #endif
201 }
202 
203 #ifdef EGBLAS_HAS_SBIAS_BATCH_SUM4
204 static constexpr bool has_sbias_batch_sum4 = true;
205 #else
206 static constexpr bool has_sbias_batch_sum4 = false;
207 #endif
208 
218 inline void bias_batch_sum4([[maybe_unused]] size_t b,
219  [[maybe_unused]] size_t n,
220  [[maybe_unused]] size_t w,
221  [[maybe_unused]] size_t h,
222  [[maybe_unused]] float* A,
223  [[maybe_unused]] float* B) {
224 #ifdef EGBLAS_HAS_SBIAS_BATCH_SUM4
225  inc_counter("egblas");
226  egblas_sbias_batch_sum4(b, n, w, h, A, B);
227 #else
228  cpp_unreachable("Invalid call to egblas::bias_batch_sum");
229 #endif
230 }
231 
232 #ifdef EGBLAS_HAS_SBIAS_BATCH_MEAN4
233 static constexpr bool has_sbias_batch_mean4 = true;
234 #else
235 static constexpr bool has_sbias_batch_mean4 = false;
236 #endif
237 
247 inline void bias_batch_mean4([[maybe_unused]] size_t b,
248  [[maybe_unused]] size_t n,
249  [[maybe_unused]] size_t w,
250  [[maybe_unused]] size_t h,
251  [[maybe_unused]] float* A,
252  [[maybe_unused]] float* B) {
253 #ifdef EGBLAS_HAS_SBIAS_BATCH_MEAN4
254  inc_counter("egblas");
255  egblas_sbias_batch_mean4(b, n, w, h, A, B);
256 #else
257  cpp_unreachable("Invalid call to egblas::bias_batch_mean");
258 #endif
259 }
260 
261 #ifdef EGBLAS_HAS_DBIAS_BATCH_SUM4
262 static constexpr bool has_dbias_batch_sum4 = true;
263 #else
264 static constexpr bool has_dbias_batch_sum4 = false;
265 #endif
266 
276 inline void bias_batch_sum4([[maybe_unused]] size_t b,
277  [[maybe_unused]] size_t n,
278  [[maybe_unused]] size_t w,
279  [[maybe_unused]] size_t h,
280  [[maybe_unused]] double* A,
281  [[maybe_unused]] double* B) {
282 #ifdef EGBLAS_HAS_DBIAS_BATCH_SUM4
283  inc_counter("egblas");
284  egblas_dbias_batch_sum4(b, n, w, h, A, B);
285 #else
286  cpp_unreachable("Invalid call to egblas::bias_batch_sum");
287 #endif
288 }
289 
290 #ifdef EGBLAS_HAS_DBIAS_BATCH_MEAN4
291 static constexpr bool has_dbias_batch_mean4 = true;
292 #else
293 static constexpr bool has_dbias_batch_mean4 = false;
294 #endif
295 
305 inline void bias_batch_mean4([[maybe_unused]] size_t b,
306  [[maybe_unused]] size_t n,
307  [[maybe_unused]] size_t w,
308  [[maybe_unused]] size_t h,
309  [[maybe_unused]] double* A,
310  [[maybe_unused]] double* B) {
311 #ifdef EGBLAS_HAS_DBIAS_BATCH_MEAN4
312  inc_counter("egblas");
313  egblas_dbias_batch_mean4(b, n, w, h, A, B);
314 #else
315  cpp_unreachable("Invalid call to egblas::bias_batch_mean");
316 #endif
317 }
318 
319 #ifdef EGBLAS_HAS_SBIAS_BATCH_VAR4
320 static constexpr bool has_sbias_batch_var4 = true;
321 #else
322 static constexpr bool has_sbias_batch_var4 = false;
323 #endif
324 
334 inline void bias_batch_var4([[maybe_unused]] size_t b,
335  [[maybe_unused]] size_t n,
336  [[maybe_unused]] size_t w,
337  [[maybe_unused]] size_t h,
338  [[maybe_unused]] float* A,
339  [[maybe_unused]] float* B,
340  [[maybe_unused]] float* Y) {
341 #ifdef EGBLAS_HAS_SBIAS_BATCH_VAR4
342  inc_counter("egblas");
343  egblas_sbias_batch_var4(b, n, w, h, A, B, Y);
344 #else
345  cpp_unreachable("Invalid call to egblas::bias_batch_var");
346 #endif
347 }
348 
349 #ifdef EGBLAS_HAS_DBIAS_BATCH_VAR4
350 static constexpr bool has_dbias_batch_var4 = true;
351 #else
352 static constexpr bool has_dbias_batch_var4 = false;
353 #endif
354 
364 inline void bias_batch_var4([[maybe_unused]] size_t b,
365  [[maybe_unused]] size_t n,
366  [[maybe_unused]] size_t w,
367  [[maybe_unused]] size_t h,
368  [[maybe_unused]] double* A,
369  [[maybe_unused]] double* B,
370  [[maybe_unused]] double* Y) {
371 #ifdef EGBLAS_HAS_DBIAS_BATCH_VAR4
372  inc_counter("egblas");
373  egblas_dbias_batch_var4(b, n, w, h, A, B, Y);
374 #else
375  cpp_unreachable("Invalid call to egblas::bias_batch_var");
376 #endif
377 }
378 
379 } //end of namespace etl::impl::egblas
Definition: abs.hpp:23
void bias_batch_sum4([[maybe_unused]] size_t b, [[maybe_unused]] size_t n, [[maybe_unused]] size_t w, [[maybe_unused]] size_t h, [[maybe_unused]] float *A, [[maybe_unused]] float *B)
Wrappers for single-precision egblas bias_batch_sum operation.
Definition: bias_batch_sum.hpp:218
void bias_batch_mean4([[maybe_unused]] size_t b, [[maybe_unused]] size_t n, [[maybe_unused]] size_t w, [[maybe_unused]] size_t h, [[maybe_unused]] float *A, [[maybe_unused]] float *B)
Wrappers for single-precision egblas bias_batch_mean operation.
Definition: bias_batch_sum.hpp:247
void bias_batch_var([[maybe_unused]] size_t b, [[maybe_unused]] size_t n, [[maybe_unused]] float *A, [[maybe_unused]] size_t lda, [[maybe_unused]] float *B, [[maybe_unused]] size_t ldb, [[maybe_unused]] float *Y, [[maybe_unused]] size_t ldy)
Wrappers for single-precision egblas bias_batch_var operation.
Definition: bias_batch_sum.hpp:156
void bias_batch_var4([[maybe_unused]] size_t b, [[maybe_unused]] size_t n, [[maybe_unused]] size_t w, [[maybe_unused]] size_t h, [[maybe_unused]] float *A, [[maybe_unused]] float *B, [[maybe_unused]] float *Y)
Wrappers for single-precision egblas bias_batch_var operation.
Definition: bias_batch_sum.hpp:334
void bias_batch_mean([[maybe_unused]] size_t b, [[maybe_unused]] size_t n, [[maybe_unused]] float *A, [[maybe_unused]] size_t lda, [[maybe_unused]] float *B, [[maybe_unused]] size_t ldb)
Wrappers for single-precision egblas bias_batch_mean operation.
Definition: bias_batch_sum.hpp:98
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25
void bias_batch_sum([[maybe_unused]] size_t b, [[maybe_unused]] size_t n, [[maybe_unused]] float *A, [[maybe_unused]] size_t lda, [[maybe_unused]] float *B, [[maybe_unused]] size_t ldb)
Wrappers for single-precision egblas bias_batch_sum operation.
Definition: bias_batch_sum.hpp:40