From ee702bd2889a8c8b42a5c606b79a7f0137f3f32c Mon Sep 17 00:00:00 2001 From: shahasad <43590019+shahasad@users.noreply.github.com> Date: Fri, 15 Feb 2019 16:08:20 -0800 Subject: [PATCH] patched the logic of removing the ._*.onnx file, in case it comes in position other than the first in listdir (#484) --- .../InferenceTest.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs index c8225cc125..633bd87df4 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs @@ -237,12 +237,20 @@ namespace Microsoft.ML.OnnxRuntime.Tests try { var onnxModelNames = modelDir.GetFiles("*.onnx"); - if (onnxModelNames.Count() != 1) + if (onnxModelNames.Length > 1) { // TODO remove file "._resnet34v2.onnx" from test set - if (onnxModelNames[0].Name == "._resnet34v2.onnx") - onnxModelNames[0] = onnxModelNames[1]; - else + bool validModelFound = false; + for (int i = 0; i < onnxModelNames.Length; i++) + { + if (onnxModelNames[i].Name != "._resnet34v2.onnx") + { + onnxModelNames[0] = onnxModelNames[i]; + validModelFound = true; + } + } + + if (!validModelFound) { var modelNamesList = string.Join(",", onnxModelNames.Select(x => x.ToString())); throw new Exception($"Opset {opset}: Model {modelDir}. Can't determine model file name. Found these :{modelNamesList}");