From 99c09dc69a070204f3134c0562d30cf36c5eaa8c Mon Sep 17 00:00:00 2001 From: Yaman Umuroglu <yamanu@xilinx.com> Date: Fri, 27 Jan 2023 09:47:36 +0000 Subject: [PATCH] [Test] extend FIFO sizing test to cnv and premade conf --- tests/fpgadataflow/test_fifosizing.py | 39 ++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/fpgadataflow/test_fifosizing.py b/tests/fpgadataflow/test_fifosizing.py index 116df98d1..d2d3b642d 100644 --- a/tests/fpgadataflow/test_fifosizing.py +++ b/tests/fpgadataflow/test_fifosizing.py @@ -32,6 +32,8 @@ import pytest import json import shutil from brevitas.export.onnx.generic.manager import BrevitasONNXManager +from qonnx.core.modelwrapper import ModelWrapper +from qonnx.custom_op.registry import getCustomOp import finn.builder.build_dataflow as build import finn.builder.build_dataflow_config as build_cfg @@ -52,7 +54,14 @@ def fetch_test_model(topology, wbits=2, abits=2): @pytest.mark.parametrize( "method", ["largefifo_rtlsim_python", "largefifo_rtlsim_cpp", "characterize"] ) -def test_fifosizing_linear(method): +@pytest.mark.parametrize( + "topology", + [ + "cnv", + # "tfc" + ], +) +def test_fifosizing_linear(method, topology): force_python_rtlsim = "python" in method method_key = "largefifo_rtlsim" if "largefifo_rtlsim" in method else "characterize" tmp_output_dir = fetch_test_model("tfc") @@ -83,4 +92,32 @@ def test_fifosizing_linear(method): / float(est_data["estimated_throughput_fps"]) > 0.9 ) + # now run the same build using the generated folding and FIFO config + tmp_output_dir_cmp = fetch_test_model("tfc") + cfg_cmp = cfg + cfg_cmp.output_dir = tmp_output_dir_cmp + cfg_cmp.auto_fifo_depths = False + cfg_cmp.target_fps = None + cfg_cmp.generate_outputs = [build_cfg.DataflowOutputType.STITCHED_IP] + cfg_cmp.folding_config_file = tmp_output_dir + "/final_hw_config.json" + build.build_dataflow_cfg(tmp_output_dir_cmp + "/model.onnx", cfg_cmp) + + model0 = ModelWrapper( + tmp_output_dir + "/intermediate_models/step_create_stitched_ip.onnx" + ) + model1 = ModelWrapper( + tmp_output_dir_cmp + "/intermediate_models/step_create_stitched_ip.onnx" + ) + + assert len(model0.graph.node) == len(model1.graph.node) + for i in range(len(model0.graph.node)): + node0 = model0.graph.node[i] + node1 = model1.graph.node[i] + assert node0.op_type == node1.op_type + if node0.op_type == "StreamingFIFO": + node0_inst = getCustomOp(node0) + node1_inst = getCustomOp(node1) + assert node0_inst.get_nodeattr("depth") == node1_inst.get_nodeattr("depth") + shutil.rmtree(tmp_output_dir) + shutil.rmtree(tmp_output_dir_cmp) -- GitLab