Optimized resizing of region_layer for random=1

This commit is contained in:
AlexeyAB
2018-02-21 15:35:09 +03:00
parent 4b0be8c701
commit e4ab47dfce
2 changed files with 9 additions and 4 deletions

View File

@ -378,6 +378,7 @@ int resize_network(network *net, int w, int h)
}
#ifdef GPU
if(gpu_index >= 0){
printf(" try to allocate workspace, ");
net->workspace = cuda_make_array(0, (workspace_size-1)/sizeof(float)+1);
printf(" CUDA allocate done! \n");
}else {

View File

@ -53,6 +53,8 @@ region_layer make_region_layer(int batch, int w, int h, int n, int classes, int
void resize_region_layer(layer *l, int w, int h)
{
int old_w = l->w;
int old_h = l->h;
l->w = w;
l->h = h;
@ -63,11 +65,13 @@ void resize_region_layer(layer *l, int w, int h)
l->delta = realloc(l->delta, l->batch*l->outputs*sizeof(float));
#ifdef GPU
if (old_w < w || old_h < h) {
cuda_free(l->delta_gpu);
cuda_free(l->output_gpu);
l->delta_gpu = cuda_make_array(l->delta, l->batch*l->outputs);
l->output_gpu = cuda_make_array(l->output, l->batch*l->outputs);
}
#endif
}