Deepity
Ultra-fast, SIMD-accelerated Predictive Coding
Loading...
Searching...
No Matches
Tanh.h File Reference

tanh and its derivative (plain and two-buffer variants), with AVX512/AVX2/SSE paths and a scalar tail. More...

#include <cassert>
#include <cstddef>
#include <immintrin.h>
#include <omp.h>
#include <sleef.h>
#include <deepity/utils/activations/ActivationMacros.h>

Go to the source code of this file.

Namespaces

namespace  Deep
 This file exists to provide both Tensor.h and IComputeBackend.h with device types without introducing circular dependencies.

Functions

static void Deep::tanh (float *RESTRICT x, const size_t n) noexcept
 In-place hyperbolic tangent activation.
static void Deep::dTanh (float *RESTRICT x, const size_t n, const bool activated=false) noexcept
 In-place tanh derivative: 1 - tanh(x)^2.
static void Deep::dTanhInto (float *RESTRICT dst, const float *RESTRICT src, const size_t n) noexcept
 Two-buffer, single-pass tanh derivative: reads src, writes 1-tanh(src)^2 directly into dst. Unlike dTanh(x, n, false), which needs two full passes internally (activate in place, then derive in place) plus a separate copy beforehand if src can't be mutated, this computes tanh(src[i]) into a register and derives from that same register immediately, with only one read of src and one write to dst – no intermediate array pass at all.

Detailed Description

tanh and its derivative (plain and two-buffer variants), with AVX512/AVX2/SSE paths and a scalar tail.