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
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)
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"
inp = helper.make_tensor_value_info("inp", TensorProto.FLOAT, shape)
outp = helper.make_tensor_value_info("outp", TensorProto.FLOAT, shape)
DWC_node = helper.make_node(
"StreamingDataWidthConverter_Batch",
......@@ -56,9 +52,9 @@ def make_single_dwc_modelwrapper(Shape, INWidth, OUTWidth, finn_dtype):
["outp"],
domain="finn.custom_op.fpgadataflow",
backend="fpgadataflow",
shape=Shape,
inWidth=INWidth,
outWidth=OUTWidth,
shape=shape,
inWidth=inWidth,
outWidth=outWidth,
dataType=str(finn_dtype.name),
impl_style=impl_style,
)
......@@ -80,41 +76,42 @@ def prepare_inputs(input_tensor, dt):
return {"inp": input_tensor}
# shape
# @pytest.mark.parametrize("Shape", [[1, 4], [1, 2, 8]])
@pytest.mark.parametrize("Shape", [[1, 24]])
# inWidth
# @pytest.mark.parametrize("INWidth", [2, 4])
@pytest.mark.parametrize("INWidth", [6])
# outWidth
# @pytest.mark.parametrize("OUTWidth", [2, 4])
@pytest.mark.parametrize("OUTWidth", [4])
# finn_dtype
# @pytest.mark.parametrize("finn_dtype", [DataType["BIPOLAR"], DataType["INT2"]])
@pytest.mark.parametrize("finn_dtype", [DataType["INT2"]])
@pytest.mark.parametrize(
"config",
[
([1, 24], 6, 4, DataType["INT2"], "hls"),
([1, 24], 4, 6, DataType["INT2"], "hls"),
([1, 4], 2, 4, DataType["BIPOLAR"], "hls"),
([1, 2, 8], 2, 4, DataType["BIPOLAR"], "hls"),
([1, 4], 4, 2, DataType["INT2"], "hls"),
([1, 2, 8], 4, 4, DataType["INT2"], "hls"),
([1, 2, 8], 8, 16, DataType["INT2"], "vivado"),
],
)
@pytest.mark.fpgadataflow
@pytest.mark.slow
@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"
target_clk_ns = 10.0
# 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)
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(GiveUniqueNodeNames())
model = model.transform(PrepareIP(test_fpga_part, 5))
model = model.transform(HLSSynthIP())
model = model.transform(CreateStitchedIP(test_fpga_part, target_clk_ns))
model.set_metadata_prop("exec_mode", "rtlsim")
model.set_metadata_prop("rtlsim_trace", "dwc.vcd")
y = oxe.execute_onnx(model, input_dict)["outp"]
assert (
y == x
).all(), """The output values are not the same as the
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