-
Notifications
You must be signed in to change notification settings - Fork 19.4k
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
Tweaks for serialization of DTypePolicy in ops/layers. #19728
Conversation
- Subclasses of `Operation` / `Layer` which override `__init__` and use the `dtype` parameter don't expect a `dict`. We deserialize the `DTypePolicy` in `from_config`. - The auto `get_config` feature would break when a `DTypePolicy` was passed to the constructor of any `Operation` or `Layer` subclass not implementing `get_config`.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #19728 +/- ##
=======================================
Coverage 78.52% 78.52%
=======================================
Files 498 498
Lines 45757 45761 +4
Branches 8454 8456 +2
=======================================
+ Hits 35931 35935 +4
Misses 8091 8091
Partials 1735 1735
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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 for the PR!
As of keras-team#19728, Operation.from_config() has been overriding the dtype field in the passed config dict. There doesn't seem to be an explicit contract that from_config doesn't modify the config argument, but this seems to be the case in practice, and this behaviour has broken some code on an internal repo.
As of #19728, Operation.from_config() has been overriding the dtype field in the passed config dict. There doesn't seem to be an explicit contract that from_config doesn't modify the config argument, but this seems to be the case in practice, and this behaviour has broken some code on an internal repo.
Operation
/Layer
which override__init__
and use thedtype
parameter don't expect adict
. We deserialize theDTypePolicy
infrom_config
.get_config
feature would break when aDTypePolicy
was passed to the constructor of anyOperation
orLayer
subclass not implementingget_config
.