Skip to content

Commit

Permalink
fix proxy conversionn when there are garbages connected
Browse files Browse the repository at this point in the history
  • Loading branch information
calad0i committed Nov 30, 2023
1 parent 8e95f8b commit 72d52fd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/HGQ/proxy/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def solve_dependencies(model: keras.Model):
if node.is_input:
continue
layer = node.layer
if layer not in model.layers:
continue
requires = list(node.parent_nodes)
provides = node
dependencies_list.append((layer, requires, provides))
Expand Down
8 changes: 7 additions & 1 deletion test/test_syn_hlayers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ def create_model(layer: str, rnd_strategy: str, io_type: str):
_inp = HQuantize()(inp)
else:
raise Exception(f'Please add test for {layer}')
out = eval('HGQ.layers.' + layer)(_inp)

_layer = eval('HGQ.layers.' + layer)
if hasattr(_layer, 'bias') and _layer.bias is not None:
bias: tf.Variable = _layer.bias
bias.assign(tf.constant(np.random.uniform(-4, 4, _layer.bias.shape).astype(np.float32)))

out = _layer(_inp)
model = keras.Model(inp, out)

for layer in model.layers:
Expand Down
3 changes: 3 additions & 0 deletions test/test_syn_large.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def create_model(rnd_strategy: str, io_type: str):
if hasattr(layer, 'paq'):
fbw: tf.Variable = layer.paq.fbw
fbw.assign(tf.constant(np.random.uniform(2, 6, fbw.shape).astype(np.float32)))
if hasattr(layer, 'bias') and layer.bias is not None:
bias: tf.Variable = layer.bias
bias.assign(tf.constant(np.random.uniform(-4, 4, layer.bias.shape).astype(np.float32)))
return horrible_model


Expand Down
3 changes: 3 additions & 0 deletions test/test_syn_small.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def create_model(rnd_strategy: str, io_type: str):
if hasattr(layer, 'paq'):
fbw: tf.Variable = layer.paq.fbw
fbw.assign(tf.constant(np.random.uniform(2, 6, fbw.shape).astype(np.float32)))
if hasattr(layer, 'bias') and layer.bias is not None:
bias: tf.Variable = layer.bias
bias.assign(tf.constant(np.random.uniform(-4, 4, layer.bias.shape).astype(np.float32)))
return model


Expand Down

0 comments on commit 72d52fd

Please sign in to comment.