Skip to content
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
2 changes: 2 additions & 0 deletions python/tvm/relay/frontend/keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def _convert_activation(
if act_type == "hard_sigmoid":
x = (_expr.const(0.2, dtype="float32") * inexpr) + _expr.const(0.5, dtype="float32")
return _op.clip(x, a_min=0.0, a_max=1.0)
if act_type == "swish":
return inexpr * _op.sigmoid(inexpr)

raise tvm.error.OpNotImplemented(f"Operator {act_type} is not supported in frontend Keras.")

Expand Down
5 changes: 3 additions & 2 deletions tests/python/frontend/keras/test_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def pytest_generate_tests(metafunc):
# Scenarios:
# - classic keras, using keras from "import keras"
# - tensorflow keras, using keras from "from tensorflow import keras as tf_keras"
USING_CALSSIC_KERAS = ("keras", {"keras_mod": keras})
USING_CLASSIC_KERAS = ("keras", {"keras_mod": keras})
USING_TENSORFLOW_KERAS = ("tf_keras", {"keras_mod": tf_keras})


Expand Down Expand Up @@ -134,7 +134,7 @@ def get_mobilenet(keras_mod):
class TestKeras:
"""Keras test"""

scenarios = [USING_CALSSIC_KERAS, USING_TENSORFLOW_KERAS]
scenarios = [USING_CLASSIC_KERAS, USING_TENSORFLOW_KERAS]

def test_forward_merge(self, keras_mod):
"""test_forward_merge"""
Expand Down Expand Up @@ -213,6 +213,7 @@ def test_forward_activations(self, keras_mod):
keras_mod.layers.Activation("tanh"),
keras_mod.layers.Activation("linear"),
keras_mod.layers.Activation("selu"),
keras_mod.layers.Activation("swish"),
keras_mod.layers.ReLU(),
keras_mod.layers.ReLU(max_value=6.0),
keras_mod.layers.ReLU(max_value=6.0, threshold=0.0),
Expand Down