Skip to content

Commit 9a78c67

Browse files
committed
Fixing bug in downsampling
1 parent c6c133d commit 9a78c67

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

tools/bvdd.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,15 @@ def projection_proto(index):
174174
# use offset 1 for CFLOBVDDs
175175
return BVDD.projection(index, 1)
176176

177-
def apply(self, return_tuple, index = 0):
177+
def apply(self, return_tuple, index = 0, level = 0):
178178
new_bvdd = type(self)({})
179179
s2o = self.get_s2o()
180180
for inputs in s2o:
181181
output = s2o[inputs]
182182
if isinstance(output, BVDD):
183-
new_bvdd.set(inputs, output.apply(return_tuple, index + 1))
183+
new_bvdd.set(inputs, output.apply(return_tuple, index + 1, level))
184+
elif index < 2**level - 1:
185+
new_bvdd.set(inputs, BVDD.constant(output).apply(return_tuple, index + 1, level))
184186
else:
185187
new_bvdd.set(inputs, return_tuple[output])
186188
return new_bvdd.reduce_SBDD().reduce_BVDD(index)
@@ -270,10 +272,11 @@ def upsample(self, level, a_rt_inv = None, b_rt_inv = None, b_cs = None, b_rts =
270272
a_c.set(inputs, a_rt_inv[output])
271273
return a_c.reduce_SBDD().reduce_BVDD(index), a_rt_inv, b_rt_inv, b_cs, b_rts
272274

273-
def downsample(self, bvdds, return_tuples):
275+
def downsample(self, level, bvdds, return_tuples):
276+
assert level > 0
274277
# apply to bvdds may reduce to constants
275278
return self.apply(dict([(exit_i, bvdds[exit_i].apply(return_tuples[exit_i], 1))
276-
for exit_i in bvdds]))
279+
for exit_i in bvdds]), 0, level - 1)
277280

278281
def tuple2exit(tuple_inv, tuple_ins):
279282
if tuple_ins not in tuple_inv:

tools/cflobvdd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ def downsample(self):
803803
g_b = g.b_connections[g_b_i]
804804
g_b_bvdds[g_b_i] = g_b.downsample().bvdd
805805

806-
bvdd = g_a_bvdd.downsample(g_b_bvdds, g.b_return_tuples)
806+
bvdd = g_a_bvdd.downsample(g.level, g_b_bvdds, g.b_return_tuples)
807807

808808
assert bvdd.number_of_exits() == g.number_of_exits
809809

0 commit comments

Comments
 (0)