Skip to content

Commit 2a42ab2

Browse files
committed
Update OnnxTransform.cs
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.
1 parent 6a83a66 commit 2a42ab2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Microsoft.ML.OnnxTransformer/OnnxTransform.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private static VersionInfo GetVersionInfo()
131131
// version 10002 = multiple inputs & outputs
132132
// version 10003 = custom protobuf recursion limit
133133
verWrittenCur: 0x00010003,
134-
verReadableCur: 0x00010002,
134+
verReadableCur: 0x00010003,
135135
verWeCanReadBack: 0x00010001,
136136
loaderSignature: LoaderSignature,
137137
loaderAssemblyName: typeof(OnnxTransformer).Assembly.FullName);
@@ -189,13 +189,15 @@ private static OnnxTransformer Create(IHostEnvironment env, ModelLoadContext ctx
189189
}
190190

191191
int recursionLimit;
192-
try
192+
193+
// Recursion limit change
194+
if (ctx.Header.ModelVerWritten >= 0x00010003)
193195
{
194196
recursionLimit = ctx.Reader.ReadInt32();
195197
}
196-
catch (EndOfStreamException)
198+
else
197199
{
198-
//default if not written inside ONNX model
200+
// Default if not written inside ONNX model
199201
recursionLimit = 100;
200202
}
201203

0 commit comments

Comments
 (0)