Skip to content

Commit f7a3b61

Browse files
[release/3.0] Torch sharp version updates and test fixes (#6958)
* torch sharp version updates and test fixes * removed extra test file * job templat updated for test coverage --------- Co-authored-by: Michael Sharp <[email protected]>
1 parent ec498d8 commit f7a3b61

File tree

16 files changed

+33
-34
lines changed

16 files changed

+33
-34
lines changed

build/ci/job-template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
- ${{ if eq(parameters.nightlyBuild, 'false') }}:
122122
- ${{ if eq(parameters.innerLoop, 'false') }}:
123123
- ${{ if and(eq(parameters.runSpecific, 'false'), eq(parameters.useVSTestTask, 'false')) }}:
124-
- 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)
124+
- script: set PATH=%PATH%;%USERPROFILE%\.nuget\packages\libtorch-cpu-win-x64\2.1.0.1\runtimes\win-x64\native;%USERPROFILE%\.nuget\packages\torchsharp\0.101.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)
125125
displayName: Run All Tests.
126126
- ${{ if and(eq(parameters.runSpecific, 'true'), eq(parameters.useVSTestTask, 'false')) }}:
127127
- 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)

eng/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
<TensorflowDotNETVersion>0.20.1</TensorflowDotNETVersion>
6363
<TensorFlowMajorVersion>2</TensorFlowMajorVersion>
6464
<TensorFlowVersion>2.3.1</TensorFlowVersion>
65-
<TorchSharpVersion>0.99.5</TorchSharpVersion>
66-
<LibTorchVersion>1.13.0.1</LibTorchVersion>
65+
<TorchSharpVersion>0.101.5</TorchSharpVersion>
66+
<LibTorchVersion>2.1.0.1</LibTorchVersion>
6767
<!-- Build/infrastructure Dependencies -->
6868
<CodecovVersion>1.12.4</CodecovVersion>
6969
<CoverletCollectorVersion>3.1.2</CoverletCollectorVersion>

src/Microsoft.ML.TorchSharp/AutoFormerV2/ObjectDetectionTrainer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public Trainer(ObjectDetectionTrainer parent, IChannel ch, IDataView input)
225225
Device = TorchUtils.InitializeDevice(Parent.Host);
226226

227227
// Move to GPU if we are running there
228-
if (Device == CUDA)
228+
if (Device.type == DeviceType.CUDA)
229229
Model.cuda();
230230

231231
// Get the parameters that need optimization and set up the optimizer
@@ -531,7 +531,7 @@ internal ObjectDetectionTransformer(IHostEnvironment env, ObjectDetectionTrainer
531531
Model = model;
532532
Model.eval();
533533

534-
if (Device == CUDA)
534+
if (Device.type == DeviceType.CUDA)
535535
Model.cuda();
536536
}
537537

src/Microsoft.ML.TorchSharp/Roberta/QATrainer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public Trainer(QATrainer parent, IChannel ch, IDataView input)
207207
Device = TorchUtils.InitializeDevice(Parent.Host);
208208

209209
// Move to GPU if we are running there
210-
if (Device == CUDA)
210+
if (Device.type == DeviceType.CUDA)
211211
Model.cuda();
212212

