hls4ml icon indicating copy to clipboard operation
hls4ml copied to clipboard

Resource Modelling

Open AlexMontgomerie opened this issue 3 years ago • 3 comments

Hi, I was curious if there is any resource modelling in the repo? I noticed that there is a get_bram_size(self, layer) method for a HLS configuration, however I'm not clear as to whether this is for a layer or for the whole bitstream.

https://github.com/fastmachinelearning/hls4ml/blob/0ef2766cc0da5705e7f93906b2e489df56baeba7/hls4ml/model/hls_model.py#L121-L123

AlexMontgomerie avatar Nov 22 '21 16:11 AlexMontgomerie

Currently, bram_size (controlled by the BramFactor in the config) is the threshold above which weights will be implemented as BRAM ports (basically the #pragma HLS INTERFACE bram port=weight_name)

vloncar avatar Nov 22 '21 16:11 vloncar

@vloncar could you give me an example how to use the BramFactor in the config ?

HenningCode avatar Dec 01 '21 11:12 HenningCode

For example:

HLSConfig:
  Model:
    Precision: ap_fixed<16,6>
    ReuseFactor: 42
    BramFactor: 1337

Now every layer whose number of weights is larger than 1337 will be implemented as BRAM ports. (The other parameters here don't matter, I just put them so you see at what level are you supposed to put BramFactor)

vloncar avatar Dec 01 '21 15:12 vloncar