-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add support for GlobalMaxPool and GlobalMeanPool #88
Add support for GlobalMaxPool and GlobalMeanPool #88
Conversation
lambe
commented
Oct 27, 2023
- updates serialization and deserialization code to permit model import and export with Flux.GlobalMaxPool and Flux.GlobalMeanPool operations
Lumping in some code for Flux's |
Looks good, but please add tests as well. |
You can change serialization tests to use the Flux native global pools here and here. To make things look consistent, you might want to add a gpvertex function here which looks something like this: |
Thanks for the tip. I just pushed this update. However, these tests are now broken. Error is of this form:
The |
Correction to the above - I think I had an environment error in my local test setup. The errors I'm getting now are mostly shape errors, e.g.,
The issue is that the Flux behaviour is to keep the length-1 dimensions but the behaviour of this package is to drop them as a wrapper in the call to |
Yup. I thought flux Dense supported any number of dimensions these days. Just add a dropdims as a layer after the global pool in the testcases. Something like this: The problem here could be that many onnx models just send a 4D array into the Dense layer after a globpool since the onnx version of Dense supports any number of dimensions iirc. If we just don't touch the deserialization parts we should be ok I hope (unless the test really checks that each op in the loaded model is identical to the original). |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #88 +/- ##
==========================================
+ Coverage 96.07% 96.12% +0.04%
==========================================
Files 15 15
Lines 1044 1109 +65
==========================================
+ Hits 1003 1066 +63
- Misses 41 43 +2 ☔ View full report in Codecov by Sentry. |
Delete redundant global pool functions since we now use the one shipped by Flux.
Thanks alot again @lambe. I will publish a new release with this and Protobuf 1 support right away. The The test harness checks that the loaded CompGraph has the exact same vertices as the saved one. However, ONNXNaiveNASflux tries to be helpful and merge any global pool followed directly by a Squeeze operation into the same vertex. This is both a reminder from before Flux shipped any global pools as well as something which is useful in the NAS context since one typically don't want the search algorithm to insert operations between the global pool and the squeeze. As this is probably quite unintuitive for normal (i.e non-NAS practicing) users I improved the printing of the squeeze (and a couple of other unrelated ops) so that it at least is clear from casual inspection that all OPs are actually part of the CompGraph. I have also opened #93 for a more long term solution. |