213213
Tokenizer = TokenizerExtensions.GetInstance(ch);
@@ -574,7 +574,7 @@ internal QATransformer(IHostEnvironment env, QATrainer.Options options, RobertaM
574574
Model = model;
575575
Model.eval();
576576

577-
if (Device == CUDA)
577+
if (Device.type == DeviceType.CUDA)
578578
Model.cuda();
579579
using (var ch = Host.Start("Initialize Tokenizer"))
580580
Tokenizer = TokenizerExtensions.GetInstance(ch);

src/Microsoft.ML.TorchSharp/TorchSharpBaseTrainer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public TrainerBase(TorchSharpBaseTrainer<TLabelCol, TTargetsCol> parent, IChanne
158158
Device = TorchUtils.InitializeDevice(Parent.Host);
159159

160160
// Move to GPU if we are running there
161-
if (Device == CUDA)
161+
if (Device.type == DeviceType.CUDA)
162162
Model.cuda();
163163
}
164164

@@ -395,7 +395,7 @@ internal TorchSharpBaseTransformer(IHostEnvironment env, TorchSharpBaseTrainer.O
395395

396396
Model = model;
397397

398-
if (Device == CUDA)
398+
if (Device.type == DeviceType.CUDA)
399399
Model.cuda();
400400
}
401401

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using Xunit;
6+
7+
[assembly: CollectionBehavior(DisableTestParallelization = true)]

test/Microsoft.ML.TensorFlow.Tests/TensorflowTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
using static Microsoft.ML.DataOperationsCatalog;
2424
using InMemoryImage = Microsoft.ML.Tests.ImageTests.InMemoryImage;
2525

26-
namespace Microsoft.ML.Scenarios
26+
namespace Microsoft.ML.TensorFlow.Scenarios
2727
{
28-
2928
internal sealed class TensorFlowScenariosTestsFixture : IDisposable
3029
{
3130
public static string tempFolder;
@@ -57,7 +56,6 @@ public void Dispose()
5756
}
5857
}
5958

60-
[Collection("NoParallelization")]
6159
public sealed class TensorFlowScenariosTests : BaseTestClass, IClassFixture<TensorFlowScenariosTestsFixture>
6260
{
6361
private readonly string _fullImagesetFolderPath;

test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,11 @@
5656
<PackageReference Include="System.Data.SQLite.Core" Version="$(SystemDataSQLiteCoreVersion)" />
5757
</ItemGroup>
5858

59-
<ItemGroup>
60-
<Content Include="Data\**">
61-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
62-
</Content>
63-
</ItemGroup>
64-
6559
<ItemGroup>
6660
<EmbeddedResource Include="ExpressionLanguageTests\TestData\ExprBindExInput.txt" />
6761
<EmbeddedResource Include="ExpressionLanguageTests\TestData\ExprBindInput.txt" />
6862
<EmbeddedResource Include="ExpressionLanguageTests\TestData\ExprCodeGenInput.txt" />
6963
<EmbeddedResource Include="ExpressionLanguageTests\TestData\ExprEvalInput.txt" />
7064
<EmbeddedResource Include="ExpressionLanguageTests\TestData\ExprParseInput.txt" />
7165
</ItemGroup>
72-
73-
<ItemGroup>
74-
<Folder Include="Properties\" />
75-
</ItemGroup>
7666
</Project>

test/Microsoft.ML.Tests/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@
33
// See the LICENSE file in the project root for more information.
44

55
using Xunit;
6-
7-
// TODO: [TEST_STABILITY] disable test parallelization for this assembly as running test in parallel sometimes cause test host process to crash
8-
[assembly: CollectionBehavior(DisableTestParallelization = true)]

test/Microsoft.ML.TorchSharp.Tests/Microsoft.ML.TorchSharp.Tests.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
<AssemblyName>Microsoft.ML.TorchSharp.Tests</AssemblyName>
44
<StrongNameKeyId>Test</StrongNameKeyId>
55

6+
<!-- Remove once we have resolved the TorchSharp issue. -->
7+
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
8+
69
</PropertyGroup>
710

811
<!-- Import the test signing certificate -->
@@ -23,7 +26,7 @@
2326

2427
<ItemGroup Condition="'$(TargetArchitecture)' == 'x64'">
2528
<PackageReference Include="libtorch-cpu-win-x64" Version="$(LibTorchVersion)" Condition="$([MSBuild]::IsOSPlatform('Windows')) AND '$(TargetArchitecture)' == 'x64'" />
26-
<!-- <PackageReference Include="TorchSharp-cuda-windows" Version="0.99.5" Condition="$([MSBuild]::IsOSPlatform('Windows'))" /> -->
29+
<!-- <PackageReference Include="TorchSharp-cuda-windows" Version="$(TorchSharpVersion)" Condition="$([MSBuild]::IsOSPlatform('Windows'))" /> -->
2730
<PackageReference Include="libtorch-cpu-linux-x64" Version="$(LibTorchVersion)" Condition="$([MSBuild]::IsOSPlatform('Linux')) AND '$(TargetArchitecture)' == 'x64'" />
2831
<PackageReference Include="libtorch-cpu-osx-x64" Version="$(LibTorchVersion)" Condition="$([MSBuild]::IsOSPlatform('OSX')) AND '$(TargetArchitecture)' == 'x64'" />
2932

0 commit comments

Comments
 (0)