-
Notifications
You must be signed in to change notification settings - Fork 19.6k
Make ops consistent and test ops consistency. #21334
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
Conversation
11c0bf0
to
37ce851
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21334 +/- ##
==========================================
- Coverage 82.65% 82.65% -0.01%
==========================================
Files 565 565
Lines 54823 54833 +10
Branches 8514 8515 +1
==========================================
+ Hits 45315 45323 +8
- Misses 7414 7417 +3
+ Partials 2094 2093 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1ef82ba
to
dfdd66c
Compare
Added tests to verify that: - All the parameters in the op class `call` (dynamic / tensor parameters) and `__init__` (static / non-tensor parameters) match the parameters in the op function - the names should match - default values should match - the order should be consistent, usually with the static parameters all at the end - Ops are exported in `keras.ops` - Ops are exported in their module, e.g. `keras.ops.numpy` - Ops are implemented in every backend - The backend implementation has the same signature as the op wrapper (same parameters in the same order with the same default values) Note about default values: only the default values declared in the common op function are used by users, which is why those values were not changed and were applied to the class and backend implementations. - The default values for the class `__init__` are not used because the op function passes all parameters when constructing the class. - The default values for the backend implementation are not used, because the common op function passes all parameters when calling the backend implementation. The exception to this is when an op implementation calls another op directly. Therefore: - The defaults on the backend implementations are just a reminder for the implementer - The defaults on the class `__init__` are mostly a reminder, but can also serve as a forward compatibility mechanism when deserializing a model after a parameter is added. Fixed all inconsistencies, mostly inconsistent default values.
dfdd66c
to
f3de9dc
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.
LGTM, thank you for the PR!
Added tests to verify that:
call
(dynamic / tensor parameters) and__init__
(static / non-tensor parameters) match the parameters in the op functionkeras.ops
keras.ops.numpy
Note about default values: only the default values declared in the common op 8000 function are used by users, which is why those values were not changed and were applied to the class and backend implementations.
__init__
are not used because the op function passes all parameters when constructing the class.Therefore:
__init__
are mostly a reminder, but can also serve as a forward compatibility mechanism when deserializing a model after a parameter is added.Fixed all inconsistencies, mostly inconsistent default values.