Skip to content

Commit

Permalink
Fix profiling SeparableConv1D and SeparableConv2D (#891)
Browse files Browse the repository at this point in the history
* Profiling: Fix suffixes for SeparableConv1D&2D

* Profiling: transform list to dict where dict is expected

---------

Co-authored-by: Quentin Berthet <[email protected]>
  • Loading branch information
qberthet and Quentin Berthet authored Oct 20, 2023
1 parent b67e730 commit 62d5e03
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hls4ml/model/profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import seaborn as sb

from hls4ml.model.graph import ModelGraph
from hls4ml.model.layers import GRU, LSTM
from hls4ml.model.layers import GRU, LSTM, SeparableConv1D, SeparableConv2D

try:
import qkeras
Expand Down Expand Up @@ -184,6 +184,8 @@ def types_hlsmodel(model):
for layer in model.get_layers():
if isinstance(layer, GRU) or isinstance(layer, LSTM):
suffix = ['w', 'rw', 'b', 'rb']
elif isinstance(layer, SeparableConv1D) or isinstance(layer, SeparableConv2D):
suffix = ['dw', 'pw', 'db', 'pb']
else:
suffix = ['w', 'b']
for iw, weight in enumerate(layer.get_weights()):
Expand Down Expand Up @@ -225,6 +227,8 @@ def weights_hlsmodel(model, fmt='longform', plot='boxplot'):
for layer in model.get_layers():
if isinstance(layer, GRU) or isinstance(layer, LSTM):
suffix = ['w', 'rw', 'b', 'rb']
elif isinstance(layer, SeparableConv1D) or isinstance(layer, SeparableConv2D):
suffix = ['dw', 'pw', 'db', 'pb']
else:
suffix = ['w', 'b']
name = layer.name
Expand Down Expand Up @@ -346,6 +350,7 @@ def activations_keras(model, X, fmt='longform', plot='boxplot'):
outputs = _get_outputs(
[layer for layer in model.layers if not isinstance(layer, keras.layers.InputLayer)], X, model.input
)
outputs = dict(zip([layer.name for layer in model.layers if not isinstance(layer, keras.layers.InputLayer)], outputs))
for layer_name, y in outputs.items():
print(f" {layer_name}")
y = y.flatten()
Expand Down

0 comments on commit 62d5e03

Please sign in to comment.