hls4ml
hls4ml copied to clipboard
Update inplace variables to not lose connection when source node is optimized.
In the original implementation, inplace variables are created when initializing an object, which can run into problems if the source node is changed due to optimizers. This PR moves the linking to a later stage, after the optimizations have run.
This is a replacement for #472, making use of the new features in the master branch.
I think I need to copy the type from the input_var
in the InplaceTensorVariable.__init__
. Let me test it a bit more extensively, though.
Some quartus-specific updates are in the QONNX PR #591. Should they be cherry-picked and added here, or is it fine to have them as part of that?
Actually, I see that #591 quite extensively modifies the code in this PR, so evaluating this PR independently I think is not useful. Extracting those changes is not very easy to do, either. Note how the optimizers have been reworked, with some going into fpga/passes. The structure of the InplaceTensorVariable
hasn't changed in that PR, though. It may be worth looking at that. This variable type is only created in passes (backends/vivado/passes/inplace_stream_flatten.py and backends/fpga/passes/inplace_parallel_reshape.py in #569) and transform_types handles the transformations appropriately.