hls4ml
hls4ml copied to clipboard
append applied_flows container before filling instead of after
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.
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.
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.
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.