Expression Templates Library (ETL)
sigmoid.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_SSIGMOID
26 static constexpr bool has_ssigmoid = true;
27 #else
28 static constexpr bool has_ssigmoid = false;
29 #endif
30 
40 inline void sigmoid([[maybe_unused]] size_t n,
41  [[maybe_unused]] float alpha,
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_SSIGMOID
47  inc_counter("egblas");
48  egblas_ssigmoid(n, alpha, A, lda, B, ldb);
49 #else
50  cpp_unreachable("Invalid call to egblas::sigmoid");
51 #endif
52 }
53 
54 #ifdef EGBLAS_HAS_DSIGMOID
55 static constexpr bool has_dsigmoid = true;
56 #else
57 static constexpr bool has_dsigmoid = false;
58 #endif
59 
69 inline void sigmoid([[maybe_unused]] size_t n,
70  [[maybe_unused]] double alpha,
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_DSIGMOID
76  inc_counter("egblas");
77  egblas_dsigmoid(n, alpha, A, lda, B, ldb);
78 #else
79  cpp_unreachable("Invalid call to egblas::sigmoid");
80 #endif
81 }
82 
83 } //end of namespace etl::impl::egblas
Definition: abs.hpp:23
auto sigmoid(const E &value) -> detail::unary_helper< E, sigmoid_unary_op >
Return the logistic sigmoid of the given ETL expression.
Definition: function_expression_builder.hpp:197
void inc_counter([[maybe_unused]] const char *name)
Increase the given counter.
Definition: counters.hpp:25