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

[FIFO] also do accumulation as part of DeriveCharacteristic

parent d5292fcb
No related branches found
No related tags found
No related merge requests found
...@@ -111,7 +111,7 @@ class HLSCustomOp(CustomOp): ...@@ -111,7 +111,7 @@ class HLSCustomOp(CustomOp):
"inFIFODepth": ("i", False, 2), "inFIFODepth": ("i", False, 2),
"outFIFODepth": ("i", False, 2), "outFIFODepth": ("i", False, 2),
"output_hook": ("s", False, ""), "output_hook": ("s", False, ""),
# characterization of stream input-output behavior per cycle # accumulated characteristic function over two periods
"io_characteristic": ("ints", False, []), "io_characteristic": ("ints", False, []),
# the period for which the characterization was run # the period for which the characterization was run
"io_characteristic_period": ("i", False, 0), "io_characteristic_period": ("i", False, 0),
......
...@@ -140,6 +140,19 @@ class DeriveCharacteristic(NodeLocalTransformation): ...@@ -140,6 +140,19 @@ class DeriveCharacteristic(NodeLocalTransformation):
txns_in += [0 for x in range(self.period - len(txns_in))] txns_in += [0 for x in range(self.period - len(txns_in))]
if len(txns_out) < self.period: if len(txns_out) < self.period:
txns_out += [0 for x in range(self.period - len(txns_out))] 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 io_characteristic = txns_in + txns_out
inst.set_nodeattr("io_characteristic", io_characteristic) inst.set_nodeattr("io_characteristic", io_characteristic)
inst.set_nodeattr("io_characteristic_period", self.period) inst.set_nodeattr("io_characteristic_period", self.period)
......
...@@ -475,9 +475,9 @@ def test_fclayer_fifocharacterize(mem_mode, idt, wdt, act, nf, sf, mw, mh): ...@@ -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") period_attr = node_inst.get_nodeattr("io_characteristic_period")
assert period_attr == exp_total_cycles assert period_attr == exp_total_cycles
chrc = node_inst.get_nodeattr("io_characteristic") 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) chrc = np.asarray(chrc, dtype=np.uint8).reshape(2, -1)
# first sf cycles should read input continuously # 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 # all outputs should be produced within the exp n of cycles
assert sum(chrc[1]) == nf assert chrc[1, exp_total_cycles] == nf
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