Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix profiling SeparableConv1D and SeparableConv2D #891

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice catch that we missed in the #863

for layer_name, y in outputs.items():
print(f" {layer_name}")
y = y.flatten()
Expand Down
Loading