Transformation - FPGADataFlow

Transformations (FPGADataFlow)

finn.transformation.fpgadataflow.cleanup

class finn.transformation.fpgadataflow.cleanup.CleanUp

Bases: finn.transformation.Transformation

Remove any generated files for fpgadataflow nodes.

apply(model)

finn.transformation.fpgadataflow.codegen_ipgen

class finn.transformation.fpgadataflow.codegen_ipgen.CodeGen_ipgen(fpgapart, clk)

Bases: finn.transformation.Transformation

Call custom implementation to generate code for single custom node and create folder that contains all the generated files. All nodes in the graph must have the fpgadataflow backend attribute and transformation gets additional arguments:

  • fpgapart (string)

  • clk in ns (int)

Outcome if succesful: Node attribute “code_gen_dir_ipgen” contains path to folder that contains generated C++ code that can be used to generate a Vivado IP block. The subsequent transformation is HLSSynth_IPGen

apply(model)

finn.transformation.fpgadataflow.codegen_ipstitch

class finn.transformation.fpgadataflow.codegen_ipstitch.CodeGen_ipstitch(fpgapart)

Bases: finn.transformation.Transformation

Create a Vivado IP Block Design project from all the generated IPs of a graph. All nodes in the graph must have the fpgadataflow backend attribute, and the CodeGen_ipgen transformation must have been previously run on the graph. The resulting block design is also packaged as IP. The transformation gets the fpgapart as a string.

Outcome if successful: sets the vivado_stitch_proj attribute in the ONNX ModelProto’s metadata_props field, with the created project dir as the value. A make_project.tcl script is also placed under the same folder, which is called to instantiate the per-layer IPs and stitch them together. The packaged block design IP can be found under the ip subdirectory.

apply(model)

finn.transformation.fpgadataflow.codegen_npysim

class finn.transformation.fpgadataflow.codegen_npysim.CodeGen_npysim

Bases: finn.transformation.Transformation

Call custom implementation to generate code for single custom node and create folder that contains all the generated files. All nodes in the graph must have the fpgadataflow backend attribute.

Outcome if succesful: Node attribute “code_gen_dir_npysim” contains path to folder that contains generated C++ code that can be used to simulate node using npysim. The subsequent transformation is Compile

apply(model)

finn.transformation.fpgadataflow.compile

class finn.transformation.fpgadataflow.compile.Compile

Bases: finn.transformation.Transformation

For every node: compile C++ code in node attribute “code_gen_dir_npysim” and save path to executables in node attribute “executable_path”. All nodes in the graph must have the fpgadataflow backend attribute.

To use these executables, exec_mode must be set to “npysim” (using transformation SetExecMode) and the model has to be executed using execute_onnx() from finn.core.onnx_exec

apply(model)

finn.transformation.fpgadataflow.convert_to_hls_layers

class finn.transformation.fpgadataflow.convert_to_hls_layers.InferBinaryStreamingFCLayer

Bases: finn.transformation.Transformation

Convert pairs of binary XnorPopcountMatMul layers to StreamingFCLayer_Batch layers. Any immediately following MultiThreshold layers will also be absorbed into the MVTU.

apply(model)

finn.transformation.fpgadataflow.create_dataflow_partition

class finn.transformation.fpgadataflow.create_dataflow_partition.CreateDataflowPartition

Bases: finn.transformation.Transformation

Split a graph into two graphs; one which contains non-FINN-dataflow nodes and a StreamingDataflowPartition node, and another which only contains FINN dataflow nodes. The StreamingDataflowPartition has a model attribute that indicates the filename for the second graph that only contains dataflow nodes. No action is taken if there are no dataflow nodes.

apply(model)

finn.transformation.fpgadataflow.hlssynth_ipgen

class finn.transformation.fpgadataflow.hlssynth_ipgen.HLSSynth_IPGen

Bases: finn.transformation.Transformation

For each node: generate IP block from code in folder that is referenced in node attribute “code_gen_dir_ipgen” and save path of generated project in node attribute “ipgen_path”. All nodes in the graph must have the fpgadataflow backend attribute.

This transformation calls Vivado HLS for synthesis, so it will run for some time (several minutes)

apply(model)

finn.transformation.fpgadataflow.insert_tlastmarker

class finn.transformation.fpgadataflow.insert_tlastmarker.InsertTLastMarker

Bases: finn.transformation.Transformation

Ensure that the graph is terminated with a TLastMarker node, inserting one if necessary.

apply(model)

finn.transformation.fpgadataflow.make_deployment

class finn.transformation.fpgadataflow.make_deployment.DeployToPYNQ(ip, username, password, target_dir)

Bases: finn.transformation.Transformation

Collects all necessary files for deployment and copies them to the PYNQ board. Expects information about PYNQ board to make scp possible:

IP address of board, username and password for board and target directory where the files are stored on the board

apply(model)

finn.transformation.fpgadataflow.make_pynq_driver

class finn.transformation.fpgadataflow.make_pynq_driver.MakePYNQDriver

Bases: finn.transformation.Transformation

Create PYNQ Python code to correctly interface the generated accelerator, including data packing/unpacking. The MakePYNQProject transformation must have been already applied.

Outcome if successful: sets the pynq_driver_dir attribute in the ONNX ModelProto’s metadata_props field, with the created driver dir as the value.

apply(model)

finn.transformation.fpgadataflow.make_pynq_proj

class finn.transformation.fpgadataflow.make_pynq_proj.MakePYNQProject(platform)

Bases: finn.transformation.Transformation

Create a Vivado PYNQ overlay project (including the shell infrastructure) from the already-stitched IP block for this graph. All nodes in the graph must have the fpgadataflow backend attribute, and the CodeGen_ipstitch transformation must have been previously run on the graph.

Outcome if successful: sets the vivado_pynq_proj attribute in the ONNX ModelProto’s metadata_props field, with the created project dir as the value.

apply(model)

finn.transformation.fpgadataflow.replace_verilog_relpaths

class finn.transformation.fpgadataflow.replace_verilog_relpaths.ReplaceVerilogRelPaths

Bases: finn.transformation.Transformation

Convert ./ relative file paths to absolute ones for generated Verilog

apply(model)

finn.transformation.fpgadataflow.set_exec_mode

class finn.transformation.fpgadataflow.set_exec_mode.SetExecMode(mode)

Bases: finn.transformation.Transformation

Set attribute exec_mode in all fpgadataflow nodes to specify which kind of execution should be used (“npysim” or “rtlsim”)

apply(model)

finn.transformation.fpgadataflow.synth_pynq_proj

class finn.transformation.fpgadataflow.synth_pynq_proj.SynthPYNQProject

Bases: finn.transformation.Transformation

Run synthesis for the PYNQ project for this graph. The MakePYNQProject transformation must be applied prior to this transformation.

apply(model)

finn.transformation.fpgadataflow.templates