fpgasystems / spooNN

FPGA-based neural network inference project with an end-to-end approach (from training to implementation to deployment)
GNU Affero General Public License v3.0
259 stars 74 forks source link

What is the meaning of K, S,Din, Cin, etc? #20

Closed yunlong12 closed 5 years ago

yunlong12 commented 5 years ago

Hi kaankara, Thanks for your code. They are very good. I am now looking through the "halfsqueezenet-config.h" and I am wondering what is the meaning of K, S, Din, Cin, Cout, Ibit, Wbit, Mbit, Abit,SWU_Outp, MVTU_InP and MVTU_OutP, in the following code? // conv1/Conv2D // Cycles per IFM: 451584.0

define L0_K 3

define L0_S 2

define L0_Din 224

define L0_Cin 3

define L0_Cout 32

define L0_Ibit 8

define L0_Wbit 20

define L0_Mbit 32

define L0_Abit 5

define L0_SWU_OutP 1

define L0_MVTU_InP 3

define L0_MVTU_OutP 8

Thanks very much.

kaankara commented 5 years ago

*** Template variable explanations K: Kernel size S: Stride Din_W: Input feature map width Din_H: Input feature map height Cin: Input feature map depth (number of input channels) Cout: Output feature map depth (number of output channels) Ibit: Bitwidth for input feature map Wbit: Bitwidth for weights Mbit: Bitwidth of multiply-accumulate registers Abit: Bitwidth for activation function result SWU_OutP: Sliding-Window-Unit processing element (output) parallelism MVTU_InP: Matrix-Vector-Multiplication-Unit SIMD (input) parallelism MVTU_OutP: Matrix-Vector-Multiplication-Unit processing element (output) parallelism

kim-sunghoon commented 5 years ago

Hi, @kaankara Thanks for awesome codes. I am now looking through your repo and plan to transform it into the classification task (cifar and imagenet) and multi-object detection task like coco. I would appreciate that if you answer a few questions.

  1. at evalute.py & *-config.h I can not understand the meaning of the scale factors, i.e.

    • SCALE_BITS --> "full precision weight scale factor"
    • HIGH_PREC_SCALE_BITS --> "full precision weight scale factor with high precision"
    • FACTOR_SCALE_BITS --> "factor scale factor"
  2. numReps , NumLinesPerReps & 448 at mnist-cnn-1W5A.cpp

    
        // 2 rows of 28 row image per line -> per image 14 lines                                                                  
       const unsigned int NumLinesPerRep = 14;                                                                                                                                                                                                              
       stream<ap_uint<448> > in_stream_extract("in_stream_extract");                                                             
       ExtractPixels<448, NumLinesPerRep> (in, in_stream_extract, numReps);                                                      
       stream<ap_uint<L0_Cin*L0_Ibit> > in_stream("in_stream");                                                                  
       ReduceWidth<448, L0_Cin*L0_Ibit, NumLinesPerRep> (in_stream_extract, in_stream, numReps); 

I'm sure MNIST image size is 28x28x1 What's the meaning of row , NumLinesPerRep, 448 at stream declaration?

  1. at halfsqueezenet_folded.cpp similar to the mnist-cnn-1W5A.cpp
    
    #define USEFUL_LINE_BITS 480
    const unsigned NumLinesPerRep = 3136; 
    whichFire 
    factorA* & factorB*
    What's the meaning of these ... ?

Could you please explain these in more detail? Thank you very much.