-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
Fix tf2.4 #9120
Fix tf2.4 #9120
Conversation
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.
Thanks a lot @jplu
tests/test_optimization_tf.py
Outdated
@@ -76,12 +76,12 @@ def accumulate(grad1, grad2): | |||
local_variables = strategy.experimental_local_results(gradient_placeholder) | |||
local_variables[0].assign(grad1) | |||
local_variables[1].assign(grad2) | |||
strategy.experimental_run_v2(accumulate_on_replica, args=(gradient_placeholder,)) | |||
strategy.run(accumulate_on_replica, args=(gradient_placeholder,)) |
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.
I'm confused, if the strategy was just removed from experimental, how is this going to be compatible with versions <2.4?
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.
The run
method is not experimental anymore since the TF 2.2 release, and removed of the experimental namespace since the 2.4.
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.
Ok but we are pinned to is >=2.0
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.
Yep, at some point if we want to keep improve the TF codebase we have to change this sometime, this will be soon the case with the upcoming perf improvements. We will have to move to at least 2.3.
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.
As example here #9124
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.
I understand, but unless that move happens today, we need some code that deals with both versions here.
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.
like this? (just pushed an update)
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! The part with the version check looks like it would break TensorFlow code given that it's in a tf.function, but I trust you tried it out. Thanks for fixing!
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.
Just added some nits to do the version checks like in other parts of the lib for consistency. Feel free to ignore if it breaks anything.
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
LGTM! |
What does this PR do?
Fix the tests to make them compliant with the new TF 2.4