From 968d162a5fdb0bca00c95eb5a420d1c45d1d4cf4 Mon Sep 17 00:00:00 2001 From: Michael Sharp Date: Thu, 27 Apr 2023 15:04:58 -0600 Subject: [PATCH 1/2] version update fixes --- eng/Versions.props | 8 ++++---- .../Microsoft.ML.TorchSharp.csproj | 1 + src/Microsoft.ML.TorchSharp/NasBert/Models/BaseModel.cs | 2 -- .../NasBert/Models/NasBertModel.cs | 1 - .../NasBert/Models/PredictionHead.cs | 4 ++-- .../NasBert/Models/TransformerEncoder.cs | 4 ++-- src/Microsoft.ML.TorchSharp/Utils/ImageUtils.cs | 4 ++-- test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj | 2 +- 8 files changed, 12 insertions(+), 14 deletions(-) diff --git a/eng/Versions.props b/eng/Versions.props index a4a30e30fe..79f2ec10a9 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -21,7 +21,7 @@ 4.5.0 1.5.0 4.5.0 - 4.5.3 + 4.5.5 4.3.0 4.3.0 6.0.0 @@ -56,12 +56,12 @@ 13.0.1 2.1.3 0.0.1 - 1.3.3 + 1.4.0 0.20.1 2 2.3.1 - 0.98.3 - 1.11.0.1 + 0.99.5 + 1.13.0.1 1.12.4 3.1.2 diff --git a/src/Microsoft.ML.TorchSharp/Microsoft.ML.TorchSharp.csproj b/src/Microsoft.ML.TorchSharp/Microsoft.ML.TorchSharp.csproj index 953b884f63..b2b89ce805 100644 --- a/src/Microsoft.ML.TorchSharp/Microsoft.ML.TorchSharp.csproj +++ b/src/Microsoft.ML.TorchSharp/Microsoft.ML.TorchSharp.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Microsoft.ML.TorchSharp/NasBert/Models/BaseModel.cs b/src/Microsoft.ML.TorchSharp/NasBert/Models/BaseModel.cs index dc13d70cc6..e2b80188e2 100644 --- a/src/Microsoft.ML.TorchSharp/NasBert/Models/BaseModel.cs +++ b/src/Microsoft.ML.TorchSharp/NasBert/Models/BaseModel.cs @@ -20,8 +20,6 @@ internal abstract class BaseModel : torch.nn.Module _predictionHead; public override TransformerEncoder GetEncoder() => Encoder; protected readonly TransformerEncoder Encoder; diff --git a/src/Microsoft.ML.TorchSharp/NasBert/Models/PredictionHead.cs b/src/Microsoft.ML.TorchSharp/NasBert/Models/PredictionHead.cs index 5b6092d779..a449984401 100644 --- a/src/Microsoft.ML.TorchSharp/NasBert/Models/PredictionHead.cs +++ b/src/Microsoft.ML.TorchSharp/NasBert/Models/PredictionHead.cs @@ -11,7 +11,7 @@ namespace Microsoft.ML.TorchSharp.NasBert.Models { - internal sealed class PredictionHead : BaseHead, torch.nn.IModule + internal sealed class PredictionHead : torch.nn.Module { [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "MSML_PrivateFieldName:Private field name not in: _camelCase format", Justification = "Has to match TorchSharp model.")] private readonly Sequential Classifier; @@ -34,7 +34,7 @@ public PredictionHead(int inputDim, int numClasses, double dropoutRate) } [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "MSML_GeneralName:This name should be PascalCased", Justification = "Need to match TorchSharp")] - public torch.Tensor forward(torch.Tensor features) + public override torch.Tensor forward(torch.Tensor features) { // TODO: try whitening-like techniques // take token (equiv. to [CLS]) diff --git a/src/Microsoft.ML.TorchSharp/NasBert/Models/TransformerEncoder.cs b/src/Microsoft.ML.TorchSharp/NasBert/Models/TransformerEncoder.cs index e9d8615085..256443fb82 100644 --- a/src/Microsoft.ML.TorchSharp/NasBert/Models/TransformerEncoder.cs +++ b/src/Microsoft.ML.TorchSharp/NasBert/Models/TransformerEncoder.cs @@ -16,7 +16,7 @@ namespace Microsoft.ML.TorchSharp.NasBert.Models { - internal sealed class TransformerEncoder : torch.nn.Module, torch.nn.IModule + internal sealed class TransformerEncoder : torch.nn.Module { #pragma warning disable MSML_PrivateFieldName // Private field name not in: _camelCase format Have to match TorchSharp model @@ -159,7 +159,7 @@ public TransformerEncoder( } [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "MSML_GeneralName:This name should be PascalCased", Justification = "Need to match TorchSharp.")] - public torch.Tensor forward( + public override torch.Tensor forward( torch.Tensor tokens, torch.Tensor segmentLabels = null, torch.Tensor positions = null) diff --git a/src/Microsoft.ML.TorchSharp/Utils/ImageUtils.cs b/src/Microsoft.ML.TorchSharp/Utils/ImageUtils.cs index 29d9e0c261..7d2e0d3850 100644 --- a/src/Microsoft.ML.TorchSharp/Utils/ImageUtils.cs +++ b/src/Microsoft.ML.TorchSharp/Utils/ImageUtils.cs @@ -50,7 +50,7 @@ public static void Postprocess(Tensor imgBatch, Tensor classification, Tensor re for (int i = 0; i < classification.shape[2]; ++i) { - var scores1 = torch.squeeze(classification[.., .., i]); + var scores1 = torch.squeeze(classification[.., .., i], null); var scoresOverThresh = scores1 > 0.05; if (scoresOverThresh.sum().ToSingle() == 0) { @@ -59,7 +59,7 @@ public static void Postprocess(Tensor imgBatch, Tensor classification, Tensor re } var scores = scores1[scoresOverThresh]; - var anchorBoxes1 = torch.squeeze(transformedAnchors); + var anchorBoxes1 = torch.squeeze(transformedAnchors, null); var anchorBoxes = anchorBoxes1[scoresOverThresh]; var anchorsNmsIdx = Nms(anchorBoxes, scores, overlapThreshold); var finalAnchorBoxesIndexesValue = torch.ones(anchorsNmsIdx.shape[0], dtype: ScalarType.Int64, device: imgBatch.device).multiply(i); diff --git a/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj b/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj index 9a13f71e63..0742d6e945 100644 --- a/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj +++ b/test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj @@ -74,7 +74,7 @@ - + From 8cf501c3c1c7481efb944abae40ef877e59b2a3f Mon Sep 17 00:00:00 2001 From: Michael Sharp Date: Fri, 28 Apr 2023 13:41:09 -0600 Subject: [PATCH 2/2] Path fix for codecov --- build/ci/job-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/ci/job-template.yml b/build/ci/job-template.yml index 6f87d45d3b..17965b4e70 100644 --- a/build/ci/job-template.yml +++ b/build/ci/job-template.yml @@ -122,7 +122,7 @@ jobs: - ${{ if eq(parameters.nightlyBuild, 'false') }}: - ${{ if eq(parameters.innerLoop, 'false') }}: - ${{ if and(eq(parameters.runSpecific, 'false'), eq(parameters.useVSTestTask, 'false')) }}: - - script: set PATH=%PATH%;%USERPROFILE%\.nuget\packages\libtorch-cpu-win-x64\1.11.0.1\runtimes\win-x64\native;%USERPROFILE%\.nuget\packages\torchsharp\0.96.7\runtimes\win-x64\native & ${{ parameters.buildScript }} /p:Build=false -configuration $(_configuration) /p:TargetArchitecture=${{ parameters.architecture }} /p:TestArchitectures=${{ parameters.architecture }} -test -integrationTest /p:Coverage=${{ parameters.codeCoverage }} $(testTargetFramework) + - script: set PATH=%PATH%;%USERPROFILE%\.nuget\packages\libtorch-cpu-win-x64\1.13.0.1\runtimes\win-x64\native;%USERPROFILE%\.nuget\packages\torchsharp\0.99.5\runtimes\win-x64\native & ${{ parameters.buildScript }} /p:Build=false -configuration $(_configuration) /p:TargetArchitecture=${{ parameters.architecture }} /p:TestArchitectures=${{ parameters.architecture }} -test -integrationTest /p:Coverage=${{ parameters.codeCoverage }} $(testTargetFramework) displayName: Run All Tests. - ${{ if and(eq(parameters.runSpecific, 'true'), eq(parameters.useVSTestTask, 'false')) }}: - script: ${{ parameters.buildScript }} /p:Build=false -configuration $(_configuration) /p:TargetArchitecture=${{ parameters.architecture }} /p:TestArchitectures=${{ parameters.architecture }} -test -integrationTest /p:TestRunnerAdditionalArguments='-trait$(spaceValue)Category=RunSpecificTest' /p:Coverage=${{ parameters.codeCoverage }} $(testTargetFramework)