Skip to content
Snippets Groups Projects
Commit 4e0d1ec7 authored by Yaman Umuroglu's avatar Yaman Umuroglu
Browse files

[Test] flesh out DWC testcases as separate configs with impl_style

parent 7faf316b
No related branches found
No related tags found
No related merge requests found
...@@ -41,14 +41,10 @@ from finn.transformation.fpgadataflow.insert_fifo import InsertFIFO ...@@ -41,14 +41,10 @@ from finn.transformation.fpgadataflow.insert_fifo import InsertFIFO
from finn.transformation.fpgadataflow.prepare_ip import PrepareIP from finn.transformation.fpgadataflow.prepare_ip import PrepareIP
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) inp = helper.make_tensor_value_info("inp", TensorProto.FLOAT, shape)
outp = helper.make_tensor_value_info("outp", TensorProto.FLOAT, Shape) outp = helper.make_tensor_value_info("outp", TensorProto.FLOAT, shape)
max_w = max(OUTWidth, INWidth)
min_w = min(OUTWidth, INWidth)
impl_style = "hls" if max_w % min_w == 0 else "vivado"
DWC_node = helper.make_node( DWC_node = helper.make_node(
"StreamingDataWidthConverter_Batch", "StreamingDataWidthConverter_Batch",
...@@ -56,9 +52,9 @@ def make_single_dwc_modelwrapper(Shape, INWidth, OUTWidth, finn_dtype): ...@@ -56,9 +52,9 @@ def make_single_dwc_modelwrapper(Shape, INWidth, OUTWidth, finn_dtype):
["outp"], ["outp"],
domain="finn.custom_op.fpgadataflow", domain="finn.custom_op.fpgadataflow",
backend="fpgadataflow", backend="fpgadataflow",
shape=Shape, shape=shape,
inWidth=INWidth, inWidth=inWidth,
outWidth=OUTWidth, outWidth=outWidth,
dataType=str(finn_dtype.name), dataType=str(finn_dtype.name),
impl_style=impl_style, impl_style=impl_style,
) )
...@@ -80,41 +76,42 @@ def prepare_inputs(input_tensor, dt): ...@@ -80,41 +76,42 @@ def prepare_inputs(input_tensor, dt):
return {"inp": input_tensor} return {"inp": input_tensor}
# shape @pytest.mark.parametrize(
# @pytest.mark.parametrize("Shape", [[1, 4], [1, 2, 8]]) "config",
@pytest.mark.parametrize("Shape", [[1, 24]]) [
# inWidth ([1, 24], 6, 4, DataType["INT2"], "hls"),
# @pytest.mark.parametrize("INWidth", [2, 4]) ([1, 24], 4, 6, DataType["INT2"], "hls"),
@pytest.mark.parametrize("INWidth", [6]) ([1, 4], 2, 4, DataType["BIPOLAR"], "hls"),
# outWidth ([1, 2, 8], 2, 4, DataType["BIPOLAR"], "hls"),
# @pytest.mark.parametrize("OUTWidth", [2, 4]) ([1, 4], 4, 2, DataType["INT2"], "hls"),
@pytest.mark.parametrize("OUTWidth", [4]) ([1, 2, 8], 4, 4, DataType["INT2"], "hls"),
# finn_dtype ([1, 2, 8], 8, 16, DataType["INT2"], "vivado"),
# @pytest.mark.parametrize("finn_dtype", [DataType["BIPOLAR"], DataType["INT2"]]) ],
@pytest.mark.parametrize("finn_dtype", [DataType["INT2"]]) )
@pytest.mark.fpgadataflow @pytest.mark.fpgadataflow
@pytest.mark.slow @pytest.mark.slow
@pytest.mark.vivado @pytest.mark.vivado
def test_fpgadataflow_dwc_rtlsim(Shape, INWidth, OUTWidth, finn_dtype): def test_fpgadataflow_dwc_rtlsim(config):
shape, inWidth, outWidth, finn_dtype, impl_style = config
test_fpga_part = "xc7z020clg400-1" test_fpga_part = "xc7z020clg400-1"
target_clk_ns = 10.0 target_clk_ns = 10.0
# generate input data # generate input data
x = gen_finn_dt_tensor(finn_dtype, Shape) x = gen_finn_dt_tensor(finn_dtype, shape)
input_dict = prepare_inputs(x, finn_dtype) 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(InsertFIFO(create_shallow_fifos=True)) model = model.transform(InsertFIFO(create_shallow_fifos=True))
model = model.transform(GiveUniqueNodeNames()) model = model.transform(GiveUniqueNodeNames())
model = model.transform(PrepareIP(test_fpga_part, 5)) model = model.transform(PrepareIP(test_fpga_part, 5))
model = model.transform(HLSSynthIP()) model = model.transform(HLSSynthIP())
model = model.transform(CreateStitchedIP(test_fpga_part, target_clk_ns)) model = model.transform(CreateStitchedIP(test_fpga_part, target_clk_ns))
model.set_metadata_prop("exec_mode", "rtlsim") model.set_metadata_prop("exec_mode", "rtlsim")
model.set_metadata_prop("rtlsim_trace", "dwc.vcd")
y = oxe.execute_onnx(model, input_dict)["outp"] y = oxe.execute_onnx(model, input_dict)["outp"]
assert ( assert (
y == x y == x
).all(), """The output values are not the same as the ).all(), """The output values are not the same as the
input values anymore.""" input values anymore."""
assert y.shape == tuple(Shape), """The output shape is incorrect.""" assert y.shape == tuple(shape), """The output shape is incorrect."""
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment