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

Typing the gelu activation function. #928

Merged
merged 26 commits into from
Jan 28, 2020
Merged

Typing the gelu activation function. #928

merged 26 commits into from
Jan 28, 2020

Conversation

gabrieldemarmiesse
Copy link
Member

I need to disable autograph to use the decorator. It's fine to use normal tracing.

from tensorflow_addons.utils.resource_loader import LazySO

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


@tf.keras.utils.register_keras_serializable(package='Addons')
def gelu(x, approximate=True):
@tf.autograph.experimental.do_not_convert
Copy link
Member

Choose a reason for hiding this comment

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

Hmmmm, this has the potential to be a larger issue.

To start I'm not sure why this function is being converted with autograph in the first place? Simple op call with no @tf.function conversion.

Given that it is for some reason converted, do we see typechecked as forever incompatible with autograph? If so I lean toward not type checking functions that are converting as opposed to the experimental do_not_convert since I'm not sure the long term implications of disabling autograph conversions as the core code base moves forward.

Copy link
Member Author

Choose a reason for hiding this comment

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

Given that it is for some reason converted, do we see typechecked as forever incompatible with autograph?

No idea, but it can be easily changed. What's a lot of work to do is the typing. Let's drop the check for now on functions creating the graph. It should be fine for class constructors though since they're not used with autograph.

Copy link
Member

@seanpmorgan seanpmorgan left a comment

Choose a reason for hiding this comment

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

Largely LGTM. I think this is still a nice improvement to the repo for readability.

@@ -14,13 +14,16 @@
# ==============================================================================

import tensorflow as tf
from typeguard import typechecked
Copy link
Member

Choose a reason for hiding this comment

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

unused import?

Copy link
Member Author

Choose a reason for hiding this comment

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

It reminds me that I need to re-enable this check with flake8

Copy link
Member

@seanpmorgan seanpmorgan left a comment

Choose a reason for hiding this comment

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

LGTM Thanks!

@seanpmorgan seanpmorgan merged commit 6c93b4b into tensorflow:master Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants