finn-plus 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- finn/__init__.py +0 -0
- finn/analysis/__init__.py +0 -0
- finn/analysis/fpgadataflow/__init__.py +0 -0
- finn/analysis/fpgadataflow/dataflow_performance.py +78 -0
- finn/analysis/fpgadataflow/exp_cycles_per_layer.py +49 -0
- finn/analysis/fpgadataflow/floorplan_params.py +61 -0
- finn/analysis/fpgadataflow/hls_synth_res_estimation.py +81 -0
- finn/analysis/fpgadataflow/op_and_param_counts.py +60 -0
- finn/analysis/fpgadataflow/post_synth_res.py +133 -0
- finn/analysis/fpgadataflow/res_estimation.py +86 -0
- finn/analysis/verify_custom_nodes.py +49 -0
- finn/builder/__init__.py +0 -0
- finn/builder/build_dataflow.py +298 -0
- finn/builder/build_dataflow_config.py +457 -0
- finn/builder/build_dataflow_steps.py +866 -0
- finn/core/__init__.py +0 -0
- finn/core/onnx_exec.py +135 -0
- finn/core/rtlsim_exec.py +411 -0
- finn/core/throughput_test.py +85 -0
- finn/custom_hls/__init__.py +0 -0
- finn/custom_hls/checksum.cpp +36 -0
- finn/custom_hls/checksum.hpp +134 -0
- finn/custom_hls/checksum_tb.sv +136 -0
- finn/custom_hls/lookup.hpp +107 -0
- finn/custom_op/fpgadataflow/__init__.py +118 -0
- finn/custom_op/fpgadataflow/addstreams.py +152 -0
- finn/custom_op/fpgadataflow/attention.py +775 -0
- finn/custom_op/fpgadataflow/attention_heads.py +645 -0
- finn/custom_op/fpgadataflow/channelwise_op.py +249 -0
- finn/custom_op/fpgadataflow/concat.py +157 -0
- finn/custom_op/fpgadataflow/convolutioninputgenerator.py +268 -0
- finn/custom_op/fpgadataflow/downsampler.py +219 -0
- finn/custom_op/fpgadataflow/duplicatestreams.py +156 -0
- finn/custom_op/fpgadataflow/elementwise_binary.py +809 -0
- finn/custom_op/fpgadataflow/fmpadding.py +162 -0
- finn/custom_op/fpgadataflow/fmpadding_pixel.py +164 -0
- finn/custom_op/fpgadataflow/globalaccpool.py +150 -0
- finn/custom_op/fpgadataflow/hls/__init__.py +131 -0
- finn/custom_op/fpgadataflow/hls/addstreams_hls.py +116 -0
- finn/custom_op/fpgadataflow/hls/attention_heads_hls.py +490 -0
- finn/custom_op/fpgadataflow/hls/attention_hls.py +809 -0
- finn/custom_op/fpgadataflow/hls/channelwise_op_hls.py +354 -0
- finn/custom_op/fpgadataflow/hls/checksum_hls.py +256 -0
- finn/custom_op/fpgadataflow/hls/concat_hls.py +183 -0
- finn/custom_op/fpgadataflow/hls/convolutioninputgenerator_hls.py +551 -0
- finn/custom_op/fpgadataflow/hls/downsampler_hls.py +90 -0
- finn/custom_op/fpgadataflow/hls/duplicatestreams_hls.py +156 -0
- finn/custom_op/fpgadataflow/hls/elementwise_binary_hls.py +766 -0
- finn/custom_op/fpgadataflow/hls/fmpadding_hls.py +138 -0
- finn/custom_op/fpgadataflow/hls/fmpadding_pixel_hls.py +92 -0
- finn/custom_op/fpgadataflow/hls/globalaccpool_hls.py +100 -0
- finn/custom_op/fpgadataflow/hls/iodma_hls.py +399 -0
- finn/custom_op/fpgadataflow/hls/labelselect_hls.py +138 -0
- finn/custom_op/fpgadataflow/hls/lookup_hls.py +228 -0
- finn/custom_op/fpgadataflow/hls/matrixvectoractivation_hls.py +582 -0
- finn/custom_op/fpgadataflow/hls/pool_hls.py +133 -0
- finn/custom_op/fpgadataflow/hls/replicate_stream_hls.py +253 -0
- finn/custom_op/fpgadataflow/hls/split_hls.py +302 -0
- finn/custom_op/fpgadataflow/hls/squeeze_hls.py +234 -0
- finn/custom_op/fpgadataflow/hls/streamingdatawidthconverter_hls.py +124 -0
- finn/custom_op/fpgadataflow/hls/streamingeltwise_hls.py +167 -0
- finn/custom_op/fpgadataflow/hls/streamingmaxpool_hls.py +135 -0
- finn/custom_op/fpgadataflow/hls/thresholding_hls.py +724 -0
- finn/custom_op/fpgadataflow/hls/tlastmarker_hls.py +259 -0
- finn/custom_op/fpgadataflow/hls/unsqueeze_hls.py +234 -0
- finn/custom_op/fpgadataflow/hls/upsampler_hls.py +98 -0
- finn/custom_op/fpgadataflow/hls/vectorvectoractivation_hls.py +533 -0
- finn/custom_op/fpgadataflow/hlsbackend.py +567 -0
- finn/custom_op/fpgadataflow/hwcustomop.py +456 -0
- finn/custom_op/fpgadataflow/labelselect.py +168 -0
- finn/custom_op/fpgadataflow/lookup.py +223 -0
- finn/custom_op/fpgadataflow/matrixvectoractivation.py +1018 -0
- finn/custom_op/fpgadataflow/pool.py +217 -0
- finn/custom_op/fpgadataflow/replicate_stream.py +300 -0
- finn/custom_op/fpgadataflow/rtl/__init__.py +51 -0
- finn/custom_op/fpgadataflow/rtl/convolutioninputgenerator_rtl.py +980 -0
- finn/custom_op/fpgadataflow/rtl/fmpadding_rtl.py +188 -0
- finn/custom_op/fpgadataflow/rtl/matrixvectoractivation_rtl.py +356 -0
- finn/custom_op/fpgadataflow/rtl/streamingdatawidthconverter_rtl.py +147 -0
- finn/custom_op/fpgadataflow/rtl/streamingfifo_rtl.py +222 -0
- finn/custom_op/fpgadataflow/rtl/thresholding_rtl.py +509 -0
- finn/custom_op/fpgadataflow/rtl/vectorvectoractivation_rtl.py +312 -0
- finn/custom_op/fpgadataflow/rtlbackend.py +149 -0
- finn/custom_op/fpgadataflow/split.py +164 -0
- finn/custom_op/fpgadataflow/squeeze.py +329 -0
- finn/custom_op/fpgadataflow/streamingdataflowpartition.py +117 -0
- finn/custom_op/fpgadataflow/streamingdatawidthconverter.py +209 -0
- finn/custom_op/fpgadataflow/streamingeltwise.py +203 -0
- finn/custom_op/fpgadataflow/streamingfifo.py +200 -0
- finn/custom_op/fpgadataflow/streamingmaxpool.py +224 -0
- finn/custom_op/fpgadataflow/templates.py +265 -0
- finn/custom_op/fpgadataflow/thresholding.py +286 -0
- finn/custom_op/fpgadataflow/unsqueeze.py +330 -0
- finn/custom_op/fpgadataflow/upsampler.py +181 -0
- finn/custom_op/fpgadataflow/vectorvectoractivation.py +918 -0
- finn/finn-rtllib/__init__.py +0 -0
- finn/finn-rtllib/axi_info/component.xml +717 -0
- finn/finn-rtllib/axi_info/hdl/axi_info.sv +119 -0
- finn/finn-rtllib/axi_info/hdl/axi_info_top.sv +98 -0
- finn/finn-rtllib/axi_info/xgui/axi_info_top_v1_0.tcl +69 -0
- finn/finn-rtllib/dwc/hdl/dwc.sv +158 -0
- finn/finn-rtllib/dwc/hdl/dwc_axi.sv +65 -0
- finn/finn-rtllib/dwc/hdl/dwc_template.v +71 -0
- finn/finn-rtllib/dwc/sim/dwc_axi_tb.sv +195 -0
- finn/finn-rtllib/fifo/hdl/Q_srl.v +318 -0
- finn/finn-rtllib/fifo/hdl/fifo_template.v +72 -0
- finn/finn-rtllib/fmpadding/hdl/axi2we.sv +122 -0
- finn/finn-rtllib/fmpadding/hdl/fmpadding.sv +223 -0
- finn/finn-rtllib/fmpadding/hdl/fmpadding_axi.sv +123 -0
- finn/finn-rtllib/fmpadding/hdl/fmpadding_axi_tb.sv +154 -0
- finn/finn-rtllib/fmpadding/hdl/fmpadding_template.v +119 -0
- finn/finn-rtllib/memstream/doc/README +45 -0
- finn/finn-rtllib/memstream/hdl/axilite_if.v +210 -0
- finn/finn-rtllib/memstream/hdl/memstream.sv +221 -0
- finn/finn-rtllib/memstream/hdl/memstream_axi.sv +265 -0
- finn/finn-rtllib/memstream/hdl/memstream_wrapper_template.v +120 -0
- finn/finn-rtllib/memstream/sim/memstream_axi_tb.sv +223 -0
- finn/finn-rtllib/memstream/sim/memstream_tb.sv +212 -0
- finn/finn-rtllib/mvu/mvu_4sx4u.sv +830 -0
- finn/finn-rtllib/mvu/mvu_8sx8u_dsp48.sv +653 -0
- finn/finn-rtllib/mvu/mvu_vvu_8sx9_dsp58.sv +449 -0
- finn/finn-rtllib/mvu/mvu_vvu_axi.sv +424 -0
- finn/finn-rtllib/mvu/mvu_vvu_axi_wrapper.v +98 -0
- finn/finn-rtllib/mvu/replay_buffer.sv +181 -0
- finn/finn-rtllib/mvu/tb/mvu_3sx3u_tb.sv +165 -0
- finn/finn-rtllib/mvu/tb/mvu_8sx9_tb.sv +165 -0
- finn/finn-rtllib/mvu/tb/mvu_accu_tb.dat +192 -0
- finn/finn-rtllib/mvu/tb/mvu_accu_tb.sv +162 -0
- finn/finn-rtllib/mvu/tb/mvu_axi_tb.sv +255 -0
- finn/finn-rtllib/mvu/tb/mvu_dsp58_tb.sv +142 -0
- finn/finn-rtllib/mvu/tb/replay_buffer_tb.sv +130 -0
- finn/finn-rtllib/mvu/tb/vvu_axi_tb.sv +227 -0
- finn/finn-rtllib/passthru/rtl/passthru_axi.sv +57 -0
- finn/finn-rtllib/passthru/rtl/passthru_template_wrapper.v +62 -0
- finn/finn-rtllib/swg/swg_common.sv +248 -0
- finn/finn-rtllib/swg/swg_pkg.sv +41 -0
- finn/finn-rtllib/swg/swg_template_axilite.v +593 -0
- finn/finn-rtllib/swg/swg_template_default.sv +237 -0
- finn/finn-rtllib/swg/swg_template_default_dynamic.sv +417 -0
- finn/finn-rtllib/swg/swg_template_parallel.sv +216 -0
- finn/finn-rtllib/swg/swg_template_wrapper.v +78 -0
- finn/finn-rtllib/swg/swg_template_wrapper_dynamic.v +187 -0
- finn/finn-rtllib/thresholding/hdl/axilite_if.v +211 -0
- finn/finn-rtllib/thresholding/hdl/thresholding.sv +372 -0
- finn/finn-rtllib/thresholding/hdl/thresholding_axi.sv +199 -0
- finn/finn-rtllib/thresholding/hdl/thresholding_template_wrapper.v +122 -0
- finn/finn-rtllib/thresholding/sim/thresh_gen.sv +75 -0
- finn/finn-rtllib/thresholding/sim/thresholding_axi_tb.sv +314 -0
- finn/finn-rtllib/thresholding/sim/thresholding_tb.sv +274 -0
- finn/interface/__init__.py +4 -0
- finn/interface/interface_globals.py +95 -0
- finn/interface/interface_utils.py +161 -0
- finn/interface/manage_deps.py +308 -0
- finn/interface/manage_tests.py +90 -0
- finn/interface/run_finn.py +394 -0
- finn/notebooks/LFCW1A1.onnx +0 -0
- finn/notebooks/advanced/0_custom_analysis_pass.ipynb +161 -0
- finn/notebooks/advanced/1_custom_transformation_pass.ipynb +258 -0
- finn/notebooks/advanced/2_custom_op.ipynb +680 -0
- finn/notebooks/advanced/3_folding.ipynb +669 -0
- finn/notebooks/advanced/4_advanced_builder_settings.ipynb +1844 -0
- finn/notebooks/advanced/cnv-w2a2_folding_config.json +79 -0
- finn/notebooks/advanced/cybsec_PE_SIMD.onnx +0 -0
- finn/notebooks/advanced/finn-dataflow.png +0 -0
- finn/notebooks/advanced/finn-folding-mvau.png +0 -0
- finn/notebooks/advanced/finn-folding.png +0 -0
- finn/notebooks/basics/0_how_to_work_with_onnx.ipynb +621 -0
- finn/notebooks/basics/1_brevitas_network_import_via_QONNX.ipynb +326 -0
- finn/notebooks/end2end_example/README.md +13 -0
- finn/notebooks/end2end_example/bnn-pynq/StreamingDataflowPartition_1.pdf +4211 -0
- finn/notebooks/end2end_example/bnn-pynq/cnv-mp-fc.png +0 -0
- finn/notebooks/end2end_example/bnn-pynq/cnv_end2end_example.ipynb +650 -0
- finn/notebooks/end2end_example/bnn-pynq/finn-design-flow-example.svg +1 -0
- finn/notebooks/end2end_example/bnn-pynq/finn-hw-arch.png +0 -0
- finn/notebooks/end2end_example/bnn-pynq/pynq_shell_project.png +0 -0
- finn/notebooks/end2end_example/bnn-pynq/stitched_ip.png +0 -0
- finn/notebooks/end2end_example/bnn-pynq/tfc_end2end_example.ipynb +1086 -0
- finn/notebooks/end2end_example/bnn-pynq/tfc_end2end_verification.ipynb +468 -0
- finn/notebooks/end2end_example/bnn-pynq/top.pdf +2755 -0
- finn/notebooks/end2end_example/bnn-pynq/verification.svg +1 -0
- finn/notebooks/end2end_example/cybersecurity/1-train-mlp-with-brevitas.ipynb +770 -0
- finn/notebooks/end2end_example/cybersecurity/2-import-into-finn-and-verify.ipynb +509 -0
- finn/notebooks/end2end_example/cybersecurity/3-build-accelerator-with-finn.ipynb +667 -0
- finn/notebooks/end2end_example/cybersecurity/README.md +21 -0
- finn/notebooks/end2end_example/cybersecurity/dataloader_quantized.py +398 -0
- finn/notebooks/end2end_example/cybersecurity/finn-example.png +0 -0
- finn/notebooks/end2end_example/cybersecurity/state_dict.pth +0 -0
- finn/notebooks/end2end_example/cybersecurity/validate-unsw-nb15.py +101 -0
- finn/qnn-data/__init__.py +0 -0
- finn/qnn-data/build_dataflow/build.py +70 -0
- finn/qnn-data/build_dataflow/dataflow_build_config.json +28 -0
- finn/qnn-data/build_dataflow/expected_output.npy +0 -0
- finn/qnn-data/build_dataflow/folding_config.json +29 -0
- finn/qnn-data/build_dataflow/input.npy +0 -0
- finn/qnn-data/build_dataflow/model.onnx +0 -0
- finn/qnn-data/build_dataflow/specialize_layers_config.json +21 -0
- finn/qnn-data/cifar10/cifar10-test-data-class3.npz +0 -0
- finn/qnn-data/cpp/npy2apintstream.hpp +80 -0
- finn/qnn-data/cpp/npy2vectorstream.hpp +72 -0
- finn/qnn-data/cpp/xsi_simdriver.cpp +444 -0
- finn/qnn-data/cybsec-mlp/state_dict.pth +0 -0
- finn/qnn-data/cybsec-mlp/validate-unsw-nb15.py +105 -0
- finn/qnn-data/mdd-data/finn_design.mdd +36 -0
- finn/qnn-data/mdd-data/finn_design.tcl +60 -0
- finn/qnn-data/templates/driver/driver_base.py +488 -0
- finn/qnn-data/templates/driver/validate.py +107 -0
- finn/qnn-data/test_ext_weights/specialize_layers_config.json +30 -0
- finn/qnn-data/test_ext_weights/tfc-w2a2-extw.json +38 -0
- finn/qnn-data/testcase/residual_testcase.onnx +0 -0
- finn/qnn-data/verilog/custom_axis_infrastructure.vh +346 -0
- finn/qnn-data/verilog/myadd/myadd_myadd.v +118 -0
- finn/qnn-data/verilog/myadd/myadd_myadd_control_s_axi.v +357 -0
- finn/tests/brevitas/king_charles.jpg +0 -0
- finn/tests/brevitas/test_brevitas_avg_pool_export.py +114 -0
- finn/tests/brevitas/test_brevitas_cnv.py +81 -0
- finn/tests/brevitas/test_brevitas_debug.py +98 -0
- finn/tests/brevitas/test_brevitas_deconv.py +82 -0
- finn/tests/brevitas/test_brevitas_fc.py +87 -0
- finn/tests/brevitas/test_brevitas_mobilenet.py +130 -0
- finn/tests/brevitas/test_brevitas_non_scaled_quanthardtanh_export.py +87 -0
- finn/tests/brevitas/test_brevitas_qconv2d.py +108 -0
- finn/tests/brevitas/test_brevitas_qlinear.py +83 -0
- finn/tests/brevitas/test_brevitas_relu_act_export.py +105 -0
- finn/tests/brevitas/test_brevitas_scaled_qhardtanh_export.py +123 -0
- finn/tests/brevitas/test_brevitas_selu_act_export.py +73 -0
- finn/tests/brevitas/test_brevitas_validate_mobilenet.py +214 -0
- finn/tests/conftest.py +91 -0
- finn/tests/end2end/test_end2end_bnn_pynq.py +824 -0
- finn/tests/end2end/test_end2end_cybsec_mlp.py +191 -0
- finn/tests/end2end/test_end2end_mobilenet_v1.py +523 -0
- finn/tests/end2end/test_ext_weights.py +103 -0
- finn/tests/fpgadataflow/test_code_gen_trafo.py +98 -0
- finn/tests/fpgadataflow/test_compilation_trafo.py +95 -0
- finn/tests/fpgadataflow/test_convert_to_hw_1d_conv_layer.py +196 -0
- finn/tests/fpgadataflow/test_convert_to_hw_channelwise_layer.py +143 -0
- finn/tests/fpgadataflow/test_convert_to_hw_conv_fc_transition.py +226 -0
- finn/tests/fpgadataflow/test_convert_to_hw_conv_layer.py +198 -0
- finn/tests/fpgadataflow/test_convert_to_hw_layers_cnv.py +156 -0
- finn/tests/fpgadataflow/test_convert_to_hw_layers_fc.py +208 -0
- finn/tests/fpgadataflow/test_convert_to_hw_layers_synthetic.py +238 -0
- finn/tests/fpgadataflow/test_convert_to_hw_pool_batch.py +244 -0
- finn/tests/fpgadataflow/test_depthwise_convolution.py +242 -0
- finn/tests/fpgadataflow/test_elementwise_binary.py +834 -0
- finn/tests/fpgadataflow/test_fifosizing.py +180 -0
- finn/tests/fpgadataflow/test_fpgadataflow_addstreams.py +147 -0
- finn/tests/fpgadataflow/test_fpgadataflow_attention.py +537 -0
- finn/tests/fpgadataflow/test_fpgadataflow_attention_heads.py +411 -0
- finn/tests/fpgadataflow/test_fpgadataflow_channelwise_ops.py +174 -0
- finn/tests/fpgadataflow/test_fpgadataflow_checksum.py +228 -0
- finn/tests/fpgadataflow/test_fpgadataflow_concat.py +176 -0
- finn/tests/fpgadataflow/test_fpgadataflow_convinputgenerator.py +239 -0
- finn/tests/fpgadataflow/test_fpgadataflow_convinputgenerator_rtl_dynamic.py +611 -0
- finn/tests/fpgadataflow/test_fpgadataflow_deconv.py +206 -0
- finn/tests/fpgadataflow/test_fpgadataflow_downsampler.py +162 -0
- finn/tests/fpgadataflow/test_fpgadataflow_duplicatestreams.py +159 -0
- finn/tests/fpgadataflow/test_fpgadataflow_dwc.py +174 -0
- finn/tests/fpgadataflow/test_fpgadataflow_eltwise.py +143 -0
- finn/tests/fpgadataflow/test_fpgadataflow_fifo.py +111 -0
- finn/tests/fpgadataflow/test_fpgadataflow_fmpadding.py +163 -0
- finn/tests/fpgadataflow/test_fpgadataflow_globalaccpool.py +146 -0
- finn/tests/fpgadataflow/test_fpgadataflow_ipstitch.py +329 -0
- finn/tests/fpgadataflow/test_fpgadataflow_labelselect.py +138 -0
- finn/tests/fpgadataflow/test_fpgadataflow_lookup.py +192 -0
- finn/tests/fpgadataflow/test_fpgadataflow_mvau.py +817 -0
- finn/tests/fpgadataflow/test_fpgadataflow_replicate_stream.py +222 -0
- finn/tests/fpgadataflow/test_fpgadataflow_res_estimate.py +145 -0
- finn/tests/fpgadataflow/test_fpgadataflow_split.py +151 -0
- finn/tests/fpgadataflow/test_fpgadataflow_streamingmaxpool.py +182 -0
- finn/tests/fpgadataflow/test_fpgadataflow_thresholding.py +367 -0
- finn/tests/fpgadataflow/test_fpgadataflow_thresholding_runtime.py +347 -0
- finn/tests/fpgadataflow/test_fpgadataflow_upsampler.py +214 -0
- finn/tests/fpgadataflow/test_fpgadataflow_vvau.py +474 -0
- finn/tests/fpgadataflow/test_minimize_bit_width.py +304 -0
- finn/tests/fpgadataflow/test_runtime_weights.py +138 -0
- finn/tests/fpgadataflow/test_set_folding.py +136 -0
- finn/tests/fpgadataflow/test_split_large_fifos.py +123 -0
- finn/tests/fpgadataflow/test_squeeze.py +392 -0
- finn/tests/fpgadataflow/test_unsqueeze.py +397 -0
- finn/tests/infrastructure/custom_steps.py +2 -0
- finn/tests/infrastructure/test_custom_step_resolution.py +32 -0
- finn/tests/notebooks/test_jupyter_notebooks.py +110 -0
- finn/tests/test_enforce_import_order.py +43 -0
- finn/tests/transformation/streamline/test_absorb_mul_into_topk.py +108 -0
- finn/tests/transformation/streamline/test_absorb_opposite_transposes.py +81 -0
- finn/tests/transformation/streamline/test_absorb_transp_into_flatten.py +100 -0
- finn/tests/transformation/streamline/test_collapse_repeated_op.py +132 -0
- finn/tests/transformation/streamline/test_factor_out_mul_sign_magnitude.py +61 -0
- finn/tests/transformation/streamline/test_maxpool_nhwc.py +97 -0
- finn/tests/transformation/streamline/test_move_add_past_mul.py +150 -0
- finn/tests/transformation/streamline/test_move_chw_add_past_conv.py +107 -0
- finn/tests/transformation/streamline/test_move_flatten_past_affine.py +108 -0
- finn/tests/transformation/streamline/test_move_flatten_past_topk.py +94 -0
- finn/tests/transformation/streamline/test_move_identical_op_past_join_add.py +150 -0
- finn/tests/transformation/streamline/test_move_identical_op_past_join_concat.py +183 -0
- finn/tests/transformation/streamline/test_move_identical_op_past_split.py +142 -0
- finn/tests/transformation/streamline/test_move_maxpool_past_multithreshold.py +125 -0
- finn/tests/transformation/streamline/test_move_mul_past_dw_conv.py +118 -0
- finn/tests/transformation/streamline/test_move_mul_past_maxpool.py +116 -0
- finn/tests/transformation/streamline/test_move_past_fork.py +133 -0
- finn/tests/transformation/streamline/test_move_scalar_past_conv.py +196 -0
- finn/tests/transformation/streamline/test_move_scalar_past_convtranspose.py +106 -0
- finn/tests/transformation/streamline/test_move_scalar_past_matmul.py +190 -0
- finn/tests/transformation/streamline/test_move_transpose_past_scalar_mul.py +113 -0
- finn/tests/transformation/streamline/test_round_thresholds.py +270 -0
- finn/tests/transformation/streamline/test_scale_resize_nhwc.py +376 -0
- finn/tests/transformation/streamline/test_sign_to_thres.py +66 -0
- finn/tests/transformation/streamline/test_streamline_cnv.py +99 -0
- finn/tests/transformation/streamline/test_streamline_fc.py +96 -0
- finn/tests/transformation/test_batchnorm_to_affine_bnn_pynq.py +95 -0
- finn/tests/transformation/test_infer_data_layouts_cnv.py +124 -0
- finn/tests/transformation/test_infer_datatypes_lfc.py +68 -0
- finn/tests/transformation/test_qonnx_to_finn.py +141 -0
- finn/tests/util/test_build_dataflow.py +79 -0
- finn/tests/util/test_create.py +67 -0
- finn/tests/util/test_data_packing.py +183 -0
- finn/tests/util/test_hls_vector.py +118 -0
- finn/transformation/__init__.py +0 -0
- finn/transformation/fpgadataflow/__init__.py +0 -0
- finn/transformation/fpgadataflow/annotate_cycles.py +61 -0
- finn/transformation/fpgadataflow/annotate_resources.py +109 -0
- finn/transformation/fpgadataflow/attention.py +658 -0
- finn/transformation/fpgadataflow/attention_heads.py +824 -0
- finn/transformation/fpgadataflow/cleanup.py +84 -0
- finn/transformation/fpgadataflow/compile_cppsim.py +75 -0
- finn/transformation/fpgadataflow/convert_to_hw_layers.py +2090 -0
- finn/transformation/fpgadataflow/create_dataflow_partition.py +118 -0
- finn/transformation/fpgadataflow/create_stitched_ip.py +658 -0
- finn/transformation/fpgadataflow/derive_characteristic.py +186 -0
- finn/transformation/fpgadataflow/externalize_params.py +71 -0
- finn/transformation/fpgadataflow/floorplan.py +181 -0
- finn/transformation/fpgadataflow/get_driver_shapes.py +143 -0
- finn/transformation/fpgadataflow/hlssynth_ip.py +84 -0
- finn/transformation/fpgadataflow/infer_pixel_padding_deconv.py +205 -0
- finn/transformation/fpgadataflow/insert_dwc.py +133 -0
- finn/transformation/fpgadataflow/insert_fifo.py +307 -0
- finn/transformation/fpgadataflow/insert_hook.py +131 -0
- finn/transformation/fpgadataflow/insert_iodma.py +255 -0
- finn/transformation/fpgadataflow/insert_tlastmarker.py +159 -0
- finn/transformation/fpgadataflow/make_driver.py +461 -0
- finn/transformation/fpgadataflow/make_zynq_proj.py +361 -0
- finn/transformation/fpgadataflow/minimize_accumulator_width.py +57 -0
- finn/transformation/fpgadataflow/minimize_weight_bit_width.py +49 -0
- finn/transformation/fpgadataflow/prepare_cppsim.py +106 -0
- finn/transformation/fpgadataflow/prepare_ip.py +95 -0
- finn/transformation/fpgadataflow/prepare_rtlsim.py +72 -0
- finn/transformation/fpgadataflow/replace_verilog_relpaths.py +68 -0
- finn/transformation/fpgadataflow/replicate_stream.py +110 -0
- finn/transformation/fpgadataflow/set_exec_mode.py +64 -0
- finn/transformation/fpgadataflow/set_fifo_depths.py +629 -0
- finn/transformation/fpgadataflow/set_folding.py +287 -0
- finn/transformation/fpgadataflow/specialize_layers.py +323 -0
- finn/transformation/fpgadataflow/synth_ooc.py +65 -0
- finn/transformation/fpgadataflow/template_driver.py +143 -0
- finn/transformation/fpgadataflow/templates.py +207 -0
- finn/transformation/fpgadataflow/vitis_build.py +457 -0
- finn/transformation/move_reshape.py +68 -0
- finn/transformation/qonnx/__init__.py +0 -0
- finn/transformation/qonnx/convert_qonnx_to_finn.py +95 -0
- finn/transformation/qonnx/fold_quant_weights.py +238 -0
- finn/transformation/qonnx/infer_quant_avg_pool_2d.py +284 -0
- finn/transformation/qonnx/qonnx_activation_handlers.py +652 -0
- finn/transformation/qonnx/quant_act_to_multithreshold.py +153 -0
- finn/transformation/squeeze.py +428 -0
- finn/transformation/streamline/__init__.py +103 -0
- finn/transformation/streamline/absorb.py +721 -0
- finn/transformation/streamline/collapse_repeated.py +212 -0
- finn/transformation/streamline/remove.py +101 -0
- finn/transformation/streamline/reorder.py +2474 -0
- finn/transformation/streamline/round_thresholds.py +94 -0
- finn/transformation/streamline/sign_to_thres.py +73 -0
- finn/transformation/streamline/streamline_plus.py +110 -0
- finn/transformation/util.py +142 -0
- finn/util/__init__.py +0 -0
- finn/util/basic.py +311 -0
- finn/util/create.py +173 -0
- finn/util/data_packing.py +451 -0
- finn/util/deps.py +10 -0
- finn/util/fpgadataflow.py +71 -0
- finn/util/hls.py +74 -0
- finn/util/imagenet.py +1146 -0
- finn/util/logging.py +3 -0
- finn/util/platforms.py +505 -0
- finn/util/pytorch.py +65 -0
- finn/util/test.py +186 -0
- finn/util/visualization.py +62 -0
- finn/util/vivado.py +87 -0
- finn_plus-1.0.0.dist-info/AUTHORS.rst +40 -0
- finn_plus-1.0.0.dist-info/LICENSE.txt +33 -0
- finn_plus-1.0.0.dist-info/METADATA +144 -0
- finn_plus-1.0.0.dist-info/RECORD +392 -0
- finn_plus-1.0.0.dist-info/WHEEL +4 -0
- finn_plus-1.0.0.dist-info/entry_points.txt +3 -0
finn/__init__.py
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Copyright (c) 2020, Xilinx, Inc.
|
|
2
|
+
# Copyright (C) 2024, Advanced Micro Devices, Inc.
|
|
3
|
+
# All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
#
|
|
8
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
# list of conditions and the following disclaimer.
|
|
10
|
+
#
|
|
11
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
# and/or other materials provided with the distribution.
|
|
14
|
+
#
|
|
15
|
+
# * Neither the name of FINN nor the names of its
|
|
16
|
+
# contributors may be used to endorse or promote products derived from
|
|
17
|
+
# this software without specific prior written permission.
|
|
18
|
+
#
|
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
|
|
30
|
+
from qonnx.custom_op.registry import getCustomOp
|
|
31
|
+
|
|
32
|
+
from finn.util.fpgadataflow import is_hls_node, is_rtl_node
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def dataflow_performance(model):
|
|
36
|
+
"""Extract key performance indicators from given model with dataflow nodes.
|
|
37
|
+
Note that the latency (critical path) analysis is very pessimistic, it
|
|
38
|
+
assumes no overlap between executions and simply sums the expected cycles
|
|
39
|
+
for each node along the critical path.
|
|
40
|
+
|
|
41
|
+
Preconditions:
|
|
42
|
+
- model consists of HLS/RTL nodes
|
|
43
|
+
- model has cycle estimates annotated (see AnnotateCycles transformation)
|
|
44
|
+
- nodes have unique names (see GiveUniqueNodeNames)
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
- max_cycles : number of cycles for slowest node
|
|
48
|
+
- max_cycles_node_name : name of slowest node
|
|
49
|
+
- critical_path_cycles : pessimistic expected latency from input to output
|
|
50
|
+
"""
|
|
51
|
+
latency_at_node_output = {}
|
|
52
|
+
max_cycles = 0
|
|
53
|
+
max_node_name = ""
|
|
54
|
+
|
|
55
|
+
for node in model.graph.node:
|
|
56
|
+
if is_hls_node(node) or is_rtl_node(node):
|
|
57
|
+
inst = getCustomOp(node)
|
|
58
|
+
node_cycles = int(inst.get_nodeattr("cycles_estimate"))
|
|
59
|
+
if node_cycles > max_cycles:
|
|
60
|
+
max_cycles = node_cycles
|
|
61
|
+
max_node_name = node.name
|
|
62
|
+
if node.name not in latency_at_node_output:
|
|
63
|
+
# calculate based on input(s)
|
|
64
|
+
predecessors = model.find_direct_predecessors(node)
|
|
65
|
+
if predecessors is None:
|
|
66
|
+
# no predecessors, node is first node
|
|
67
|
+
max_pred_latency = 0
|
|
68
|
+
else:
|
|
69
|
+
# find max of any of predecessors
|
|
70
|
+
pred_latencies = map(lambda x: latency_at_node_output[x.name], predecessors)
|
|
71
|
+
max_pred_latency = max(pred_latencies)
|
|
72
|
+
latency_at_node_output[node.name] = node_cycles + max_pred_latency
|
|
73
|
+
critical_path_cycles = max(latency_at_node_output.values())
|
|
74
|
+
return {
|
|
75
|
+
"critical_path_cycles": int(critical_path_cycles),
|
|
76
|
+
"max_cycles": int(max_cycles),
|
|
77
|
+
"max_cycles_node_name": max_node_name,
|
|
78
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Copyright (c) 2020, Xilinx, Inc.
|
|
2
|
+
# Copyright (C) 2024, Advanced Micro Devices, Inc.
|
|
3
|
+
# All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
#
|
|
8
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
# list of conditions and the following disclaimer.
|
|
10
|
+
#
|
|
11
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
# and/or other materials provided with the distribution.
|
|
14
|
+
#
|
|
15
|
+
# * Neither the name of FINN nor the names of its
|
|
16
|
+
# contributors may be used to endorse or promote products derived from
|
|
17
|
+
# this software without specific prior written permission.
|
|
18
|
+
#
|
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
|
|
30
|
+
import qonnx.custom_op.registry as registry
|
|
31
|
+
|
|
32
|
+
from finn.util.fpgadataflow import is_hls_node, is_rtl_node
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def exp_cycles_per_layer(model):
|
|
36
|
+
"""Estimates the number of cycles per sample for dataflow layers in the given model.
|
|
37
|
+
Ensure that all nodes have unique names (by calling the GiveUniqueNodeNames
|
|
38
|
+
transformation) prior to calling this analysis pass to ensure all nodes are
|
|
39
|
+
visible in the results.
|
|
40
|
+
|
|
41
|
+
Returns {node name : cycle estimation}."""
|
|
42
|
+
|
|
43
|
+
cycle_dict = {}
|
|
44
|
+
for node in model.graph.node:
|
|
45
|
+
if is_hls_node(node) or is_rtl_node(node):
|
|
46
|
+
inst = registry.getCustomOp(node)
|
|
47
|
+
cycle_dict[node.name] = int(inst.get_exp_cycles())
|
|
48
|
+
|
|
49
|
+
return cycle_dict
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Copyright (c) 2020, Xilinx
|
|
2
|
+
# Copyright (C) 2024, Advanced Micro Devices, Inc.
|
|
3
|
+
# All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
#
|
|
8
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
# list of conditions and the following disclaimer.
|
|
10
|
+
#
|
|
11
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
# and/or other materials provided with the distribution.
|
|
14
|
+
#
|
|
15
|
+
# * Neither the name of FINN nor the names of its
|
|
16
|
+
# contributors may be used to endorse or promote products derived from
|
|
17
|
+
# this software without specific prior written permission.
|
|
18
|
+
#
|
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
|
|
30
|
+
from qonnx.custom_op.registry import getCustomOp
|
|
31
|
+
|
|
32
|
+
from finn.util.fpgadataflow import is_fpgadataflow_node
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def floorplan_params(model):
|
|
36
|
+
"""Gathers SLR and partition IDs from nodes.
|
|
37
|
+
|
|
38
|
+
Returns {node name : {slr, device id, partition id, memory port}}."""
|
|
39
|
+
|
|
40
|
+
ret_dict = {
|
|
41
|
+
"Defaults": {
|
|
42
|
+
"slr": [-1, ["all"]],
|
|
43
|
+
"partition_id": [0, ["all"]],
|
|
44
|
+
"device_id": [0, ["all"]],
|
|
45
|
+
"mem_port": ["", ["all"]],
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
for node in model.graph.node:
|
|
49
|
+
if is_fpgadataflow_node(node):
|
|
50
|
+
node_inst = getCustomOp(node)
|
|
51
|
+
node_slr = node_inst.get_nodeattr("slr")
|
|
52
|
+
node_pid = node_inst.get_nodeattr("partition_id")
|
|
53
|
+
node_mport = node_inst.get_nodeattr("mem_port")
|
|
54
|
+
ret_dict[node.name] = {
|
|
55
|
+
"slr": node_slr,
|
|
56
|
+
"partition_id": node_pid,
|
|
57
|
+
"device_id": 0,
|
|
58
|
+
"mem_port": node_mport,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return ret_dict
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Copyright (c) 2020, Xilinx
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
|
6
|
+
#
|
|
7
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
# list of conditions and the following disclaimer.
|
|
9
|
+
#
|
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
# and/or other materials provided with the distribution.
|
|
13
|
+
#
|
|
14
|
+
# * Neither the name of FINN nor the names of its
|
|
15
|
+
# contributors may be used to endorse or promote products derived from
|
|
16
|
+
# this software without specific prior written permission.
|
|
17
|
+
#
|
|
18
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
23
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
24
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
25
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
26
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
import os
|
|
29
|
+
import qonnx.custom_op.registry as registry
|
|
30
|
+
import xml.etree.ElementTree as ET
|
|
31
|
+
|
|
32
|
+
from finn.util.fpgadataflow import is_hls_node
|
|
33
|
+
from finn.util.logging import log
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def hls_synth_res_estimation(model):
|
|
37
|
+
"""Extracts the FPGA resource results from the Vitis HLS synthesis estimates.
|
|
38
|
+
Note that this analysis pass only works on nodes that have an HLS backend.
|
|
39
|
+
Ensure that all nodes have unique names (by calling the GiveUniqueNodeNames
|
|
40
|
+
transformation) prior to calling this analysis pass to ensure all nodes are
|
|
41
|
+
visible in the results.
|
|
42
|
+
|
|
43
|
+
Returns {node name : resources_dict}."""
|
|
44
|
+
|
|
45
|
+
res_dict = {}
|
|
46
|
+
for node in model.graph.node:
|
|
47
|
+
if is_hls_node(node):
|
|
48
|
+
# init values to zero
|
|
49
|
+
res_dict[node.name] = dict()
|
|
50
|
+
res_dict[node.name]["BRAM_18K"] = 0
|
|
51
|
+
res_dict[node.name]["FF"] = 0
|
|
52
|
+
res_dict[node.name]["LUT"] = 0
|
|
53
|
+
res_dict[node.name]["DSP48E"] = 0
|
|
54
|
+
res_dict[node.name]["URAM"] = 0
|
|
55
|
+
inst = registry.getCustomOp(node)
|
|
56
|
+
code_gen_dir = inst.get_nodeattr("code_gen_dir_ipgen")
|
|
57
|
+
if code_gen_dir == "":
|
|
58
|
+
log.warning(
|
|
59
|
+
"""Could not find report files, values will be set to zero
|
|
60
|
+
for this node. Please run "PrepareIP" transformation and
|
|
61
|
+
"HLSSynthIP" first to generate the report files"""
|
|
62
|
+
)
|
|
63
|
+
else:
|
|
64
|
+
xmlfile = "{}/project_{}/sol1/syn/report/{}_csynth.xml".format(
|
|
65
|
+
code_gen_dir, node.name, node.name
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
if os.path.isfile(xmlfile):
|
|
69
|
+
tree = ET.parse(xmlfile)
|
|
70
|
+
root = tree.getroot()
|
|
71
|
+
for item in root.findall("AreaEstimates/Resources"):
|
|
72
|
+
for child in item:
|
|
73
|
+
if child.text is not None:
|
|
74
|
+
res_dict[node.name][child.tag] = int(child.text)
|
|
75
|
+
else:
|
|
76
|
+
log.warning(
|
|
77
|
+
"""Could not find report files, values will be set to zero
|
|
78
|
+
for this node. Please run "PrepareIP" transformation and
|
|
79
|
+
"HLSSynthIP" first to generate the report files"""
|
|
80
|
+
)
|
|
81
|
+
return res_dict
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Copyright (c) 2020, Xilinx
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
|
6
|
+
#
|
|
7
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
# list of conditions and the following disclaimer.
|
|
9
|
+
#
|
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
# and/or other materials provided with the distribution.
|
|
13
|
+
#
|
|
14
|
+
# * Neither the name of FINN nor the names of its
|
|
15
|
+
# contributors may be used to endorse or promote products derived from
|
|
16
|
+
# this software without specific prior written permission.
|
|
17
|
+
#
|
|
18
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
23
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
24
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
25
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
26
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
|
|
29
|
+
import qonnx.custom_op.registry as registry
|
|
30
|
+
from qonnx.util.basic import is_finn_op
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def aggregate_dict_keys(res_dict):
|
|
34
|
+
total_dict = {}
|
|
35
|
+
for layer in res_dict:
|
|
36
|
+
layer_res_dict = res_dict[layer]
|
|
37
|
+
for r_type in layer_res_dict.keys():
|
|
38
|
+
if "efficiency" in r_type:
|
|
39
|
+
continue
|
|
40
|
+
r_amount = layer_res_dict[r_type]
|
|
41
|
+
r_amount = float(r_amount)
|
|
42
|
+
if r_type in total_dict.keys():
|
|
43
|
+
total_dict[r_type] += r_amount
|
|
44
|
+
else:
|
|
45
|
+
total_dict[r_type] = r_amount
|
|
46
|
+
return total_dict
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def op_and_param_counts(model):
|
|
50
|
+
"""Return per-node and aggregate op counts per inference."""
|
|
51
|
+
|
|
52
|
+
ret_dict = {}
|
|
53
|
+
for node in model.graph.node:
|
|
54
|
+
if is_finn_op(node.domain):
|
|
55
|
+
inst = registry.getCustomOp(node)
|
|
56
|
+
if hasattr(inst, "get_op_and_param_counts"):
|
|
57
|
+
node_op_and_param_counts = inst.get_op_and_param_counts()
|
|
58
|
+
ret_dict[node.name] = node_op_and_param_counts
|
|
59
|
+
ret_dict["total"] = aggregate_dict_keys(ret_dict)
|
|
60
|
+
return ret_dict
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Copyright (c) 2020, Xilinx, Inc.
|
|
2
|
+
# Copyright (C) 2024, Advanced Micro Devices, Inc.
|
|
3
|
+
# All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
|
7
|
+
#
|
|
8
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
# list of conditions and the following disclaimer.
|
|
10
|
+
#
|
|
11
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
# and/or other materials provided with the distribution.
|
|
14
|
+
#
|
|
15
|
+
# * Neither the name of FINN nor the names of its
|
|
16
|
+
# contributors may be used to endorse or promote products derived from
|
|
17
|
+
# this software without specific prior written permission.
|
|
18
|
+
#
|
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
|
|
30
|
+
import os
|
|
31
|
+
import xml.etree.ElementTree as ET
|
|
32
|
+
from qonnx.core.modelwrapper import ModelWrapper
|
|
33
|
+
from qonnx.custom_op.registry import getCustomOp
|
|
34
|
+
|
|
35
|
+
from finn.util.fpgadataflow import is_hls_node, is_rtl_node
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def post_synth_res(model, override_synth_report_filename=None):
|
|
39
|
+
"""Extracts the FPGA resource results from the Vivado synthesis.
|
|
40
|
+
Ensure that all nodes have unique names (by calling the GiveUniqueNodeNames
|
|
41
|
+
transformation) prior to calling this analysis pass to ensure all nodes are
|
|
42
|
+
visible in the results.
|
|
43
|
+
|
|
44
|
+
Returns {node name : resources_dict}."""
|
|
45
|
+
|
|
46
|
+
res_dict = {}
|
|
47
|
+
if override_synth_report_filename is not None:
|
|
48
|
+
synth_report_filename = override_synth_report_filename
|
|
49
|
+
else:
|
|
50
|
+
synth_report_filename = model.get_metadata_prop("vivado_synth_rpt")
|
|
51
|
+
if os.path.isfile(synth_report_filename):
|
|
52
|
+
tree = ET.parse(synth_report_filename)
|
|
53
|
+
root = tree.getroot()
|
|
54
|
+
all_cells = root.findall(".//tablecell")
|
|
55
|
+
# strip all whitespace from table cell contents
|
|
56
|
+
for cell in all_cells:
|
|
57
|
+
cell.attrib["contents"] = cell.attrib["contents"].strip()
|
|
58
|
+
else:
|
|
59
|
+
raise Exception("Please run synthesis first")
|
|
60
|
+
|
|
61
|
+
restype_to_ind_default = {
|
|
62
|
+
"LUT": 2,
|
|
63
|
+
"SRL": 5,
|
|
64
|
+
"FF": 6,
|
|
65
|
+
"BRAM_36K": 7,
|
|
66
|
+
"BRAM_18K": 8,
|
|
67
|
+
"DSP": 10,
|
|
68
|
+
}
|
|
69
|
+
restype_to_ind_vitis = {
|
|
70
|
+
"LUT": 4,
|
|
71
|
+
"SRL": 7,
|
|
72
|
+
"FF": 8,
|
|
73
|
+
"BRAM_36K": 9,
|
|
74
|
+
"BRAM_18K": 10,
|
|
75
|
+
"URAM": 11,
|
|
76
|
+
"DSP": 12,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# format: (human_readable_name_in_report, canonical_name)
|
|
80
|
+
res_types_to_search = [
|
|
81
|
+
("Total LUTs", "LUT"),
|
|
82
|
+
("SRLs", "SRL"),
|
|
83
|
+
("FFs", "FF"),
|
|
84
|
+
("RAMB36", "BRAM_36K"),
|
|
85
|
+
("RAMB18", "BRAM_18K"),
|
|
86
|
+
("URAM", "URAM"),
|
|
87
|
+
("DSP Blocks", "DSP"),
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
# try to infer resource type to table index by
|
|
91
|
+
# looking at the names in headings
|
|
92
|
+
header_row = root.findall(".//*[@contents='Instance']/..")
|
|
93
|
+
if header_row != []:
|
|
94
|
+
headers = [x.attrib["contents"] for x in list(header_row[0])]
|
|
95
|
+
restype_to_ind = {}
|
|
96
|
+
for res_type_name, res_type in res_types_to_search:
|
|
97
|
+
if res_type_name in headers:
|
|
98
|
+
restype_to_ind[res_type] = headers.index(res_type_name)
|
|
99
|
+
else:
|
|
100
|
+
# could not infer resource types from header
|
|
101
|
+
# fall back to default indices
|
|
102
|
+
if model.get_metadata_prop("platform") == "alveo":
|
|
103
|
+
restype_to_ind = restype_to_ind_vitis
|
|
104
|
+
else:
|
|
105
|
+
restype_to_ind = restype_to_ind_default
|
|
106
|
+
|
|
107
|
+
def get_instance_stats(inst_name):
|
|
108
|
+
row = root.findall(".//*[@contents='%s']/.." % inst_name)
|
|
109
|
+
if row != []:
|
|
110
|
+
node_dict = {}
|
|
111
|
+
row = list(row[0])
|
|
112
|
+
for restype, ind in restype_to_ind.items():
|
|
113
|
+
node_dict[restype] = int(row[ind].attrib["contents"])
|
|
114
|
+
return node_dict
|
|
115
|
+
else:
|
|
116
|
+
return None
|
|
117
|
+
|
|
118
|
+
# global (top-level) stats, including shell etc.
|
|
119
|
+
top_dict = get_instance_stats("(top)")
|
|
120
|
+
if top_dict is not None:
|
|
121
|
+
res_dict["(top)"] = top_dict
|
|
122
|
+
|
|
123
|
+
for node in model.graph.node:
|
|
124
|
+
if node.op_type == "StreamingDataflowPartition":
|
|
125
|
+
sdp_model = ModelWrapper(getCustomOp(node).get_nodeattr("model"))
|
|
126
|
+
sdp_res_dict = post_synth_res(sdp_model, synth_report_filename)
|
|
127
|
+
res_dict.update(sdp_res_dict)
|
|
128
|
+
elif is_hls_node(node) or is_rtl_node(node):
|
|
129
|
+
node_dict = get_instance_stats(node.name)
|
|
130
|
+
if node_dict is not None:
|
|
131
|
+
res_dict[node.name] = node_dict
|
|
132
|
+
|
|
133
|
+
return res_dict
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Copyright (c) 2020, Xilinx
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
|
6
|
+
#
|
|
7
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
# list of conditions and the following disclaimer.
|
|
9
|
+
#
|
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
# and/or other materials provided with the distribution.
|
|
13
|
+
#
|
|
14
|
+
# * Neither the name of FINN nor the names of its
|
|
15
|
+
# contributors may be used to endorse or promote products derived from
|
|
16
|
+
# this software without specific prior written permission.
|
|
17
|
+
#
|
|
18
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
23
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
24
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
25
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
26
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
|
|
29
|
+
import qonnx.custom_op.registry as registry
|
|
30
|
+
|
|
31
|
+
from finn.util.fpgadataflow import is_hls_node, is_rtl_node
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def res_estimation(model, fpgapart):
|
|
35
|
+
"""Estimates the resources needed for the given model.
|
|
36
|
+
Ensure that all nodes have unique names (by calling the GiveUniqueNodeNames
|
|
37
|
+
transformation) prior to calling this analysis pass to ensure all nodes are
|
|
38
|
+
visible in the results.
|
|
39
|
+
|
|
40
|
+
Returns {node name : resource estimation}."""
|
|
41
|
+
|
|
42
|
+
res_dict = {}
|
|
43
|
+
for node in model.graph.node:
|
|
44
|
+
if is_hls_node(node) or is_rtl_node(node):
|
|
45
|
+
inst = registry.getCustomOp(node)
|
|
46
|
+
res_dict[node.name] = inst.node_res_estimation(fpgapart)
|
|
47
|
+
|
|
48
|
+
return res_dict
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def res_estimation_complete(model, fpgapart):
|
|
52
|
+
"""Estimates the resources needed for the given model and all values for
|
|
53
|
+
resource-related switches.
|
|
54
|
+
Ensure that all nodes have unique names (by calling the GiveUniqueNodeNames
|
|
55
|
+
transformation) prior to calling this analysis pass to ensure all nodes are
|
|
56
|
+
visible in the results.
|
|
57
|
+
|
|
58
|
+
Returns {node name : [resource estimation(s)]}."""
|
|
59
|
+
|
|
60
|
+
res_dict = {}
|
|
61
|
+
for node in model.graph.node:
|
|
62
|
+
if is_hls_node(node) or is_rtl_node(node):
|
|
63
|
+
inst = registry.getCustomOp(node)
|
|
64
|
+
op_type = node.op_type
|
|
65
|
+
if op_type.startswith("MVAU") or op_type.startswith("VVAU"):
|
|
66
|
+
orig_restype = inst.get_nodeattr("resType")
|
|
67
|
+
res_dict[node.name] = []
|
|
68
|
+
inst.set_nodeattr("resType", "dsp")
|
|
69
|
+
res_dict[node.name].append(inst.node_res_estimation(fpgapart))
|
|
70
|
+
inst.set_nodeattr("resType", "lut")
|
|
71
|
+
res_dict[node.name].append(inst.node_res_estimation(fpgapart))
|
|
72
|
+
inst.set_nodeattr("resType", orig_restype)
|
|
73
|
+
elif op_type.startswith("ConvolutionInputGenerator"):
|
|
74
|
+
orig_ramstyle = inst.get_nodeattr("ram_style")
|
|
75
|
+
res_dict[node.name] = []
|
|
76
|
+
inst.set_nodeattr("ram_style", "block")
|
|
77
|
+
res_dict[node.name].append(inst.node_res_estimation(fpgapart))
|
|
78
|
+
inst.set_nodeattr("ram_style", "distributed")
|
|
79
|
+
res_dict[node.name].append(inst.node_res_estimation(fpgapart))
|
|
80
|
+
inst.set_nodeattr("ram_style", "ultra")
|
|
81
|
+
res_dict[node.name].append(inst.node_res_estimation(fpgapart))
|
|
82
|
+
inst.set_nodeattr("ram_style", orig_ramstyle)
|
|
83
|
+
else:
|
|
84
|
+
res_dict[node.name] = [inst.node_res_estimation(fpgapart)]
|
|
85
|
+
|
|
86
|
+
return res_dict
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Copyright (c) 2020, Xilinx
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
|
6
|
+
#
|
|
7
|
+
# * Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
# list of conditions and the following disclaimer.
|
|
9
|
+
#
|
|
10
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
# and/or other materials provided with the distribution.
|
|
13
|
+
#
|
|
14
|
+
# * Neither the name of FINN nor the names of its
|
|
15
|
+
# contributors may be used to endorse or promote products derived from
|
|
16
|
+
# this software without specific prior written permission.
|
|
17
|
+
#
|
|
18
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22
|
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
23
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
24
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
25
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
26
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
|
|
29
|
+
import qonnx.custom_op.registry as registry
|
|
30
|
+
from qonnx.util.basic import is_finn_op
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def verify_nodes(model):
|
|
34
|
+
"""Checks if custom ops in graph are correctly built, with all attributes
|
|
35
|
+
and inputs. Please note that many FINN CustomOps don't yet implement the
|
|
36
|
+
verify_node function required for this analysis pass to work correctly.
|
|
37
|
+
|
|
38
|
+
Returns {node op_type : info_messages}
|
|
39
|
+
|
|
40
|
+
* info_messages: is list of strings about the result of the verification."""
|
|
41
|
+
|
|
42
|
+
verification_dict = {}
|
|
43
|
+
for node in model.graph.node:
|
|
44
|
+
if is_finn_op(node.domain):
|
|
45
|
+
op_type = node.op_type
|
|
46
|
+
inst = registry.getCustomOp(node)
|
|
47
|
+
verification_dict[op_type] = inst.verify_node()
|
|
48
|
+
|
|
49
|
+
return verification_dict
|
finn/builder/__init__.py
ADDED
|
File without changes
|