You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
#include <cuda_runtime.h>
|
|
#include <curand.h>
|
|
#include <cublas_v2.h>
|
|
|
|
#include "cuda.h"
|
|
|
|
#include "../layers/dropoutLayer.h"
|
|
|
|
__global__ void yoloswag420blazeit360noscope(float *input, int size, float *rand, float prob, float scale)
|
|
{
|
|
int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
|
|
if(id < size) input[id] = (rand[id] < prob) ? 0 : input[id]*scale;
|
|
}
|
|
|
|
void gpuCUDA::forward_layer(dropoutLayer *layer, cortexSTATE state){
|
|
if (!state.train) return;
|
|
int size = layer->m_nInput * layer->m_nBatch;
|
|
makeRandom(layer->m_pGpuRand, size);
|
|
/*
|
|
int i;
|
|
for(i = 0; i < size; ++i){
|
|
layer.rand[i] = rand_uniform();
|
|
}
|
|
cuda_push_array(layer.rand_gpu, layer.rand, size);
|
|
*/
|
|
yoloswag420blazeit360noscope << <gridSize(size), BLOCK >> >(
|
|
state.input,
|
|
size,
|
|
layer->m_pGpuRand,
|
|
layer->m_fProbability,
|
|
layer->m_fScale
|
|
);
|
|
checkError();// cudaPeekAtLastError());
|
|
}
|
|
|
|
void gpuCUDA::backward_layer(dropoutLayer *layer, cortexSTATE state){
|
|
if(!state.delta) return;
|
|
int size = layer->m_nInput*layer->m_nBatch;
|
|
yoloswag420blazeit360noscope << <gridSize(size), BLOCK >> >(
|
|
state.delta,
|
|
size,
|
|
layer->m_pGpuRand,
|
|
layer->m_fProbability,
|
|
layer->m_fScale
|
|
);
|
|
checkError();// cudaPeekAtLastError());
|
|
}
|