-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Onnx recursion limit #5840
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
Onnx recursion limit #5840
Conversation
|
@michaelgsharp Hi, could you please take a look at this PR? It fixes the linked issue. Build is failing because I changed the public API, I think. How is this change normally done? |
|
Thanks for taking the time to submit this change. The reason the builds are failing is because we have an API checker in place to make sure we don't change any public methods to help with backwards compatibility. You are changing the The way to fix this is instead of modifying the three |
Codecov Report
@@ Coverage Diff @@
## main #5840 +/- ##
==========================================
- Coverage 68.32% 68.20% -0.12%
==========================================
Files 1131 1134 +3
Lines 241291 241996 +705
Branches 25053 25303 +250
==========================================
+ Hits 164863 165064 +201
- Misses 69923 70276 +353
- Partials 6505 6656 +151
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Yeah, it makes sense. I made these changes. |
michaelgsharp
left a comment
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.
It looks really good. Only 2 things that I can see.
1 - Since how the save/load of the model is being changed, the model version needs to be updated. See here for number you need to increment. Only the verWrittenCur needs to change, the rest are fine. But do add a comment above saving what the change was.
2 - Can you add a unit test that uses a non-default value? Even if you just take an existing test and change the value that will work. The TestEstimatorCore method we have in the tests will test the saving/loading and make sure the model is the same before/after loading.
|
Hey @Crabzmatic I'll merge this today. Just trying to verify one more thing about backwards compatibility. I'm just testing to make sure these newer models can still be loaded fine on an older version of ML.NET. |
Changed the `verReadableCur` to match the `verWrittenCur`. Changed the try catch on model load to only load based on the version the model was written with.
michaelgsharp
left a comment
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.
@Crabzmatic Turns out we did need to update the verReadableCur. I went ahead and made that change and pushed it.
I also changed the model loading so instead of using the try/catch it only tries to load the recursion limit if the model was saved with the right version.
Once the tests are complete I will go ahead and merge this.
* remotes/official/main: Update lgbm to v2.3.1 (dotnet#5851) Speed-up bitmap operations on images. Fixes dotnet#5856 (dotnet#5857) Onnx recursion limit (dotnet#5840) Speed up the inference of the saved_model(s). Fixes dotnet#5847 (dotnet#5848) Signed-off-by: darth-vader-lg <[email protected]>
Fixes #5839
Optional parameter
recursionLimit = 100is added to methods that are loading ONNX models. This parameter is used inGoogle.Protobuf.CodedInputStream.CreateWithLimits(modelStream, Int32.MaxValue, recursionLimit)(see changes in fileOnnxUtils.cs)This parameter is saved in overriden
SaveModelmethod in classOnnxTransformer.Parameter is also read in method
Create, if it is written, default is set otherwise.