Conversation
Summary of ChangesHello @MarcosAsh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request adds the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces the fold operation to keras.ops.nn, which serves as the inverse of unfold (im2col). The implementation includes support for JAX, TensorFlow, and NumPy backends, a passthrough for the Torch backend, and raises a NotImplementedError for the OpenVINO backend, which is consistent with the unfold operation. The changes are well-structured and include a comprehensive set of tests covering various scenarios like non-overlapping and overlapping roundtrips, multi-channel inputs, and different parameter configurations. My review includes one suggestion for the TensorFlow backend implementation to improve code consistency and maintainability by using a helper function, similar to how it's done in the JAX and NumPy backends.
| k = ( | ||
| (kernel_size, kernel_size) | ||
| if isinstance(kernel_size, int) | ||
| else kernel_size | ||
| ) | ||
| o = ( | ||
| (output_size, output_size) | ||
| if isinstance(output_size, int) | ||
| else output_size | ||
| ) | ||
| d = (dilation, dilation) if isinstance(dilation, int) else dilation | ||
| p = (padding, padding) if isinstance(padding, int) else padding | ||
| s = (stride, stride) if isinstance(stride, int) else stride |
There was a problem hiding this comment.
For consistency with the JAX and NumPy backend implementations of fold, consider using a _pair helper function to handle integer inputs for kernel_size, output_size, dilation, padding, and stride. This would reduce code duplication and improve readability, adhering to the principle of internal consistency mentioned in the style guide.
def _pair(x):
return (x, x) if isinstance(x, int) else x
k = _pair(kernel_size)
o = _pair(output_size)
d = _pair(dilation)
p = _pair(padding)
s = _pair(stride)References
- The style guide emphasizes internal consistency. While the rule on line 71 specifically mentions naming, its principle of internal consistency can be extended to implementation patterns. Using a
_pairhelper function here would align the TensorFlow backend's implementation with the JAX and NumPy backends for the same operation, improving code clarity and maintainability. (link)
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #22283 +/- ##
===========================================
+ Coverage 71.44% 82.74% +11.29%
===========================================
Files 594 594
Lines 65029 65860 +831
Branches 10174 10278 +104
===========================================
+ Hits 46461 54493 +8032
+ Misses 16105 8730 -7375
- Partials 2463 2637 +174
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:
|
a476465 to
6245fec
Compare
6245fec to
b2aafd7
Compare
Fix ruff formatting in tensorflow/nn.py and nn_test.py. Add tests for tuple parameters, zero padding, non-square outputs, larger batch/channel dimensions, and divisibility validation.
|
Hi I did some changes I added tests for tuple parameters (non-square kernels, asymmetric padding/stride) and added tests for zero padding, non-square output sizes, larger batch/channel dimensions, and divisibility validation |
Summary
tensor (N, C, oH, oW) by summing overlapping patches.
Test plan