diff --git a/build/Dependencies.props b/build/Dependencies.props index 0fda49b27c..f109987e84 100644 --- a/build/Dependencies.props +++ b/build/Dependencies.props @@ -1,24 +1,44 @@ + + - 3.5.1 10.0.3 - 2.1.3 - 4.8.0 4.4.0 + 1.5.0 + 4.5.1 4.3.0 - 1.0.0-beta-62824-02 + 4.8.0 + + + + + 3.5.1 2.2.1.1 + 1.1.0 0.0.0.7 + 2.1.3 4.5.0 - 0.11.1 + 4.5.0 + 4.5.0 1.10.0 - 1.5.0 - 4.5.1 + + + + 2.9.0 4.5.0 1.2.0 - 1.1.0 - 4.5.0 - 4.5.0 + + + + 1.0.0-beta-62824-02 + + + + + 0.11.1 + 0.0.2-test + + diff --git a/src/Microsoft.ML.Data/Model/ModelHeader.cs b/src/Microsoft.ML.Data/Model/ModelHeader.cs index 37a5b9ac92..a18593ed60 100644 --- a/src/Microsoft.ML.Data/Model/ModelHeader.cs +++ b/src/Microsoft.ML.Data/Model/ModelHeader.cs @@ -483,6 +483,18 @@ public static bool TryValidate(ref ModelHeader header, BinaryReader reader, long { // No strings. strings = null; + + if (header.VerWritten < VerAssemblyNameSupported) + { + // Before VerAssemblyNameSupported, if there were no strings in the model, + // validation ended here. Specifically the FpTail checks below were skipped. + // There are earlier versions of models that don't have strings, and 'reader' is + // not at FpTail at this point. + // Preserve the previous behavior by returning early here. + loaderAssemblyName = null; + ex = null; + return true; + } } else { diff --git a/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj b/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj index 5ec2eb7a03..51d82b7d47 100644 --- a/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj +++ b/test/Microsoft.ML.Core.Tests/Microsoft.ML.Core.Tests.csproj @@ -2,7 +2,7 @@ CORECLR - + @@ -22,7 +22,11 @@ - + + + + + diff --git a/test/Microsoft.ML.Core.Tests/UnitTests/TestModelLoad.cs b/test/Microsoft.ML.Core.Tests/UnitTests/TestModelLoad.cs new file mode 100644 index 0000000000..d8ea0c6736 --- /dev/null +++ b/test/Microsoft.ML.Core.Tests/UnitTests/TestModelLoad.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.ML.Runtime.Data; +using Microsoft.ML.Runtime.Model; +using Microsoft.ML.TestFramework; +using System.IO; +using Xunit; + +namespace Microsoft.ML.Runtime.RunTests +{ + public class TestModelLoad + { + /// + /// Tests loading a model file that was saved using an older version still loads correctly. + /// + [Fact] + public void LoadOriginalBinaryLoaderModel() + { + using (var env = new LocalEnvironment() + .AddStandardComponents()) + using (var modelStream = File.OpenRead(Path.Combine("TestModels", "BinaryLoader-v3.11.0.0.zip"))) + using (var rep = RepositoryReader.Open(modelStream, env)) + { + IDataLoader result = ModelFileUtils.LoadLoader(env, rep, new MultiFileSource(null), true); + + Assert.Equal(2, result.Schema.ColumnCount); + Assert.Equal("Image", result.Schema[0].Name); + Assert.Equal("Class", result.Schema[1].Name); + } + } + } +} \ No newline at end of file