Skip to content

Commit

Permalink
[execute node] switch to rtlsim multi io for all custom ops
Browse files Browse the repository at this point in the history
  • Loading branch information
auphelia committed Oct 22, 2024
1 parent 25443da commit afbf1fe
Show file tree
Hide file tree
Showing 23 changed files with 133 additions and 34 deletions.
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/hls/channelwise_op_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,12 @@ def execute_node(self, context, graph):
inp = npy_to_rtlsim_input("{}/input_0.npy".format(code_gen_dir), export_idt, nbits)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
output = self.rtlsim(sim, inp)
io_dict = {
"inputs": {"in0": inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
output = io_dict["outputs"]["out"]
odt = self.get_output_datatype()
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = export_idt
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/hls/downsampler_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = export_idt
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/hls/fmpadding_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = export_idt
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/hls/fmpadding_pixel_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = export_idt
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/hls/globalaccpool_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = self.get_output_datatype()
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/hls/labelselect_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = self.get_output_datatype()
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/hls/lookup_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
out_npy_path = "{}/output.npy".format(code_gen_dir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,13 @@ def execute_node(self, context, graph):
"inputs": {"in0": inp, "weights": wei * num_w_reps},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
output = io_dict["outputs"]["out"]
else:
output = self.rtlsim(sim, inp)
io_dict = {
"inputs": {"in0": inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
output = io_dict["outputs"]["out"]
odt = self.get_output_datatype()
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/hls/pool_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = self.get_output_datatype()
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = export_idt
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/hls/streamingeltwise_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp0, rtlsim_inp1)
io_dict = {
"inputs": {"in0": rtlsim_inp0, "in1": rtlsim_inp1},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = self.get_output_datatype()
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/hls/streamingmaxpool_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = export_idt
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
9 changes: 6 additions & 3 deletions src/finn/custom_op/fpgadataflow/hls/thresholding_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,15 @@ def execute_node(self, context, graph):
"inputs": {"in0": inp, "weights": wei * num_w_reps},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
output = io_dict["outputs"]["out"]
elif self.get_nodeattr("mem_mode") == "internal_embedded":
output = self.rtlsim(sim, inp)
io_dict = {
"inputs": {"in0": inp},
"outputs": {"out": []},
}
else:
raise Exception("Unrecognized mem_mode")
self.rtlsim_multi_io(sim, io_dict)
output = io_dict["outputs"]["out"]
odt = self.get_output_datatype()
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/hls/upsampler_hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = export_idt
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,13 @@ def execute_node(self, context, graph):
"inputs": {"in0": inp, "weights": wei * num_w_reps},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
output = io_dict["outputs"]["out"]
else:
output = self.rtlsim(sim, inp)
io_dict = {
"inputs": {"in0": inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
output = io_dict["outputs"]["out"]
odt = self.get_output_datatype()
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
3 changes: 1 addition & 2 deletions src/finn/custom_op/fpgadataflow/hwcustomop.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def get_nodeattr_types(self):
"res_estimate": ("s", False, ""),
"res_synth": ("s", False, ""),
"rtlsim_so": ("s", False, ""),
"rtlsim_backend": ("s", False, "pyverilator", {"pyverilator", "pyxsi"}),
# partitioning info
# ID of SLR to which the Op is attached in Vitis builds
# Set to -1 as 'don't care'
Expand Down Expand Up @@ -98,8 +99,6 @@ def get_nodeattr_types(self):
# amount of zero padding inserted during chrc.
"io_chrc_pads_in": ("ints", False, []),
"io_chrc_pads_out": ("ints", False, []),
# experimental: rtlsim backend
"rtlsim_backend": ("s", False, "pyverilator", {"pyverilator", "pyxsi"}),
}

def get_verilog_top_module_name(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = export_idt
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/rtl/fmpadding_rtl.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = export_idt
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,13 @@ def execute_node(self, context, graph):
"inputs": {"in0": inp, "weights": wei * num_w_reps},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
output = io_dict["outputs"]["out"]
else:
output = self.rtlsim(sim, inp)
io_dict = {
"inputs": {"in0": inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
output = io_dict["outputs"]["out"]
odt = self.get_output_datatype()
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ def execute_node(self, context, graph):
)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
rtlsim_output = self.rtlsim(sim, rtlsim_inp)
io_dict = {
"inputs": {"in0": rtlsim_inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
rtlsim_output = io_dict["outputs"]["out"]
odt = export_idt
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
7 changes: 6 additions & 1 deletion src/finn/custom_op/fpgadataflow/rtl/streamingfifo_rtl.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ def execute_node(self, context, graph):
inp = npy_to_rtlsim_input("{}/input_0.npy".format(code_gen_dir), export_idt, nbits)
super().reset_rtlsim(sim)
super().toggle_clk(sim)
output = self.rtlsim(sim, inp)
io_dict = {
"inputs": {"in0": inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
output = io_dict["outputs"]["out"]
odt = DataType[self.get_nodeattr("dataType")]
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,13 @@ def execute_node(self, context, graph):
"inputs": {"in0": inp, "weights": wei * num_w_reps},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
output = io_dict["outputs"]["out"]
else:
output = self.rtlsim(sim, inp)
io_dict = {
"inputs": {"in0": inp},
"outputs": {"out": []},
}
self.rtlsim_multi_io(sim, io_dict)
output = io_dict["outputs"]["out"]
odt = self.get_output_datatype()
target_bits = odt.bitwidth()
packed_bits = self.get_outstream_width()
Expand Down

0 comments on commit afbf1fe

Please sign in to comment.