diff --git a/.vsts-dotnet-ci.yml b/.vsts-dotnet-ci.yml index 2699c9b7b3..ff6a0d6bec 100644 --- a/.vsts-dotnet-ci.yml +++ b/.vsts-dotnet-ci.yml @@ -23,6 +23,20 @@ phases: queue: name: Hosted VS2017 +- template: /build/ci/phase-template.yml + parameters: + name: core30 + buildScript: build.cmd + customMatrixes: + Build_Debug_Intrinsics: + _configuration: Debug-Intrinsics + _config_short: DI + Build_Release_Intrinsics: + _configuration: Release-Intrinsics + _config_short: RI + queue: + name: Hosted VS2017 + - template: /build/ci/phase-template.yml parameters: name: Windows_x86 diff --git a/DotnetCLIVersion.netcoreapp.latest.txt b/DotnetCLIVersion.netcoreapp.latest.txt new file mode 100644 index 0000000000..23f4ef9a4c --- /dev/null +++ b/DotnetCLIVersion.netcoreapp.latest.txt @@ -0,0 +1 @@ +3.0.100-alpha1-009622 \ No newline at end of file diff --git a/build/ci/phase-template.yml b/build/ci/phase-template.yml index 9929ba182d..a9d2a35943 100644 --- a/build/ci/phase-template.yml +++ b/build/ci/phase-template.yml @@ -3,6 +3,7 @@ parameters: architecture: x64 buildScript: '' queue: {} + customMatrixes: '' phases: - phase: ${{ parameters.name }} @@ -14,12 +15,15 @@ phases: timeoutInMinutes: 45 parallel: 99 matrix: - Build_Debug: - _configuration: Debug - _config_short: D - Build_Release: - _configuration: Release - _config_short: R + ${{ if eq(parameters.customMatrixes, '') }}: + Build_Debug: + _configuration: Debug + _config_short: D + Build_Release: + _configuration: Release + _config_short: R + ${{ if ne(parameters.customMatrixes, '') }}: + ${{ insert }}: ${{ parameters.customMatrixes }} ${{ insert }}: ${{ parameters.queue }} steps: - script: $(_buildScript) -$(_configuration) -buildArch=$(_arch) diff --git a/config.json b/config.json index 8436586e61..54e56ddeb1 100644 --- a/config.json +++ b/config.json @@ -3,7 +3,7 @@ "Configuration": { "description": "Sets the optimization level for the Build Configuration you want to build.", "valueType": "property", - "values": [ "Debug", "Release" ], + "values": [ "Debug", "Release", "Debug-Intrinsics", "Release-Intrinsics" ], "defaultValue": "Debug" }, "TargetArchitecture": { @@ -94,6 +94,18 @@ "Configuration": "Release" } }, + "debug-intrinsics": { + "description": "Sets optimization level to debug for managed build configuration and builds against netcoreapp3.0. (/p:Configuration=Debug-Intrinsics)", + "settings": { + "Configuration": "Debug-Intrinsics" + } + }, + "release-intrinsics": { + "description": "Sets optimization level to release for managed build configuration and builds against netcoreapp3.0. (/p:Configuration=Release-Intrinsics)", + "settings": { + "Configuration": "Release-Intrinsics" + } + }, "buildArch": { "description": "Sets the architecture for the native build. (/p:TargetArchitecture=[value])", "settings": { diff --git a/init-tools.cmd b/init-tools.cmd index 3743cb413d..349f7b1461 100644 --- a/init-tools.cmd +++ b/init-tools.cmd @@ -46,15 +46,17 @@ if exist "%DotNetBuildToolsDir%" ( echo Running %0 > "%INIT_TOOLS_LOG%" set /p DOTNET_VERSION=< "%~dp0DotnetCLIVersion.txt" -if exist "%DOTNET_CMD%" goto :afterdotnetrestore :Arg_Loop if [%1] == [] goto :ArchSet -if /i [%1] == [x86] ( set ARCH=x86&&goto ArchSet) +if /i [%1] == [x86] ( set ARCH=x86) +if /i [%1] == [-Debug-Intrinsics] ( set /p DOTNET_VERSION=< "%~dp0DotnetCLIVersion.netcoreapp.latest.txt") +if /i [%1] == [-Release-Intrinsics] ( set /p DOTNET_VERSION=< "%~dp0DotnetCLIVersion.netcoreapp.latest.txt") shift goto :Arg_Loop :ArchSet +if exist "%DOTNET_CMD%" goto :afterdotnetrestore echo Installing dotnet cli... if NOT exist "%DOTNET_PATH%" mkdir "%DOTNET_PATH%" diff --git a/src/Microsoft.ML.CpuMath/AvxIntrinsics.cs b/src/Microsoft.ML.CpuMath/AvxIntrinsics.cs index 55e692eb63..5b402c6ba1 100644 --- a/src/Microsoft.ML.CpuMath/AvxIntrinsics.cs +++ b/src/Microsoft.ML.CpuMath/AvxIntrinsics.cs @@ -9,6 +9,7 @@ // * P suffix means sparse (unaligned) partial vector - the vector is only part of a larger sparse vector. // * Tran means the matrix is transposed. +using Microsoft.ML.Runtime.Internal.CpuMath.Core; using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -158,9 +159,6 @@ public static unsafe void MatMul(AlignedArray mat, AlignedArray src, AlignedArra public static unsafe void MatMul(ReadOnlySpan mat, ReadOnlySpan src, Span dst, int crow, int ccol) { - Contracts.Assert(crow % 4 == 0); - Contracts.Assert(ccol % 4 == 0); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) fixed (float* pmat = &MemoryMarshal.GetReference(mat)) @@ -313,9 +311,6 @@ public static unsafe void MatMulP(AlignedArray mat, ReadOnlySpan rgposSrc, public static unsafe void MatMulP(ReadOnlySpan mat, ReadOnlySpan rgposSrc, ReadOnlySpan src, int posMin, int iposMin, int iposEnd, Span dst, int crow, int ccol) { - Contracts.Assert(crow % 8 == 0); - Contracts.Assert(ccol % 8 == 0); - // REVIEW: For extremely sparse inputs, interchanging the loops would // likely be more efficient. fixed (float* psrc = &MemoryMarshal.GetReference(src)) @@ -473,9 +468,6 @@ public static unsafe void MatMulTran(AlignedArray mat, AlignedArray src, Aligned public static unsafe void MatMulTran(ReadOnlySpan mat, ReadOnlySpan src, Span dst, int crow, int ccol) { - Contracts.Assert(crow % 4 == 0); - Contracts.Assert(ccol % 4 == 0); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) fixed (float* pmat = &MemoryMarshal.GetReference(mat)) @@ -951,8 +943,6 @@ public static unsafe void Scale(float scale, Span dst) public static unsafe void ScaleSrcU(float scale, ReadOnlySpan src, Span dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) { @@ -1046,8 +1036,6 @@ public static unsafe void ScaleAddU(float a, float b, Span dst) public static unsafe void AddScaleU(float scale, ReadOnlySpan src, Span dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) { @@ -1100,8 +1088,6 @@ public static unsafe void AddScaleU(float scale, ReadOnlySpan src, Span src, ReadOnlySpan dst, Span result, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) fixed (float* pres = &MemoryMarshal.GetReference(result)) @@ -1156,8 +1142,6 @@ public static unsafe void AddScaleCopyU(float scale, ReadOnlySpan src, Re public static unsafe void AddScaleSU(float scale, ReadOnlySpan src, ReadOnlySpan idx, Span dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (int* pidx = &MemoryMarshal.GetReference(idx)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) @@ -1206,8 +1190,6 @@ public static unsafe void AddScaleSU(float scale, ReadOnlySpan src, ReadO public static unsafe void AddU(ReadOnlySpan src, Span dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) { @@ -1255,8 +1237,6 @@ public static unsafe void AddU(ReadOnlySpan src, Span dst, int cou public static unsafe void AddSU(ReadOnlySpan src, ReadOnlySpan idx, Span dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (int* pidx = &MemoryMarshal.GetReference(idx)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) @@ -1738,8 +1718,6 @@ public static unsafe float MaxAbsDiffU(float mean, ReadOnlySpan src) public static unsafe float DotU(ReadOnlySpan src, ReadOnlySpan dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) { @@ -1792,8 +1770,6 @@ public static unsafe float DotU(ReadOnlySpan src, ReadOnlySpan dst public static unsafe float DotSU(ReadOnlySpan src, ReadOnlySpan dst, ReadOnlySpan idx, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) fixed (int* pidx = &MemoryMarshal.GetReference(idx)) @@ -1848,8 +1824,6 @@ public static unsafe float DotSU(ReadOnlySpan src, ReadOnlySpan ds public static unsafe float Dist2(ReadOnlySpan src, ReadOnlySpan dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) { diff --git a/src/Microsoft.ML.CpuMath/SseIntrinsics.cs b/src/Microsoft.ML.CpuMath/SseIntrinsics.cs index 5d6f2ed134..9583fbe652 100644 --- a/src/Microsoft.ML.CpuMath/SseIntrinsics.cs +++ b/src/Microsoft.ML.CpuMath/SseIntrinsics.cs @@ -122,9 +122,6 @@ public static unsafe void MatMul(AlignedArray mat, AlignedArray src, AlignedArra public static unsafe void MatMul(ReadOnlySpan mat, ReadOnlySpan src, Span dst, int crow, int ccol) { - Contracts.Assert(crow % 4 == 0); - Contracts.Assert(ccol % 4 == 0); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) fixed (float* pmat = &MemoryMarshal.GetReference(mat)) @@ -285,9 +282,6 @@ public static unsafe void MatMulP(AlignedArray mat, ReadOnlySpan rgposSrc, public static unsafe void MatMulP(ReadOnlySpan mat, ReadOnlySpan rgposSrc, ReadOnlySpan src, int posMin, int iposMin, int iposEnd, Span dst, int crow, int ccol) { - Contracts.Assert(crow % 4 == 0); - Contracts.Assert(ccol % 4 == 0); - // REVIEW: For extremely sparse inputs, interchanging the loops would // likely be more efficient. fixed (float* psrc = &MemoryMarshal.GetReference(src)) @@ -448,9 +442,6 @@ public static unsafe void MatMulTran(AlignedArray mat, AlignedArray src, Aligned public static unsafe void MatMulTran(ReadOnlySpan mat, ReadOnlySpan src, Span dst, int crow, int ccol) { - Contracts.Assert(crow % 4 == 0); - Contracts.Assert(ccol % 4 == 0); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) fixed (float* pmat = &MemoryMarshal.GetReference(mat)) @@ -893,8 +884,6 @@ public static unsafe void Scale(float scale, Span dst) public static unsafe void ScaleSrcU(float scale, ReadOnlySpan src, Span dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) { @@ -963,8 +952,6 @@ public static unsafe void ScaleAddU(float a, float b, Span dst) public static unsafe void AddScaleU(float scale, ReadOnlySpan src, Span dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) { @@ -1004,8 +991,6 @@ public static unsafe void AddScaleU(float scale, ReadOnlySpan src, Span src, ReadOnlySpan dst, Span result, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) fixed (float* pres = &MemoryMarshal.GetReference(result)) @@ -1047,8 +1032,6 @@ public static unsafe void AddScaleCopyU(float scale, ReadOnlySpan src, Re public static unsafe void AddScaleSU(float scale, ReadOnlySpan src, ReadOnlySpan idx, Span dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (int* pidx = &MemoryMarshal.GetReference(idx)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) @@ -1085,8 +1068,6 @@ public static unsafe void AddScaleSU(float scale, ReadOnlySpan src, ReadO public static unsafe void AddU(ReadOnlySpan src, Span dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) { @@ -1122,8 +1103,6 @@ public static unsafe void AddU(ReadOnlySpan src, Span dst, int cou public static unsafe void AddSU(ReadOnlySpan src, ReadOnlySpan idx, Span dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (int* pidx = &MemoryMarshal.GetReference(idx)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) @@ -1157,9 +1136,6 @@ public static unsafe void AddSU(ReadOnlySpan src, ReadOnlySpan idx, public static unsafe void MulElementWiseU(ReadOnlySpan src1, ReadOnlySpan src2, Span dst, int count) { - Contracts.Assert(src1.Length == dst.Length); - Contracts.Assert(src2.Length == dst.Length); - fixed (float* psrc1 = &MemoryMarshal.GetReference(src1)) fixed (float* psrc2 = &MemoryMarshal.GetReference(src2)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) @@ -1494,8 +1470,6 @@ public static unsafe float MaxAbsDiffU(float mean, ReadOnlySpan src) public static unsafe float DotU(ReadOnlySpan src, ReadOnlySpan dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) { @@ -1535,8 +1509,6 @@ public static unsafe float DotU(ReadOnlySpan src, ReadOnlySpan dst public static unsafe float DotSU(ReadOnlySpan src, ReadOnlySpan dst, ReadOnlySpan idx, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) fixed (int* pidx = &MemoryMarshal.GetReference(idx)) @@ -1578,8 +1550,6 @@ public static unsafe float DotSU(ReadOnlySpan src, ReadOnlySpan ds public static unsafe float Dist2(ReadOnlySpan src, ReadOnlySpan dst, int count) { - Contracts.Assert(src.Length == dst.Length); - fixed (float* psrc = &MemoryMarshal.GetReference(src)) fixed (float* pdst = &MemoryMarshal.GetReference(dst)) { diff --git a/test/Microsoft.ML.Core.Tests/UnitTests/TestCSharpApi.cs b/test/Microsoft.ML.Core.Tests/UnitTests/TestCSharpApi.cs index 362e440935..f5d9006800 100644 --- a/test/Microsoft.ML.Core.Tests/UnitTests/TestCSharpApi.cs +++ b/test/Microsoft.ML.Core.Tests/UnitTests/TestCSharpApi.cs @@ -255,7 +255,7 @@ public void TestCrossValidationBinaryMacro() } } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline public void TestCrossValidationMacro() { var dataPath = GetDataPath(TestDatasets.generatedRegressionDatasetmacro.trainFilename); diff --git a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs index ec9cbd85e3..5e6b541acb 100644 --- a/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs +++ b/test/Microsoft.ML.Core.Tests/UnitTests/TestEntryPoints.cs @@ -961,7 +961,7 @@ public void EntryPointPipelineEnsemble() getterAnom(ref scoreAnom); Assert.True(Single.IsNaN(scoreBin) && Single.IsNaN(score) || scoreBin == score); Assert.True(Single.IsNaN(scoreBinCali) && Single.IsNaN(score) || scoreBinCali == score); - Assert.True(Single.IsNaN(scoreSaved) && Single.IsNaN(score) || scoreSaved == score); + Assert.True(Single.IsNaN(scoreSaved) && Single.IsNaN(score) || CompareNumbersWithTolerance(scoreSaved, score, null, 6)); Assert.True(Single.IsNaN(scoreAnom) && Single.IsNaN(score) || scoreAnom == score); Single avg = 0; @@ -1341,7 +1341,7 @@ public void EntryPointMulticlassPipelineEnsemble() } } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] public void EntryPointPipelineEnsembleGetSummary() { var dataPath = GetDataPath("breast-cancer-withheader.txt"); @@ -1431,14 +1431,14 @@ public void EntryPointPipelineEnsembleGetSummary() var saver = Env.CreateSaver("Text"); using (var file = Env.CreateOutputFile(summary)) DataSaverUtils.SaveDataView(ch, saver, summaryDataViews.Summaries[i], file); - CheckEquality(@"../Common/EntryPoints", $"ensemble-model{i}-summary.txt"); + CheckEquality(@"../Common/EntryPoints", $"ensemble-model{i}-summary.txt", digitsOfPrecision: 4); if (summaryDataViews.Stats[i] != null) { var stats = DeleteOutputPath(@"../Common/EntryPoints", $"ensemble-model{i}-stats.txt"); using (var file = Env.CreateOutputFile(stats)) DataSaverUtils.SaveDataView(ch, saver, summaryDataViews.Stats[i], file); - CheckEquality(@"../Common/EntryPoints", $"ensemble-model{i}-stats.txt"); + CheckEquality(@"../Common/EntryPoints", $"ensemble-model{i}-stats.txt", digitsOfPrecision: 4); } } } @@ -1448,7 +1448,7 @@ public void EntryPointPipelineEnsembleGetSummary() using (var writer = Utils.OpenWriter(file)) summarizable.SaveSummary(writer, null); - CheckEquality(@"../Common/EntryPoints", "ensemble-summary.txt"); + CheckEquality(@"../Common/EntryPoints", "ensemble-summary.txt", digitsOfPrecision: 4); var summaryKvps = binaryEnsembleCalibrated.Predictor as ICanGetSummaryInKeyValuePairs; Assert.NotNull(summaryKvps); @@ -1472,7 +1472,7 @@ public void EntryPointPipelineEnsembleGetSummary() } } } - CheckEquality(@"../Common/EntryPoints", "ensemble-summary-key-value-pairs.txt"); + CheckEquality(@"../Common/EntryPoints", "ensemble-summary-key-value-pairs.txt", digitsOfPrecision: 4); Done(); } diff --git a/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs b/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs index 3d4c7b63aa..9f900b5440 100644 --- a/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs +++ b/test/Microsoft.ML.Predictor.Tests/TestPredictors.cs @@ -161,7 +161,7 @@ public void EarlyStoppingTest() /// /// Multiclass Logistic Regression test. /// - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline [TestCategory("Multiclass")] [TestCategory("Logistic Regression")] public void MulticlassLRTest() @@ -173,7 +173,7 @@ public void MulticlassLRTest() /// /// Multiclass Logistic Regression with non-negative coefficients test. /// - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline [TestCategory("Multiclass")] [TestCategory("Logistic Regression")] public void MulticlassLRNonNegativeTest() @@ -313,7 +313,7 @@ public void BinaryClassifierLogisticRegressionNormTest() /// ///A test for binary classifiers with non-negative coefficients /// - [ConditionalFact(typeof(Environment), nameof(Environment.Is64BitProcess))] // x86 output differs from Baseline + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCoreAnd64BitProcess))] // netcore3.0 and x86 output differs from Baseline [TestCategory("Binary")] public void BinaryClassifierLogisticRegressionNonNegativeTest() { @@ -326,7 +326,7 @@ public void BinaryClassifierLogisticRegressionNonNegativeTest() /// ///A test for binary classifiers /// - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline [TestCategory("Binary")] public void BinaryClassifierLogisticRegressionBinNormTest() { @@ -904,7 +904,7 @@ private void CombineAndTestEnsembles(IDataView idv, string name, string options, predGetters[i](ref preds[i]); } if (scores.All(s => !float.IsNaN(s))) - Assert.Equal(score, scores.Sum() / predCount, 3); + CompareNumbersWithTolerance(score, scores.Sum() / predCount); for (int i = 0; i < predCount; i++) Assert.Equal(vectorScore.Length, vectorScores[i].Length); for (int i = 0; i < vectorScore.Length; i++) @@ -1561,7 +1561,7 @@ public IList GetDatasetsForCalibratorTest() /// ///A test for no calibrators /// - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline [TestCategory("Calibrator")] public void DefaultCalibratorPerceptronTest() { @@ -1573,7 +1573,7 @@ public void DefaultCalibratorPerceptronTest() /// ///A test for PAV calibrators /// - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline [TestCategory("Calibrator")] public void PAVCalibratorPerceptronTest() { @@ -1585,7 +1585,7 @@ public void PAVCalibratorPerceptronTest() /// ///A test for random calibrators /// - [ConditionalFact(typeof(Environment), nameof(Environment.Is64BitProcess))] // x86 output differs from Baseline + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCoreAnd64BitProcess))] // netcore3.0 and x86 output differs from Baseline [TestCategory("Calibrator")] public void RandomCalibratorPerceptronTest() { diff --git a/test/Microsoft.ML.StaticPipelineTesting/Training.cs b/test/Microsoft.ML.StaticPipelineTesting/Training.cs index 7a22368843..83836447e9 100644 --- a/test/Microsoft.ML.StaticPipelineTesting/Training.cs +++ b/test/Microsoft.ML.StaticPipelineTesting/Training.cs @@ -961,7 +961,7 @@ public void HogwildSGDBinaryClassification() Assert.InRange(metrics.Auprc, 0, 1); } - [ConditionalFact(typeof(Environment), nameof(Environment.Is64BitProcess))] // This test is being fixed as part of issue #1441. + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCoreAnd64BitProcess))] // netcore3.0 and x86 output differs from Baseline. This test is being fixed as part of issue #1441. public void MatrixFactorization() { // Create a new context for ML.NET operations. It can be used for exception tracking and logging, diff --git a/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs b/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs index 0a1e7ada2f..dbdbee29ae 100644 --- a/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs +++ b/test/Microsoft.ML.TestFramework/BaseTestBaseline.cs @@ -24,6 +24,10 @@ public abstract partial class BaseTestBaseline : BaseTestClass { public const int DigitsOfPrecision = 7; + public static bool LessThanNetCore30OrNotNetCore { get; } = AppDomain.CurrentDomain.GetData("FX_PRODUCT_VERSION") == null ? true : false; + + public static bool LessThanNetCore30OrNotNetCoreAnd64BitProcess { get; } = LessThanNetCore30OrNotNetCore && Environment.Is64BitProcess; + protected BaseTestBaseline(ITestOutputHelper output) : base(output) { } diff --git a/test/Microsoft.ML.TestFramework/TestCommandBase.cs b/test/Microsoft.ML.TestFramework/TestCommandBase.cs index a4593edbb1..bc62b2c9d0 100644 --- a/test/Microsoft.ML.TestFramework/TestCommandBase.cs +++ b/test/Microsoft.ML.TestFramework/TestCommandBase.cs @@ -1172,7 +1172,7 @@ public void CommandTrainMlrWithLabelNames() Done(); } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline [TestCategory(Cat), TestCategory("Multiclass"), TestCategory("Logistic Regression")] public void CommandTrainMlrWithStats() { diff --git a/test/Microsoft.ML.Tests/CSharpCodeGen.cs b/test/Microsoft.ML.Tests/CSharpCodeGen.cs index d16a9924f1..a2f2fa7459 100644 --- a/test/Microsoft.ML.Tests/CSharpCodeGen.cs +++ b/test/Microsoft.ML.Tests/CSharpCodeGen.cs @@ -22,7 +22,7 @@ public void RegenerateCSharpApi() Runtime.Tools.Maml.Main(new[] { $"? generator=cs{{csFilename={basePath}}}" }); } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(LessThanNetCore30OrNotNetCore))] public void TestGeneratedCSharpAPI() { var dataPath = GetOutputPath("Api.cs"); diff --git a/test/Microsoft.ML.Tests/OnnxTests.cs b/test/Microsoft.ML.Tests/OnnxTests.cs index 320af0adde..9b53f9aba8 100644 --- a/test/Microsoft.ML.Tests/OnnxTests.cs +++ b/test/Microsoft.ML.Tests/OnnxTests.cs @@ -351,7 +351,7 @@ public void WordEmbeddingsTest() Done(); } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 differs from Baseline public void KmeansTest() { string dataPath = GetDataPath(@"breast-cancer.txt"); diff --git a/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs b/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs index aa7d6f2b5e..258f9d6e4a 100644 --- a/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs +++ b/test/Microsoft.ML.Tests/Transformers/NormalizerTests.cs @@ -393,7 +393,7 @@ public void TestLpNormOldSavingAndLoading() } } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline public void GcnWorkout() { string dataSource = GetDataPath(TestDatasets.generatedRegressionDataset.trainFilename); diff --git a/test/Microsoft.ML.Tests/Transformers/RffTests.cs b/test/Microsoft.ML.Tests/Transformers/RffTests.cs index d647eddbca..f231082757 100644 --- a/test/Microsoft.ML.Tests/Transformers/RffTests.cs +++ b/test/Microsoft.ML.Tests/Transformers/RffTests.cs @@ -37,7 +37,7 @@ private class TestClassInvalidSchema public int A; } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline public void RffWorkout() { Random rand = new Random(); diff --git a/test/Microsoft.ML.TimeSeries.Tests/TimeSeries.cs b/test/Microsoft.ML.TimeSeries.Tests/TimeSeries.cs index 308e45c247..f20de461f4 100644 --- a/test/Microsoft.ML.TimeSeries.Tests/TimeSeries.cs +++ b/test/Microsoft.ML.TimeSeries.Tests/TimeSeries.cs @@ -72,7 +72,7 @@ public void SavePipeSsaSpike() Done(); } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline public void SavePipeSsaSpikeNoData() { string pathData = DeleteOutputPath("SavePipe", "SsaSpikeNoData.txt"); diff --git a/test/Microsoft.ML.TimeSeries.Tests/TimeSeriesDirectApi.cs b/test/Microsoft.ML.TimeSeries.Tests/TimeSeriesDirectApi.cs index 8cc54896a8..0bd4604daa 100644 --- a/test/Microsoft.ML.TimeSeries.Tests/TimeSeriesDirectApi.cs +++ b/test/Microsoft.ML.TimeSeries.Tests/TimeSeriesDirectApi.cs @@ -9,6 +9,7 @@ using Microsoft.ML.Data; using Microsoft.ML.Runtime.Api; using Microsoft.ML.Runtime.Data; +using Microsoft.ML.Runtime.RunTests; using Microsoft.ML.Runtime.TimeSeriesProcessing; using Microsoft.ML.TimeSeries; using Xunit; @@ -86,7 +87,7 @@ public void ChangeDetection() } } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline public void ChangePointDetectionWithSeasonality() { var env = new MLContext(conc: 1); @@ -136,7 +137,7 @@ public void ChangePointDetectionWithSeasonality() } } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] public void ChangePointDetectionWithSeasonalityPredictionEngineNoColumn() { const int ChangeHistorySize = 10; @@ -189,10 +190,10 @@ public void ChangePointDetectionWithSeasonalityPredictionEngineNoColumn() var engine2 = model2.CreateTimeSeriesPredictionFunction(ml); var prediction2 = engine2.Predict(new Data(1)); //Raw score after first input. - Assert.Equal(1.1661833524703979, prediction2.Change[1], precision: 7); // Raw score + Assert.Equal(1.1661833524703979, prediction2.Change[1], precision: 5); // Raw score prediction2 = engine2.Predict(new Data(1)); //Raw score after second input. - Assert.Equal(0.12216401100158691, prediction2.Change[1], precision: 7); // Raw score + Assert.Equal(0.12216401100158691, prediction2.Change[1], precision: 5); // Raw score //Even though time series column is not requested it will // pass the observation through time series transform and update the state with the first input. @@ -209,10 +210,10 @@ public void ChangePointDetectionWithSeasonalityPredictionEngineNoColumn() //and raw score should match the raw score obtained by passing the two input in the first model. var engine3 = model3.CreateTimeSeriesPredictionFunction(ml); var prediction3 = engine3.Predict(new Data(1)); - Assert.Equal(0.12216401100158691, prediction2.Change[1], precision: 7); // Raw score + Assert.Equal(0.12216401100158691, prediction2.Change[1], precision: 5); // Raw score } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] public void ChangePointDetectionWithSeasonalityPredictionEngine() { const int ChangeHistorySize = 10; @@ -252,7 +253,7 @@ public void ChangePointDetectionWithSeasonalityPredictionEngine() var engine = model.CreateTimeSeriesPredictionFunction(ml); var prediction = engine.Predict(new Data(1)); Assert.Equal(0, prediction.Change[0], precision: 7); // Alert - Assert.Equal(1.1661833524703979, prediction.Change[1], precision: 7); // Raw score + Assert.Equal(1.1661833524703979, prediction.Change[1], precision: 5); // Raw score Assert.Equal(0.5, prediction.Change[2], precision: 7); // P-Value score Assert.Equal(5.1200000000000114E-08, prediction.Change[3], precision: 7); // Martingale score @@ -263,8 +264,8 @@ public void ChangePointDetectionWithSeasonalityPredictionEngine() //Model 1: Prediction #2 prediction = engine.Predict(new Data(1)); Assert.Equal(0, prediction.Change[0], precision: 7); // Alert - Assert.Equal(0.12216401100158691, prediction.Change[1], precision: 7); // Raw score - Assert.Equal(0.14823824685192111, prediction.Change[2], precision: 7); // P-Value score + Assert.Equal(0.12216401100158691, prediction.Change[1], precision: 5); // Raw score + Assert.Equal(0.14823824685192111, prediction.Change[2], precision: 5); // P-Value score Assert.Equal(1.5292508189989167E-07, prediction.Change[3], precision: 7); // Martingale score // Load Model 1. @@ -276,9 +277,9 @@ public void ChangePointDetectionWithSeasonalityPredictionEngine() engine = model2.CreateTimeSeriesPredictionFunction(ml); prediction = engine.Predict(new Data(1)); Assert.Equal(0, prediction.Change[0], precision: 7); // Alert - Assert.Equal(0.12216401100158691, prediction.Change[1], precision: 7); // Raw score - Assert.Equal(0.14823824685192111, prediction.Change[2], precision: 7); // P-Value score - Assert.Equal(1.5292508189989167E-07, prediction.Change[3], precision: 7); // Martingale score + Assert.Equal(0.12216401100158691, prediction.Change[1], precision: 5); // Raw score + Assert.Equal(0.14823824685192111, prediction.Change[2], precision: 5); // P-Value score + Assert.Equal(1.5292508189989167E-07, prediction.Change[3], precision: 5); // Martingale score } } } diff --git a/test/Microsoft.ML.TimeSeries.Tests/TimeSeriesEstimatorTests.cs b/test/Microsoft.ML.TimeSeries.Tests/TimeSeriesEstimatorTests.cs index 3d7cfd5d32..a7892701d7 100644 --- a/test/Microsoft.ML.TimeSeries.Tests/TimeSeriesEstimatorTests.cs +++ b/test/Microsoft.ML.TimeSeries.Tests/TimeSeriesEstimatorTests.cs @@ -41,7 +41,7 @@ public TimeSeriesEstimatorTests(ITestOutputHelper output) : base(output) { } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline void TestSsaChangePointEstimator() { int Confidence = 95; @@ -75,7 +75,7 @@ void TestSsaChangePointEstimator() Done(); } - [Fact] + [ConditionalFact(typeof(BaseTestBaseline), nameof(BaseTestBaseline.LessThanNetCore30OrNotNetCore))] // netcore3.0 output differs from Baseline void TestSsaSpikeEstimator() { int Confidence = 95;