fastmachinelearning/hls4ml

Vivado FIFO optimization overestimates first FIFO depth

rfforelli opened this issue · 0 comments

Quick summary

hls4ml's fifo optimization overestimates the size of my CNN's first layer output fifo.

Details

I am synthesizing a small CNN and using hls4ml's fifo optimization. The size of the output stream (layer28_out) of the first layer (zp2d_q_conv2d) is 6500 by default. However the FIFO optimization greatly overestimates this depth at 12238, almost double. I am using hls4ml 0.8.1 from pip.

Steps to Reproduce

files.zip

  1. download and unzip files.zip
  2. install conda environment with conda env create -f environment.yml.
  3. activate environment conda activate fifo_opt_issue.
  4. install kernel in jupyteripython kernel install --user --name=fifo_opt_issue.
  5. run notebook and wait for FIFO optimization to complete.
  6. See myproject.cpp, layer28_out is set to 12238.

image

Expected behavior

I would expect the layer depth to be equal to+1 or lower than the default hls4ml depth of 6500, since this is the full output size of the previous layer.

Actual behavior

The layer depth is set to almost double the size that should be required to accommodate the activations.

Optional

Possible fix

I understand the optimization reads the FIFO's internal usedw signal in vivado co-sim. Perhaps this is an issue with Xilinx software.

Additional context

I am using the extensions API to implement a custom layer. I am not sure if that might have any effect.
I can set the problematic stream's depth to 6500 post-fifo opt and the design runs on hardware without issue.