29 template <vector_mode_t V>
50 template <
typename V = default_vec>
58 static constexpr T
apply(
const T& x) {
59 return math::logistic_sigmoid(x);
68 template <
typename V = default_vec>
70 auto one = V::set(T(1));
72 auto t1 = V::minus(x);
74 auto t3 = V::add(one, t2);
75 return V::div(one, t3);
85 template <
typename X,
typename Y>
93 if (n < 8 * 1024 * 1024 && is_single_precision<Y> && impl::egblas::has_ssigmoid) {
94 impl::egblas::sigmoid(n, 1, t1.gpu_memory(), 1, t2.gpu_memory(), 1);
95 }
else if (n < 1024 * 1024 && is_double_precision<Y> && impl::egblas::has_dsigmoid) {
96 impl::egblas::sigmoid(n, 1, t1.gpu_memory(), 1, t2.gpu_memory(), 1);
98 impl::cudnn::sigmoid(t1, t2);
109 template <
typename X,
typename Y>
115 if (n < 8 * 1024 * 1024 && is_single_precision<Y> && impl::egblas::has_ssigmoid) {
116 impl::egblas::sigmoid(n, 1, t1.gpu_memory(), 1, y.gpu_memory(), 1);
120 }
else if (n < 1024 * 1024 && is_double_precision<Y> && impl::egblas::has_dsigmoid) {
121 impl::egblas::sigmoid(n, 1, t1.gpu_memory(), 1, y.gpu_memory(), 1);
126 impl::cudnn::sigmoid(t1, y);
136 static std::string
desc() noexcept {
145 template <
typename T>
147 static constexpr
bool linear =
true;
148 static constexpr
bool thread_safe =
true;
155 template <vector_mode_t V>
156 static constexpr
bool vectorizable =
false;
161 template <
typename E>
183 z = (1.5 * x / (1 + x));
185 z = (0.935409070603099 + 0.0458812946797165 * (x - 1.7));
187 z = 0.99505475368673;
192 z = (1.5 * xx / (1 + xx));
194 z = (0.935409070603099 + 0.0458812946797165 * (xx - 1.7));
196 z = 0.99505475368673;
201 return 0.5 * (z + 1.0);
208 static std::string
desc() noexcept {
209 return "fast_sigmoid";
static constexpr bool thread_safe
Indicates if the operator is thread safe or not.
Definition: sigmoid.hpp:22
static constexpr int complexity()
Estimate the complexity of operator.
Definition: sigmoid.hpp:43
static constexpr bool gpu_computable
Indicates if the operator can be computed on GPU.
Definition: sigmoid.hpp:37
Unary operation computing a fast sigmoid approximation.
Definition: sigmoid.hpp:146
EGBLAS wrappers for the sigmoid operation.
decltype(auto) select_smart_gpu_compute(X &x, Y &y)
Compute the expression into a representation that is GPU up to date and possibly store this represent...
Definition: helpers.hpp:434
static constexpr T apply(const T &x)
Apply the unary operator on x.
Definition: sigmoid.hpp:58
static T apply(const T &v)
Apply the unary operator on x.
Definition: sigmoid.hpp:177
Unary operation computing the logistic sigmoid.
Definition: sigmoid.hpp:20
SSE3 is the max vectorization available.
Convolution implementations with NVidia cuDNN library.
static constexpr bool linear
Indicates if the operator is linear.
Definition: sigmoid.hpp:21
static std::string desc() noexcept
Returns a textual representation of the operator.
Definition: sigmoid.hpp:136
constexpr bool intel_compiler
Indicates if the projectis compiled with intel compiler.
Definition: config.hpp:225
Root namespace for the ETL library.
Definition: adapter.hpp:15
static constexpr int complexity()
Estimate the complexity of operator.
Definition: sigmoid.hpp:168
constexpr bool cudnn_enabled
Indicates if the NVIDIA CUDNN library is available for ETL.
Definition: config.hpp:114
static auto gpu_compute_hint(const X &x, Y &y) noexcept
Compute the result of the operation using the GPU.
Definition: sigmoid.hpp:86
decltype(auto) force_temporary_gpu_dim_only(E &&expr)
Force a temporary out of the expression, without copying its content.
Definition: temporary.hpp:223
static Y & gpu_compute(const X &x, Y &y) noexcept
Compute the result of the operation using the GPU.
Definition: sigmoid.hpp:110
constexpr size_t size(const E &expr) noexcept
Returns the size of the given ETL expression.
Definition: helpers.hpp:108
auto exp(E &&value) -> detail::unary_helper< E, exp_unary_op >
Apply exponential on each value of the given expression.
Definition: function_expression_builder.hpp:154
AVX is the max vectorization available.
typename V::template vec_type< T > vec_type
Definition: sigmoid.hpp:51
static constexpr bool vectorizable
Indicates if the expression is vectorizable using the given vector mode.
Definition: sigmoid.hpp:30
static vec_type< V > load(const vec_type< V > &x) noexcept
Compute several applications of the operator at a time.
Definition: sigmoid.hpp:69
decltype(auto) smart_gpu_compute_hint(E &expr, Y &y)
Compute the expression into a representation that is GPU up to date.
Definition: helpers.hpp:368
static std::string desc() noexcept
Returns a textual representation of the operator.
Definition: sigmoid.hpp:208