<jupyter_start><jupyter_text>Load input<jupyter_code>ibuf_normal = np.load(f"{verification_dir}/input.npy").astype(np.float32)
input_dict = {"global_in": ibuf_normal}<jupyter_output><empty_output><jupyter_text>Golden model<jupyter_code>model = ModelWrapper(f"{onnx_dir}/dance-dance_tidy.onnx")

output_dict_golden = oxe.execute_onnx(model, input_dict)
output_golden = output_dict_golden['global_out']<jupyter_output><empty_output><jupyter_text>Python simulation<jupyter_code>model = ModelWrapper(f"{onnx_dir}/dance-dance_streamlined.onnx")
                     
output_dict_python = oxe.execute_onnx(model, input_dict)
output_python = output_dict_python['global_out']
compare(output_python, output_golden)<jupyter_output>Results are the same.<jupyter_text>C++ simulation<jupyter_code>from finn.transformation.general import GiveUniqueNodeNames
from finn.transformation.fpgadataflow.prepare_cppsim import PrepareCppSim
from finn.transformation.fpgadataflow.compile_cppsim import CompileCppSim
from finn.transformation.fpgadataflow.set_exec_mode import SetExecMode

model = ModelWrapper(f"{onnx_dir}/dance-dance_fold.onnx")

model = model.transform(GiveUniqueNodeNames())
model = model.transform(PrepareCppSim())
model = model.transform(CompileCppSim())
model = model.transform(SetExecMode("cppsim"))

model.save(f"{onnx_dir}/dance-dance_cppsim.onnx")
from finn.custom_op.registry import getCustomOp

parent_model = ModelWrapper(f"{onnx_dir}/dance-dance_dataflow_parent.onnx")
sdp_node = parent_model.get_nodes_by_op_type("StreamingDataflowPartition")[0]
child_model_filename = f"{onnx_dir}/dance-dance_cppsim.onnx"
getCustomOp(sdp_node).set_nodeattr("model", child_model_filename)

output_dict_cppsim = oxe.execute_onnx(parent_model, input_dict)
output_cppsim = output_dict_cppsim['global_out']
compare(output_cppsim, output_golden)<jupyter_output>Results are the same.<jupyter_text>PyVerilator simulation<jupyter_code>from finn.util.basic import pynq_part_map
from finn.transformation.general import GiveUniqueNodeNames
from finn.transformation.fpgadataflow.prepare_ip import PrepareIP
from finn.transformation.fpgadataflow.hlssynth_ip import HLSSynthIP
from finn.transformation.fpgadataflow.set_exec_mode import SetExecMode
from finn.transformation.fpgadataflow.prepare_rtlsim import PrepareRTLSim

pynq_board = "Ultra96"
fpga_part = pynq_part_map[pynq_board]
target_clk_ns = 10

child_model = ModelWrapper(f"{onnx_dir}/dance-dance_fold.onnx")

child_model = child_model.transform(GiveUniqueNodeNames())
child_model = child_model.transform(PrepareIP(fpga_part, target_clk_ns))
child_model = child_model.transform(HLSSynthIP())
child_model = child_model.transform(SetExecMode("rtlsim"))
child_model = child_model.transform(PrepareRTLSim())

child_model.save(f"{onnx_dir}/dance-dance_dataflow_child.onnx")
from finn.custom_op.registry import getCustomOp
from finn.transformation.fpgadataflow.set_exec_mode import SetExecMode

parent_model = ModelWrapper(f"{onnx_dir}/dance-dance_dataflow_parent.onnx")
sdp_node = parent_model.get_nodes_by_op_type("StreamingDataflowPartition")[0]
sdp_node = getCustomOp(sdp_node)
sdp_node.set_nodeattr("model", f"{onnx_dir}/dance-dance_dataflow_child.onnx")
parent_model = parent_model.transform(SetExecMode("rtlsim"))

output_dict_verilator = oxe.execute_onnx(parent_model, input_dict)
output_verilator = output_dict_verilator['global_out']
compare(output_verilator, output_golden)<jupyter_output>Results are the same.
{'fraction_non_alphanumeric': 0.10026079397276152, 'fraction_numerical': 0.0023181686467690526, 'mean_word_length': 10.318032786885245, 'pattern_counts': {'":': 1, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '87805', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1242, 'n_words': 146, 'path': 'notebooks/dance-dance/verification.ipynb', 'repo_name': 'gowgos5/finn', 'size': '3451'}