Skip to content

Instantly share code, notes, and snippets.

@sbugrov
Created September 2, 2017 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbugrov/ca710ec2025c410221548d5c89c416ce to your computer and use it in GitHub Desktop.
Save sbugrov/ca710ec2025c410221548d5c89c416ce to your computer and use it in GitHub Desktop.
__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