diff --git a/src/finn/custom_op/fpgadataflow/hlscustomop.py b/src/finn/custom_op/fpgadataflow/hlscustomop.py index 85f5bfd3f119b35123724f00657e2036be9c5715..bb359ef0b5ccd14555b0001f5722eb48d2e71173 100644 --- a/src/finn/custom_op/fpgadataflow/hlscustomop.py +++ b/src/finn/custom_op/fpgadataflow/hlscustomop.py @@ -111,7 +111,7 @@ class HLSCustomOp(CustomOp): "inFIFODepth": ("i", False, 2), "outFIFODepth": ("i", False, 2), "output_hook": ("s", False, ""), - # characterization of stream input-output behavior per cycle + # accumulated characteristic function over two periods "io_characteristic": ("ints", False, []), # the period for which the characterization was run "io_characteristic_period": ("i", False, 0), diff --git a/src/finn/transformation/fpgadataflow/derive_characteristic.py b/src/finn/transformation/fpgadataflow/derive_characteristic.py index 0a32ba7e73d81c794dd39be382f5dcdec5fe71a9..72573f250bd6a6ad6a869139c4423620a46e6938 100644 --- a/src/finn/transformation/fpgadataflow/derive_characteristic.py +++ b/src/finn/transformation/fpgadataflow/derive_characteristic.py @@ -140,6 +140,19 @@ class DeriveCharacteristic(NodeLocalTransformation): txns_in += [0 for x in range(self.period - len(txns_in))] if len(txns_out) < self.period: txns_out += [0 for x in range(self.period - len(txns_out))] + + def accumulate_char_fxn(chrc): + p = len(chrc) + ret = [] + for t in range(2 * p): + if t == 0: + ret.append(chrc[0]) + else: + ret.append(ret[-1] + chrc[t % p]) + return ret + + txns_in = accumulate_char_fxn(txns_in) + txns_out = accumulate_char_fxn(txns_out) io_characteristic = txns_in + txns_out inst.set_nodeattr("io_characteristic", io_characteristic) inst.set_nodeattr("io_characteristic_period", self.period) diff --git a/tests/fpgadataflow/test_fpgadataflow_mvau.py b/tests/fpgadataflow/test_fpgadataflow_mvau.py index 87c30a00bf922e6eaa7911e6cdee29361fbedad5..22ff36f5371feeadf5720bb2838a614442f87dce 100644 --- a/tests/fpgadataflow/test_fpgadataflow_mvau.py +++ b/tests/fpgadataflow/test_fpgadataflow_mvau.py @@ -475,9 +475,9 @@ def test_fclayer_fifocharacterize(mem_mode, idt, wdt, act, nf, sf, mw, mh): period_attr = node_inst.get_nodeattr("io_characteristic_period") assert period_attr == exp_total_cycles chrc = node_inst.get_nodeattr("io_characteristic") - assert len(chrc) == 2 * exp_total_cycles + assert len(chrc) == 4 * exp_total_cycles chrc = np.asarray(chrc, dtype=np.uint8).reshape(2, -1) # first sf cycles should read input continuously - assert (chrc[0, :sf] == 1).all() + assert (chrc[0, :sf] == range(1, sf + 1)).all() # all outputs should be produced within the exp n of cycles - assert sum(chrc[1]) == nf + assert chrc[1, exp_total_cycles] == nf