Skip to content

Commit

Permalink
[KERAS]Minimum & AlphaDropout op support (#5380)
Browse files Browse the repository at this point in the history
  • Loading branch information
siju-samuel authored Apr 22, 2020
1 parent ef61fd5 commit 24f6865
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit 24f6865

Please sign in to comment.