hls4ml icon indicating copy to clipboard operation
hls4ml copied to clipboard

append applied_flows container before filling instead of after

Open jmitrevs opened this issue 2 years ago • 2 comments

Description

This change simply appends applied_flows to ModelGraph._applied_flows in the beginning, before it is filled, so that ModelGraph._applied_flows always has an accurate description of what has been applied. This is important in the FIFO depth optimization, because the FifoDepthOptimization runs the writer flow outside of the main flow, before the flow is finished and before ModelGraph._applied_flows is updated, so currently it sees ModelGraph._applied_flows == [], and since the writer depends on 'vivado:ip', all the optimizers are run again, which sometimes messes things up. For example, running on a ResNet sample, rerunning the optimizers changes a type from being PackedType to just being FixedPrecisionType, causing it to fail. This way, ModelGraph._applied_flows is always current so the out of main flow writer does not run 'vivado:ip' again.

I also updated a few empty lists to empty sets so that applied_flows is always a dictionary of sets, not a dictionary of sets or empty lists.

Type of change

  • [x] Bug fix (non-breaking change that fixes an issue)

Tests

The main test is to see that this doesn't break the current pytests. The FIFO optimization is too long to run as a standard test.

Checklist

  • [x] I have read the guidelines for contributing.
  • [x] I have commented my code, particularly in hard-to-understand areas.
  • [x] I have made corresponding changes to the documentation.
  • [x] My changes generate no new warnings.

jmitrevs avatar Aug 22 '22 23:08 jmitrevs

There is a change in the fifo depth optimization discussed in in in #642, basically getting rid of the explict, out of flow write called from the optimizer, that would make this change unnecessary in the case I mentioned, though this change would still be beneficial, I believe.

jmitrevs avatar Aug 23 '22 10:08 jmitrevs

I think this change should go in since it fixes the current fifo depth optimization, and even if we change how we do the optimization, this will have no ill effect.

jmitrevs avatar Sep 26 '22 22:09 jmitrevs

Any more thoughts on this? I have to tell people to use it if they are doing fifo depth optimization, which is a bit annoying.

jmitrevs avatar Oct 24 '22 14:10 jmitrevs