doonny / PipeCNN

An OpenCL-based FPGA Accelerator for Convolutional Neural Networks
Apache License 2.0
1.22k stars 370 forks source link

maxpooling #39

Closed zhao-lun closed 6 years ago

zhao-lun commented 6 years ago
                for(unsigned int k=0; k<input_num; k++){
                if(pool_size==3)
            row_pool_reg[ll] = pool_max(line_buf_1[ll][line_buf_ptr], line_buf_0[ll][line_buf_ptr]);
        else // pool_size==2
            row_pool_reg[ll] = line_buf_0[ll][line_buf_ptr];`

        pool_reg[ll][0] = pool_max(row_pool_reg[ll], conv_ch_out.lane[ll]);

        // Max pooling among colums
        // with previous row-pooling results stored in shift-registers
        if(pool_size==3)
            col_pool_reg[ll] = pool_max(pool_reg[ll][1], pool_reg[ll][2]);
        else //pool_size==2
            col_pool_reg[ll] = pool_reg[ll][1];

        pool_final.lane[ll] = pool_max(col_pool_reg[ll], pool_reg[ll][0]);

        // Update line buffer   
        line_buf_1[ll][line_buf_ptr] = line_buf_0[ll][line_buf_ptr];
        line_buf_0[ll][line_buf_ptr] = conv_ch_out.lane[ll];`

Hi Prof @doonny, Can you explain how you make this work? Is this not square max pooling? Can i use pool_size ==2 ? If pool_size = 2 , the line_buf_1 seem redundant.

image

doonny commented 6 years ago

Yes, it is square pooling, and line_buf_1 will not be used if pool_size=2