blob: d6152ea8d356120fa06dacc6d27bf848a20e792e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include "THCUNN.h"
#include "THCHalf.h"
#include "THCHalfAutoNumerics.cuh"
#include <THC/THCApply.cuh>
template <typename T>
struct logSigmoid_updateOutput_functor
{
__device__ void operator()(T *output, const T *input) const
{
T z = exp(-*input);
*output = ScalarConvert<double, T>::to(-log(1. + z));
}
};
template <typename T>
struct logSigmoid_updateGradInput_functor
{
__device__ void operator()(T *gradInput, const T *input, const T *gradOutput) const
{
T z = exp(-*input);
*gradInput = ScalarConvert<double, T>::to(*gradOutput * z / (1. + z));
}
};
#include "generic/LogSigmoid.cu"
#include "THCGenerateFloatTypes.h"
|