-
Notifications
You must be signed in to change notification settings - Fork 86
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
Simplify lq.math implementations #677
base: main
Are you sure you want to change the base?
Conversation
Minor comment: |
Yes, you are right. The idea behind it was that we then would be implementation independent, but I agree a proper pattern is much easier and we can still keep it backwards compatible. |
I agree that matching directly against the pattern in LCE would be good. If it doesn't cause any issues, it might be nice to still keep the How do you think we should manage the scenario where somebody uses a new version of Larq but an old version of the converter? I guess on init we could try and detect if LCE is installed, detect the version, and print some kind of warning message if it's |
Yes, I think that should work well. That's how TensorFlow Addons handles it as well. |
39d15e6
to
e24265d
Compare
I added a LCE version check to I'd be happy to move this check to |
e24265d
to
3f16474
Compare
eb4c852
to
810bede
Compare
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.
Awesome :)
I guess we should run a quick sanity check model conversion with LCE 0.6.1 before merging, but this looks great.
I will run a sanity check later today or tomorrow to be save! |
@lgeiger @AdamHillier @Tombana : just as a suggestion since I'm dealing with
instead of
This would result in fewer ops. |
@simonmaurer Did you do any performance profiling of you proposed solution? One problem with using |
@lgeiger ah I see, this is indeed good reasoning. I didn't do any performance tests yet. |
This PR simplifies the implementations of
lq.math
to make them more readable. Currently this would break Compute Engine, since we rely on the implementation details there. We could either fix this using@tf.function(experimental_implements=...)
which would require us dropping support for older TensorFlow version, or we could update the patterns in Compute Engine to handle this implementation properly which shouldn't be hard.I briefly evaluated the performance impact of this change on a T4 GPU in this notebook (although only on one input size). This shows performance improvements for some cases and performance regressions for others, although I am not sure if this would be noticeable in a real world model. I am happy to run benchmarks if you think this change might impact full model training performance.
This PR is still WIP for now to explore this further.