AlexeyAB
2018-02-21 e4ab47dfcedb4c87e5eddf484caa4ac0c020fc9b
Optimized resizing of region_layer for random=1
2 files modified
13 ■■■■■ changed files
src/network.c 1 ●●●● patch | view | raw | blame | history
src/region_layer.c 12 ●●●●● patch | view | raw | blame | history
src/network.c
@@ -378,6 +378,7 @@
    }
#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 {
src/region_layer.c
@@ -53,6 +53,8 @@
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 @@
    l->delta = realloc(l->delta, l->batch*l->outputs*sizeof(float));
#ifdef GPU
    cuda_free(l->delta_gpu);
    cuda_free(l->output_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);
        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
}