-
Notifications
You must be signed in to change notification settings - Fork 674
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
open for inheritance #1451
open for inheritance #1451
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1451 +/- ##
============================================
- Coverage 72.08% 70.67% -1.42%
- Complexity 5126 5297 +171
============================================
Files 473 493 +20
Lines 21970 23222 +1252
Branches 2351 2533 +182
============================================
+ Hits 15838 16413 +575
- Misses 4925 5529 +604
- Partials 1207 1280 +73
Continue to review full report at Codecov.
|
In the example I set up for onnx export I am facing the following specific inheritance problems: From the screenshot you see a particular problem with Conv2d with package privacy on the constructors and the final Builder class. You can see Conv2d, Linear, LayerNorm, LamdaBlock which I could not inherit easily. In the pull request I also included other classes with likely similar situations ... as I would not like to bother you daily with some more classes. |
To achieve an ONNX export for my MuZero implementation https://enpasos.ai/muzero/How#onnx I only "opened" the four classes Conv2d, Linear, LayerNorm, LambdaBlock a little as mentioned above. What do you think about:
That would help me in the way that I could remove the patches of the four classes from my working MuZero ONNX export - which likely is not the best way to do it in general, but at least works for this case. |
Sorry for the delay. I finally get some time to look into this. I look a bit in your repo, and I think the inherit solution doesn't provide a good user experience. It requires user to rewrite their model. I made some changes, it seems we can achieve the Onnx conversion by implementing a set of Of course, we need make some changes to DJL Block API to expose some internal information. The change can be minimal: frankfliu@a1b789f Let me know what do you think. |
Thank you for your expert look into the subject. Your converter approach gives a nice separation of concerns - much better than the inheritance approach I used. Looks promissing to achieve a good UX. My approach was to see if I could manage to run MuZero Inference in the browser. Result: Works fine on the CPU via WebAssembly, but not on the GPU via WebGL, because there were too few onnx network functions supported in WebGL. I would like to add some thoughts from the experience I made on that way:
I think this could be achieved by allowing the user to provide an implementation of the factory method Two more thoughts:
|
For me it would be perfect to switch to your approach. To be able to map an onnx join function to a djl join function in ParallelBlocks it would be nice to have the option to provide a name string for the join function that can be used for the mapping. I do not know what would be the best way to proceed. If you like you can close and open a new issue, or rename this issue. What do you think? |
Two reasons why I closed the old issue and opened a new one (#2231):
|
To implement an onnx export (see #1420 (comment)) I would like to extend the export capability of existing block classes by inheritance. To do this, it would be very helpful if the DJL classes were opened up more to inheritance (the builders and the classes themselves).
This pull request is a suggestion on how this could happen.
Since it simply expands access with respect to inheritance, it should have no impact on existing implementations that use the library.