28 template <vector_mode_t V>
52 static std::uniform_real_distribution<double> real_distribution(0.0, 1.0);
54 return x + real_distribution(rand_engine);
61 static std::string
desc() noexcept {
62 return "uniform_noise";
70 template <
typename G,
typename T>
91 template <vector_mode_t V>
114 std::uniform_real_distribution<double> real_distribution(0.0, 1.0);
116 return x + real_distribution(rand_engine);
123 static std::string
desc() noexcept {
124 return "uniform_noise";
132 template <
typename T>
142 template <vector_mode_t V>
148 template <
typename E>
166 static std::normal_distribution<T> normal_distribution(0.0, 1.0);
168 return x + normal_distribution(rand_engine);
175 static std::string
desc() noexcept {
176 return "normal_noise";
184 template <
typename G,
typename T>
205 template <vector_mode_t V>
211 template <
typename E>
228 std::normal_distribution<T> normal_distribution(0.0, 1.0);
230 return x + normal_distribution(rand_engine);
237 static std::string
desc() noexcept {
238 return "normal_noise";
246 template <
typename T>
256 template <vector_mode_t V>
262 template <
typename E>
263 static constexpr
bool gpu_computable = (is_single_precision_t<T> && impl::egblas::has_slogistic_noise_seed)
264 || (is_double_precision_t<T> && impl::egblas::has_dlogistic_noise_seed);
282 std::normal_distribution<T> noise_distribution(0.0, math::logistic_sigmoid(x));
284 return x + noise_distribution(rand_engine);
294 template <
typename X,
typename Y>
298 std::uniform_int_distribution<long> seed_dist;
305 impl::egblas::logistic_noise_seed(
etl::size(y), alpha, t1.gpu_memory(), 1, t2.gpu_memory(), 1, seed_dist(rand_engine));
315 template <
typename X,
typename Y>
319 std::uniform_int_distribution<long> seed_dist;
324 impl::egblas::logistic_noise_seed(
etl::size(y), alpha, t1.gpu_memory(), 1, y.gpu_memory(), 1, seed_dist(rand_engine));
336 static std::string
desc() noexcept {
337 return "logistic_noise";
345 template <
typename G,
typename T>
347 static constexpr
bool linear =
true;
348 static constexpr
bool thread_safe =
false;
366 template <vector_mode_t V>
367 static constexpr
bool vectorizable =
false;
372 template <
typename E>
373 static constexpr
bool gpu_computable = (is_single_precision_t<T> && impl::egblas::has_slogistic_noise_seed)
374 || (is_double_precision_t<T> && impl::egblas::has_dlogistic_noise_seed);
390 std::normal_distribution<T> noise_distribution(0.0, math::logistic_sigmoid(x));
392 return x + noise_distribution(rand_engine);
402 template <
typename X,
typename Y>
404 std::uniform_int_distribution<long> seed_dist;
411 impl::egblas::logistic_noise_seed(
etl::size(y), alpha, t1.gpu_memory(), 1, t2.gpu_memory(), 1, seed_dist(rand_engine));
421 template <
typename X,
typename Y>
423 std::uniform_int_distribution<long> seed_dist;
428 impl::egblas::logistic_noise_seed(
etl::size(y), alpha, t1.gpu_memory(), 1, y.gpu_memory(), 1, seed_dist(rand_engine));
440 static std::string
desc() noexcept {
441 return "logistic_noise";
453 template <
typename T>
455 static constexpr
bool linear =
true;
456 static constexpr
bool thread_safe =
false;
463 template <vector_mode_t V>
464 static constexpr
bool vectorizable =
false;
469 template <
typename E>
470 static constexpr
bool gpu_computable = (is_single_precision_t<T> && impl::egblas::has_slogistic_noise_seed)
471 || (is_double_precision_t<T> && impl::egblas::has_dlogistic_noise_seed);
488 if constexpr (impl::egblas::has_logistic_noise_prepare) {
489 states = std::make_shared<void*>();
490 *states = impl::egblas::logistic_noise_prepare();
498 if constexpr (impl::egblas::has_logistic_noise_prepare) {
499 this->states = states;
501 if (!*this->states) {
502 std::uniform_int_distribution<long> seed_dist;
503 *this->states = impl::egblas::logistic_noise_prepare_seed(seed_dist(rand_engine));
514 std::normal_distribution<double> noise_distribution(0.0, math::logistic_sigmoid(x));
516 return x + noise_distribution(rand_engine);
526 template <
typename X,
typename Y>
533 impl::egblas::logistic_noise_states(
etl::size(y), alpha, t1.gpu_memory(), 1, t2.gpu_memory(), 1, *states);
543 template <
typename X,
typename Y>
548 impl::egblas::logistic_noise_states(
etl::size(y), alpha, t1.gpu_memory(), 1, y.gpu_memory(), 1, *states);
560 static std::string
desc() noexcept {
561 return "state_logistic_noise";
573 template <
typename G,
typename T>
575 static constexpr
bool linear =
true;
576 static constexpr
bool thread_safe =
false;
580 std::shared_ptr<void*> states;
587 if constexpr (impl::egblas::has_logistic_noise_prepare) {
588 std::uniform_int_distribution<long> seed_dist;
590 states = std::make_shared<void*>();
591 *states = impl::egblas::logistic_noise_prepare_seed(seed_dist(rand_engine));
599 if constexpr (impl::egblas::has_logistic_noise_prepare) {
600 this->states = states;
602 if (!*this->states) {
603 std::uniform_int_distribution<long> seed_dist;
604 *this->states = impl::egblas::logistic_noise_prepare_seed(seed_dist(rand_engine));
614 template <vector_mode_t V>
615 static constexpr
bool vectorizable =
false;
620 template <
typename E>
621 static constexpr
bool gpu_computable = (is_single_precision_t<T> && impl::egblas::has_slogistic_noise_states)
622 || (is_double_precision_t<T> && impl::egblas::has_dlogistic_noise_states);
638 std::normal_distribution<double> noise_distribution(0.0, math::logistic_sigmoid(x));
640 return x + noise_distribution(rand_engine);
650 template <
typename X,
typename Y>
657 impl::egblas::logistic_noise_states(
etl::size(y), alpha, t1.gpu_memory(), 1, t2.gpu_memory(), 1, *states);
667 template <
typename X,
typename Y>
672 impl::egblas::logistic_noise_states(
etl::size(y), alpha, t1.gpu_memory(), 1, y.gpu_memory(), 1, *states);
684 static std::string
desc() noexcept {
685 return "state_logistic_noise";
auto gpu_compute_hint(const X &x, Y &y) const noexcept
Compute the result of the operation using the GPU.
Definition: noise.hpp:651
EGBLAS wrappers for the logistic_noise operation.
Unary operation applying a normal noise.
Definition: noise.hpp:185
Y & gpu_compute(const X &x, Y &y) const noexcept
Compute the result of the operation using the GPU.
Definition: noise.hpp:544
static T apply(const T &x)
Apply the unary operator on x.
Definition: noise.hpp:164
Unary operation applying a normal noise.
Definition: noise.hpp:133
static constexpr int complexity()
Estimate the complexity of operator.
Definition: noise.hpp:155
static constexpr int complexity()
Estimate the complexity of operator.
Definition: noise.hpp:628
static constexpr int complexity()
Estimate the complexity of operator.
Definition: noise.hpp:218
state_logistic_noise_unary_op()
Construct a new operator.
Definition: noise.hpp:487
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
auto gpu_compute_hint(const X &x, Y &y) const noexcept
Compute the result of the operation using the GPU.
Definition: noise.hpp:527
normal_noise_unary_g_op(G &rand_engine)
Construct a new normal_noise_unary_g_op.
Definition: noise.hpp:196
static constexpr int complexity()
Estimate the complexity of operator.
Definition: noise.hpp:477
T apply(const T &x) const
Apply the unary operator on x.
Definition: noise.hpp:637
static std::string desc() noexcept
Returns a textual representation of the operator.
Definition: noise.hpp:440
T apply(const T &x) const
Apply the unary operator on x.
Definition: noise.hpp:513
T apply(const T &x) const
Apply the unary operator on x.
Definition: noise.hpp:227
Unary operation applying a logistic noise.
Definition: noise.hpp:574
static T apply(const T &x)
Apply the unary operator on x.
Definition: noise.hpp:279
Root namespace for the ETL library.
Definition: adapter.hpp:15
state_logistic_noise_unary_g_op(G &rand_engine)
Construct a new state_logistic_noise_unary_g_op.
Definition: noise.hpp:586
auto gpu_compute_hint(const X &x, Y &y) const noexcept
Compute the result of the operation using the GPU.
Definition: noise.hpp:403
T apply(const T &x) const
Apply the unary operator on x.
Definition: noise.hpp:389
static std::string desc() noexcept
Returns a textual representation of the operator.
Definition: noise.hpp:175
static constexpr int complexity()
Estimate the complexity of operator.
Definition: noise.hpp:270
static std::string desc() noexcept
Returns a textual representation of the operator.
Definition: noise.hpp:684
static constexpr int complexity()
Estimate the complexity of operator.
Definition: noise.hpp:380
Unary operation applying a logistic noise.
Definition: noise.hpp:454
Unary operation applying a logistic noise.
Definition: noise.hpp:346
decltype(auto) force_temporary_gpu_dim_only(E &&expr)
Force a temporary out of the expression, without copying its content.
Definition: temporary.hpp:223
state_logistic_noise_unary_g_op(G &rand_engine, const std::shared_ptr< void *> &states)
Construct a new state_logistic_noise_unary_g_op.
Definition: noise.hpp:598
constexpr size_t size(const E &expr) noexcept
Returns the size of the given ETL expression.
Definition: helpers.hpp:108
logistic_noise_unary_g_op(G &rand_engine)
Construct a new logistic_noise_unary_g_op.
Definition: noise.hpp:357
std::shared_ptr< void * > states
The random generator extra states.
Definition: noise.hpp:482
static Y & gpu_compute(const X &x, Y &y) noexcept
Compute the result of the operation using the GPU.
Definition: noise.hpp:316
state_logistic_noise_unary_op(const std::shared_ptr< void *> states)
Construct a new operator.
Definition: noise.hpp:497
static std::string desc() noexcept
Returns a textual representation of the operator.
Definition: noise.hpp:237
random_engine rand_engine
The random generator.
Definition: noise.hpp:481
Y & gpu_compute(const X &x, Y &y) const noexcept
Compute the result of the operation using the GPU.
Definition: noise.hpp:422
std::mt19937_64 random_engine
The random engine used by the library.
Definition: random.hpp:22
static std::string desc() noexcept
Returns a textual representation of the operator.
Definition: noise.hpp:560
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
Unary operation applying a logistic noise.
Definition: noise.hpp:247
static auto gpu_compute_hint(const X &x, Y &y) noexcept
Compute the result of the operation using the GPU.
Definition: noise.hpp:295
Y & gpu_compute(const X &x, Y &y) const noexcept
Compute the result of the operation using the GPU.
Definition: noise.hpp:668
static std::string desc() noexcept
Returns a textual representation of the operator.
Definition: noise.hpp:336