Skip to content

Commit 6a83a66

Browse files
committed
increment model version and add a test for recursion limit
1 parent 159b507 commit 6a83a66

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/Microsoft.ML.OnnxTransformer/OnnxCatalog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static OnnxScoringEstimator ApplyOnnxModel(this TransformsCatalog catalog
110110
/// <param name="modelFile">The path of the file containing the ONNX model.</param>
111111
/// <param name="shapeDictionary">ONNX shapes to be used over those loaded from <paramref name="modelFile"/>.
112112
/// For keys use names as stated in the ONNX model, e.g. "input". Stating the shapes with this parameter
113-
/// is particullarly useful for working with variable dimension inputs and outputs.
113+
/// is particularly useful for working with variable dimension inputs and outputs.
114114
/// </param>
115115
/// <param name="gpuDeviceId">Optional GPU device ID to run execution on, <see langword="null" /> to run on CPU.</param>
116116
/// <param name="fallbackToCpu">If GPU error, raise exception or fallback to CPU.</param>

src/Microsoft.ML.OnnxTransformer/OnnxTransform.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ private static VersionInfo GetVersionInfo()
129129
modelSignature: "ONNXSCOR",
130130
// version 10001 is single input & output.
131131
// version 10002 = multiple inputs & outputs
132-
verWrittenCur: 0x00010002,
132+
// version 10003 = custom protobuf recursion limit
133+
verWrittenCur: 0x00010003,
133134
verReadableCur: 0x00010002,
134135
verWeCanReadBack: 0x00010001,
135136
loaderSignature: LoaderSignature,

test/Microsoft.ML.OnnxTransformerTest/OnnxTransformTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,5 +1002,32 @@ public void TestOnnxTransformSaveAndLoadWithCustomShapes()
10021002
(model as IDisposable)?.Dispose();
10031003
(loadedModel as IDisposable)?.Dispose();
10041004
}
1005+
1006+
/// <summary>
1007+
/// A test to check if recursion limit works.
1008+
/// </summary>
1009+
[OnnxFact]
1010+
public void TestOnnxTransformSaveAndLoadWithRecursionLimit()
1011+
{
1012+
var modelFile = Path.Combine(Directory.GetCurrentDirectory(), "squeezenet", "00000001", "model.onnx");
1013+
1014+
const int imageHeight = 224;
1015+
const int imageWidth = 224;
1016+
var dataFile = GetDataPath("images/images.tsv");
1017+
var imageFolder = Path.GetDirectoryName(dataFile);
1018+
1019+
var data = ML.Data.LoadFromTextFile(dataFile, new[] {
1020+
new TextLoader.Column("imagePath", DataKind.String, 0),
1021+
new TextLoader.Column("name", DataKind.String, 1)
1022+
});
1023+
1024+
var pipe = ML.Transforms.LoadImages("data_0", imageFolder, "imagePath")
1025+
.Append(ML.Transforms.ResizeImages("data_0", imageHeight, imageWidth))
1026+
.Append(ML.Transforms.ExtractPixels("data_0", interleavePixelColors: true))
1027+
.Append(ML.Transforms.ApplyOnnxModel(new []{ "softmaxout_1" }, new []{ "data_0" }, modelFile,
1028+
gpuDeviceId: _gpuDeviceId, fallbackToCpu: _fallbackToCpu, shapeDictionary: null, recursionLimit: 50));
1029+
1030+
TestEstimatorCore(pipe, data);
1031+
}
10051032
}
10061033
}

0 commit comments

Comments
 (0)