Joseph Redmon
2016-11-08 4b60afcc640a340a87fa56431322a4bb4ae1cfea
src/reorg_layer.c
@@ -4,7 +4,7 @@
#include <stdio.h>
layer make_reorg_layer(int batch, int h, int w, int c, int stride)
layer make_reorg_layer(int batch, int h, int w, int c, int stride, int reverse)
{
    layer l = {0};
    l.type = REORG;
@@ -13,9 +13,15 @@
    l.h = h;
    l.w = w;
    l.c = c;
    if(reverse){
    l.out_w = w*stride;
    l.out_h = h*stride;
    l.out_c = c/(stride*stride);
    }else{
        l.out_w = w/stride;
        l.out_h = h/stride;
        l.out_c = c*(stride*stride);
    }
    fprintf(stderr, "Reorg Layer: %d x %d x %d image -> %d x %d x %d image, \n", w,h,c,l.out_w, l.out_h, l.out_c);
    l.outputs = l.out_h * l.out_w * l.out_c;
    l.inputs = h*w*c;
@@ -107,11 +113,19 @@
#ifdef GPU
void forward_reorg_layer_gpu(layer l, network_state state)
{
    if(l.reverse){
    reorg_ongpu(state.input, l.w, l.h, l.c, l.batch, l.stride, 1, l.output_gpu);
    }else {
        reorg_ongpu(state.input, l.w, l.h, l.c, l.batch, l.stride, 0, l.output_gpu);
    }
}
void backward_reorg_layer_gpu(layer l, network_state state)
{
    if(l.reverse){
    reorg_ongpu(l.delta_gpu, l.w, l.h, l.c, l.batch, l.stride, 0, state.delta);
    }else{
        reorg_ongpu(l.delta_gpu, l.w, l.h, l.c, l.batch, l.stride, 1, state.delta);
    }
}
#endif