-
Notifications
You must be signed in to change notification settings - Fork 613
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
Typing the gelu activation function. #928
Conversation
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused import?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks!
I need to disable autograph to use the decorator. It's fine to use normal tracing.