mirror of
https://github.com/lordmathis/CUDANet.git
synced 2025-11-06 01:34:22 +00:00
Remove not needed code
This commit is contained in:
@@ -2,18 +2,6 @@
|
||||
|
||||
#include "activations.cuh"
|
||||
|
||||
__device__ float sigmoid(float a) {
|
||||
return 1.0 / (1.0 + exp(-a));
|
||||
}
|
||||
|
||||
__device__ float relu(float a) {
|
||||
return a < 0.0 ? 0.0 : a;
|
||||
}
|
||||
|
||||
__device__ float linear(float a) {
|
||||
return a;
|
||||
}
|
||||
|
||||
__global__ void sigmoid_kernel(
|
||||
const float* __restrict__ src,
|
||||
float* __restrict__ dst,
|
||||
@@ -23,7 +11,7 @@ __global__ void sigmoid_kernel(
|
||||
int tid = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
|
||||
for (int i = tid; i < len; i += stride) {
|
||||
dst[i] = sigmoid(src[i]);
|
||||
dst[i] = 1.0 / (1.0 + exp(-src[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +21,7 @@ relu_kernel(const float* __restrict__ src, float* __restrict__ dst, int len) {
|
||||
int tid = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
|
||||
for (int i = tid; i < len; i += stride) {
|
||||
dst[i] = relu(src[i]);
|
||||
dst[i] = src[i] < 0.0 ? 0.0 : src[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +31,6 @@ linear_kernel(const float* __restrict__ src, float* __restrict__ dst, int len) {
|
||||
int tid = blockDim.x * blockIdx.x + threadIdx.x;
|
||||
|
||||
for (int i = tid; i < len; i += stride) {
|
||||
dst[i] = linear(src[i]);
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,8 @@ void Layers::Dense::forward(const float* d_input, float* d_output) {
|
||||
d_output, d_output, outputSize
|
||||
);
|
||||
}
|
||||
|
||||
CUDA_CHECK(cudaDeviceSynchronize());
|
||||
}
|
||||
|
||||
void Layers::Dense::toCuda() {
|
||||
|
||||
Reference in New Issue
Block a user