From f9314ed3b687ad9f360138edb2ca23d33507bf29 Mon Sep 17 00:00:00 2001 From: hannahxy13 <128490865+hannahxy13@users.noreply.github.com> Date: Thu, 23 May 2024 16:40:20 +0100 Subject: [PATCH 1/4] Changed QONNX_TO_FINN_PYTHON verification step name to match build config name QONNX_TO_FINN_PYTHON verification step is named "finn_onnx_python" in build_dataflow_config.py, but in build_data_steps.py it is named "qonnx_to_finn_python". Changed to "finn_onnx_python" to match the build config, so the verification file is created with the expected name --- src/finn/builder/build_dataflow_steps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/finn/builder/build_dataflow_steps.py b/src/finn/builder/build_dataflow_steps.py index 443d2df54c..ecf6f2d107 100644 --- a/src/finn/builder/build_dataflow_steps.py +++ b/src/finn/builder/build_dataflow_steps.py @@ -277,7 +277,7 @@ def step_qonnx_to_finn(model: ModelWrapper, cfg: DataflowBuildConfig): ) if VerificationStepType.QONNX_TO_FINN_PYTHON in cfg._resolve_verification_steps(): - verify_step(model, cfg, "qonnx_to_finn_python", need_parent=False) + verify_step(model, cfg, "finn_onnx_python", need_parent=False) return model From 0db17912d82cdac5eb356023c0f8ef8b4bad4a47 Mon Sep 17 00:00:00 2001 From: Hannah Yan Date: Tue, 25 Jun 2024 16:22:07 +0100 Subject: [PATCH 2/4] Updated run-docker.sh and added verification step NODE_BY_NODE_RTLSIM --- run-docker.sh | 2 ++ src/finn/builder/build_dataflow_config.py | 2 ++ src/finn/builder/build_dataflow_steps.py | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/run-docker.sh b/run-docker.sh index 88fabff2fa..d7785fe9a7 100755 --- a/run-docker.sh +++ b/run-docker.sh @@ -139,6 +139,7 @@ elif [ "$1" = "build_custom" ]; then BUILD_CUSTOM_DIR=$(readlink -f "$2") FLOW_NAME=${3:-build} FINN_DOCKER_EXTRA+="-v $BUILD_CUSTOM_DIR:$BUILD_CUSTOM_DIR -w $BUILD_CUSTOM_DIR " + FINN_DOCKER_EXTRA+="-v $BUILD_CUSTOM_DIR/../../ci:$BUILD_CUSTOM_DIR/../../ci " DOCKER_INTERACTIVE="-it" #FINN_HOST_BUILD_DIR=$BUILD_DATAFLOW_DIR/build gecho "Running build_custom: $BUILD_CUSTOM_DIR/$FLOW_NAME.py" @@ -214,6 +215,7 @@ DOCKER_EXEC+="-v $SCRIPTPATH:$SCRIPTPATH " DOCKER_EXEC+="-v $FINN_HOST_BUILD_DIR:$FINN_HOST_BUILD_DIR " DOCKER_EXEC+="-e FINN_BUILD_DIR=$FINN_HOST_BUILD_DIR " DOCKER_EXEC+="-e FINN_ROOT="$SCRIPTPATH" " +DOCKER_EXEC+="-e VERIFICATION_EN=$VERIFICATION_EN " DOCKER_EXEC+="-e LOCALHOST_URL=$LOCALHOST_URL " DOCKER_EXEC+="-e VIVADO_IP_CACHE=$VIVADO_IP_CACHE " DOCKER_EXEC+="-e PYNQ_BOARD=$PYNQ_BOARD " diff --git a/src/finn/builder/build_dataflow_config.py b/src/finn/builder/build_dataflow_config.py index e35c1cd346..5d69802337 100644 --- a/src/finn/builder/build_dataflow_config.py +++ b/src/finn/builder/build_dataflow_config.py @@ -96,6 +96,8 @@ class VerificationStepType(str, Enum): STREAMLINED_PYTHON = "streamlined_python" #: verify after step_apply_folding_config, using C++ for each HLS node FOLDED_HLS_CPPSIM = "folded_hls_cppsim" + #: verify after step_hw_ipgen + NODE_BY_NODE_RTLSIM = "node_by_node_rtlsim" #: verify after step_create_stitched_ip, using stitched-ip Verilog STITCHED_IP_RTLSIM = "stitched_ip_rtlsim" diff --git a/src/finn/builder/build_dataflow_steps.py b/src/finn/builder/build_dataflow_steps.py index e202a74956..b8ed8daec7 100644 --- a/src/finn/builder/build_dataflow_steps.py +++ b/src/finn/builder/build_dataflow_steps.py @@ -527,6 +527,11 @@ def step_hw_ipgen(model: ModelWrapper, cfg: DataflowBuildConfig): estimate_layer_resources_hls = model.analysis(hls_synth_res_estimation) with open(report_dir + "/estimate_layer_resources_hls.json", "w") as f: json.dump(estimate_layer_resources_hls, f, indent=2) + + if VerificationStepType.NODE_BY_NODE_RTLSIM in cfg._resolve_verification_steps(): + model = model.transform(PrepareRTLSim()) + model = model.transform(SetExecMode("rtlsim")) + verify_step(model, cfg, "node_by_node_rtlsim", need_parent=True) return model From be2823b1318ae99fb1ca6de316d4bfcda00f0c13 Mon Sep 17 00:00:00 2001 From: hannahxy13 <128490865+hannahxy13@users.noreply.github.com> Date: Mon, 15 Jul 2024 09:05:12 +0100 Subject: [PATCH 3/4] Update run-docker.sh to remove unneeded verification env vars --- run-docker.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/run-docker.sh b/run-docker.sh index d7785fe9a7..88fabff2fa 100755 --- a/run-docker.sh +++ b/run-docker.sh @@ -139,7 +139,6 @@ elif [ "$1" = "build_custom" ]; then BUILD_CUSTOM_DIR=$(readlink -f "$2") FLOW_NAME=${3:-build} FINN_DOCKER_EXTRA+="-v $BUILD_CUSTOM_DIR:$BUILD_CUSTOM_DIR -w $BUILD_CUSTOM_DIR " - FINN_DOCKER_EXTRA+="-v $BUILD_CUSTOM_DIR/../../ci:$BUILD_CUSTOM_DIR/../../ci " DOCKER_INTERACTIVE="-it" #FINN_HOST_BUILD_DIR=$BUILD_DATAFLOW_DIR/build gecho "Running build_custom: $BUILD_CUSTOM_DIR/$FLOW_NAME.py" @@ -215,7 +214,6 @@ DOCKER_EXEC+="-v $SCRIPTPATH:$SCRIPTPATH " DOCKER_EXEC+="-v $FINN_HOST_BUILD_DIR:$FINN_HOST_BUILD_DIR " DOCKER_EXEC+="-e FINN_BUILD_DIR=$FINN_HOST_BUILD_DIR " DOCKER_EXEC+="-e FINN_ROOT="$SCRIPTPATH" " -DOCKER_EXEC+="-e VERIFICATION_EN=$VERIFICATION_EN " DOCKER_EXEC+="-e LOCALHOST_URL=$LOCALHOST_URL " DOCKER_EXEC+="-e VIVADO_IP_CACHE=$VIVADO_IP_CACHE " DOCKER_EXEC+="-e PYNQ_BOARD=$PYNQ_BOARD " From 0133f2358174495bd85383779528fccb5fe1065d Mon Sep 17 00:00:00 2001 From: auphelia Date: Mon, 15 Jul 2024 11:07:48 +0100 Subject: [PATCH 4/4] [Tests] Add node by node rtlsim to build dataflow test case --- src/finn/qnn-data/build_dataflow/build.py | 1 + src/finn/qnn-data/build_dataflow/dataflow_build_config.json | 1 + tests/util/test_build_dataflow.py | 1 + 3 files changed, 3 insertions(+) diff --git a/src/finn/qnn-data/build_dataflow/build.py b/src/finn/qnn-data/build_dataflow/build.py index 58d566a6e6..6cc7ff2419 100644 --- a/src/finn/qnn-data/build_dataflow/build.py +++ b/src/finn/qnn-data/build_dataflow/build.py @@ -61,6 +61,7 @@ build_cfg.VerificationStepType.TIDY_UP_PYTHON, build_cfg.VerificationStepType.STREAMLINED_PYTHON, build_cfg.VerificationStepType.FOLDED_HLS_CPPSIM, + build_cfg.VerificationStepType.NODE_BY_NODE_RTLSIM, build_cfg.VerificationStepType.STITCHED_IP_RTLSIM, ], save_intermediate_models=True, diff --git a/src/finn/qnn-data/build_dataflow/dataflow_build_config.json b/src/finn/qnn-data/build_dataflow/dataflow_build_config.json index 8165055fd5..2c1db458dd 100644 --- a/src/finn/qnn-data/build_dataflow/dataflow_build_config.json +++ b/src/finn/qnn-data/build_dataflow/dataflow_build_config.json @@ -13,6 +13,7 @@ "initial_python", "streamlined_python", "folded_hls_cppsim", + "node_by_node_rtlsim", "stitched_ip_rtlsim" ], "generate_outputs": [ diff --git a/tests/util/test_build_dataflow.py b/tests/util/test_build_dataflow.py index 75ed8335c0..c8787b4098 100644 --- a/tests/util/test_build_dataflow.py +++ b/tests/util/test_build_dataflow.py @@ -72,5 +72,6 @@ def test_end2end_build_dataflow_directory(): assert os.path.isfile(verify_out_dir + f"/verify_initial_python_{i}_SUCCESS.npy") assert os.path.isfile(verify_out_dir + f"/verify_streamlined_python_{i}_SUCCESS.npy") assert os.path.isfile(verify_out_dir + f"/verify_folded_hls_cppsim_{i}_SUCCESS.npy") + assert os.path.isfile(verify_out_dir + f"/verify_node_by_node_rtlsim_{i}_SUCCESS.npy") assert os.path.isfile(verify_out_dir + f"/verify_stitched_ip_rtlsim_{i}_SUCCESS.npy") assert os.path.isfile(output_dir + f"/report/verify_rtlsim_{i}.vcd")