Skip to content

Commit 797d150

Browse files
committed
[Tests] Add node-by-node rtlsim check to decoupled mem mode elementwise test
1 parent 6047f1e commit 797d150

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

tests/fpgadataflow/test_fpgadataflow_elementwise_binary.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,27 @@ def test_elementwise_binary_operation_stitched_ip(
289289
model = model.transform(MinimizeWeightBitWidth())
290290
model = model.transform(MinimizeAccumulatorWidth())
291291

292+
model = model.transform(SetExecMode("rtlsim"))
292293
model = model.transform(GiveUniqueNodeNames())
293-
model = model.transform(InsertAndSetFIFODepths("xczu7ev-ffvc1156-2-e", 10))
294294
model = model.transform(PrepareIP("xczu7ev-ffvc1156-2-e", 10))
295295
model = model.transform(HLSSynthIP())
296296

297+
model = model.transform(PrepareRTLSim())
298+
299+
# Compute ground-truth output in software
300+
lhs = context["in_x"]
301+
rhs = context["in_y"]
302+
303+
o_expected = numpy_reference(lhs, rhs)
304+
305+
# node-by-node rtlsim
306+
o_produced = execute_onnx(model, context)[model.graph.output[0].name]
307+
assert np.all(o_produced == o_expected)
308+
309+
# prepare for stitched ip rtlsim
310+
model = model.transform(InsertAndSetFIFODepths("xczu7ev-ffvc1156-2-e", 10))
311+
model = model.transform(PrepareIP("xczu7ev-ffvc1156-2-e", 10))
312+
model = model.transform(HLSSynthIP())
297313
model = model.transform(
298314
CreateStitchedIP(
299315
"xczu7ev-ffvc1156-2-e",
@@ -302,12 +318,6 @@ def test_elementwise_binary_operation_stitched_ip(
302318
)
303319
)
304320

305-
# Compute ground-truth output in software
306-
lhs = context["in_x"]
307-
rhs = context["in_y"]
308-
309-
o_expected = numpy_reference(lhs, rhs)
310-
311321
# Tensor names might have changed during the test, so assembling an updated context dict
312322
io_dict = {}
313323
if not initializers:
@@ -318,7 +328,7 @@ def test_elementwise_binary_operation_stitched_ip(
318328
io_dict[model.graph.input[0].name] = rhs
319329
elif initializers[0] == "in_y":
320330
io_dict[model.graph.input[0].name] = lhs
321-
# Execute the onnx model to collect the result
331+
# stitched-ip rtlsim
322332
model.set_metadata_prop("exec_mode", "rtlsim")
323333
o_produced = execute_onnx(model, io_dict)[model.graph.output[0].name]
324334

0 commit comments

Comments
 (0)