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

[KERAS]Minimum & AlphaDropout op support #5380

Merged
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions python/tvm/relay/frontend/keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,11 @@ def _convert_merge(inexpr, keras_layer, _):
elif merge_type == 'Subtract':
assert len(inexpr) == 2, "Subtract merge takes 2 inputs."
ret = _op.subtract(ret, inexpr[1])
elif merge_type in ['Add', 'Multiply', 'Maximum']:
op_map = {'Add': _op.add, 'Multiply': _op.multiply, 'Maximum': _op.maximum}
elif merge_type in ['Add', 'Multiply', 'Minimum', 'Maximum']:
op_map = {'Add': _op.add,
'Multiply': _op.multiply,
'Minimum': _op.minimum,
'Maximum': _op.maximum}
for i in range(1, len(inexpr)):
ret = op_map[merge_type](ret, inexpr[i])
elif merge_type == 'Average':
Expand Down Expand Up @@ -902,6 +905,7 @@ def _default_skip(inexpr, keras_layer, _): # pylint: disable=unused-argument
# 'TimeDistributed' : _default_skip,

'Average' : _convert_merge,
'Minimum' : _convert_merge,
'Maximum' : _convert_merge,
'Dot' : _convert_merge,
'Permute' : _convert_permute,
Expand All @@ -910,6 +914,7 @@ def _default_skip(inexpr, keras_layer, _): # pylint: disable=unused-argument

'InputLayer' : _default_skip,
'Dropout' : _default_skip,
'AlphaDropout' : _default_skip,
'SpatialDropout2D' : _default_skip,
'SpatialDropout1D' : _default_skip,
'GaussianDropout' : _default_skip,
Expand Down
1 change: 1 addition & 0 deletions tests/python/frontend/keras/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def test_forward_merge(self, keras):
keras.layers.Subtract(),
keras.layers.Multiply(),
keras.layers.Maximum(),
keras.layers.Minimum(),
keras.layers.Average(),
keras.layers.Concatenate()]
for merge_func in merge_funcs:
Expand Down