Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix redeclaration of streams in StreamingDataWidthConverter_hls #1107

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ def strm_decl(self):
self.get_instream_width(), self.hls_sname(), self.hls_sname()
)
)
if self.needs_lcm():
self.code_gen_dict["$STREAMDECLARATIONS$"].append(
'hls::stream<ap_uint<{}>> intermediate ("intermediate");'.format(
self.get_iowidth_lcm()
)
)
self.code_gen_dict["$STREAMDECLARATIONS$"].append(
'hls::stream<ap_uint<{}>> out_{} ("out_{}");'.format(
self.get_outstream_width(), self.hls_sname(), self.hls_sname()
Expand Down
17 changes: 8 additions & 9 deletions tests/fpgadataflow/test_fpgadataflow_dwc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from finn.transformation.fpgadataflow.specialize_layers import SpecializeLayers


def make_single_dwc_modelwrapper(shape, inWidth, outWidth, finn_dtype):
def make_single_dwc_modelwrapper(shape, inWidth, outWidth, finn_dtype, impl_style):
inp = helper.make_tensor_value_info("inp", TensorProto.FLOAT, shape)
outp = helper.make_tensor_value_info("outp", TensorProto.FLOAT, shape)

Expand All @@ -63,6 +63,7 @@ def make_single_dwc_modelwrapper(shape, inWidth, outWidth, finn_dtype):
inWidth=inWidth,
outWidth=outWidth,
dataType=str(finn_dtype.name),
preferred_impl_style=impl_style,
)

graph = helper.make_graph(nodes=[DWC_node], name="dwc_graph", inputs=[inp], outputs=[outp])
Expand All @@ -86,25 +87,25 @@ def prepare_inputs(input_tensor, dt):
([1, 24], 6, 4, DataType["INT2"]),
([1, 24], 4, 6, DataType["INT2"]),
([1, 4], 2, 4, DataType["BIPOLAR"]),
([1, 2, 8], 2, 4, DataType["BIPOLAR"]),
([1, 4], 4, 2, DataType["INT2"]),
([1, 2, 8], 4, 4, DataType["INT2"]),
([1, 2, 8], 8, 16, DataType["INT2"]),
],
)
@pytest.mark.parametrize("exec_mode", ["cppsim", "rtlsim"])
@pytest.mark.parametrize("impl_style", ["hls", "rtl"])
@pytest.mark.fpgadataflow
@pytest.mark.slow
@pytest.mark.vivado
def test_fpgadataflow_dwc(config, exec_mode):
def test_fpgadataflow_dwc(config, exec_mode, impl_style):
shape, inWidth, outWidth, finn_dtype = config

test_fpga_part = "xc7z020clg400-1"
# generate input data
x = gen_finn_dt_tensor(finn_dtype, shape)
input_dict = prepare_inputs(x, finn_dtype)

model = make_single_dwc_modelwrapper(shape, inWidth, outWidth, finn_dtype)
model = make_single_dwc_modelwrapper(shape, inWidth, outWidth, finn_dtype, impl_style)
# verify abstraction level execution
y = oxe.execute_onnx(model, input_dict)["outp"]
assert (
Expand Down Expand Up @@ -136,19 +137,17 @@ def test_fpgadataflow_dwc(config, exec_mode):
@pytest.mark.parametrize(
"config",
[
([1, 24], 6, 4, DataType["INT2"]),
([1, 24], 4, 6, DataType["INT2"]),
([1, 4], 2, 4, DataType["BIPOLAR"]),
([1, 2, 8], 2, 4, DataType["BIPOLAR"]),
([1, 4], 4, 2, DataType["INT2"]),
([1, 2, 8], 4, 4, DataType["INT2"]),
([1, 2, 8], 8, 16, DataType["INT2"]),
],
)
@pytest.mark.parametrize("impl_style", ["hls", "rtl"])
@pytest.mark.fpgadataflow
@pytest.mark.slow
@pytest.mark.vivado
def test_fpgadataflow_dwc_stitched_rtlsim(config):
def test_fpgadataflow_dwc_stitched_rtlsim(config, impl_style):
shape, inWidth, outWidth, finn_dtype = config

test_fpga_part = "xc7z020clg400-1"
Expand All @@ -157,7 +156,7 @@ def test_fpgadataflow_dwc_stitched_rtlsim(config):
x = gen_finn_dt_tensor(finn_dtype, shape)
input_dict = prepare_inputs(x, finn_dtype)

model = make_single_dwc_modelwrapper(shape, inWidth, outWidth, finn_dtype)
model = make_single_dwc_modelwrapper(shape, inWidth, outWidth, finn_dtype, impl_style)
model = model.transform(SpecializeLayers(test_fpga_part))
model = model.transform(InsertFIFO(create_shallow_fifos=True))
model = model.transform(SpecializeLayers(test_fpga_part))
Expand Down
Loading