Skip to content

Commit

Permalink
Exposed the pure python implementation of lisht. (tensorflow#1251)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldemarmiesse authored Mar 9, 2020
1 parent 111d285 commit eb3f30d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tensorflow_addons/activations/lisht.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from tensorflow_addons.utils import types
from tensorflow_addons.utils.resource_loader import LazySO
from tensorflow_addons import options

_activation_so = LazySO("custom_ops/activations/_activation_ops.so")

Expand All @@ -36,6 +37,17 @@ def lisht(x: types.TensorLike) -> tf.Tensor:
A `Tensor`. Has the same type as `x`.
"""
x = tf.convert_to_tensor(x)

if not options.TF_ADDONS_PY_OPS:
try:
return _lisht_custom_op(x)
except tf.errors.NotFoundError:
options.warn_fallback("lisht")

return _lisht_py(x)


def _lisht_custom_op(x):
return _activation_so.ops.addons_lisht(x)


Expand Down

0 comments on commit eb3f30d

Please sign in to comment.