Skip to content

Instantly share code, notes, and snippets.

@sbugrov
Created Sep 2, 2017
Embed
What would you like to do?
__global__ void kSigmoid(float const *input, float *output) {
/* Computes the value of the sigmoid function f(x) = 1/(1 + e^-x).
Inputs:
input: array
output: array, the results of the computation are to be stored here
*/
const int id = blockIdx.x * blockDim.x + threadIdx.x;
output[id] = 1.0 / (1.0 + std::exp(-input[id]));
}
__device__ void dSigmoid(float const *input, float *output, const int height, const int width){
kSigmoid <<< height, width >>> (input, output);
cudaDeviceSynchronize();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment