зеркало из https://github.com/dotnet/infer.git
Update to .NET 6 (#391)
* Disable warning for usage of WebClient in Evaluator * vmImage: windows-latest * Adjust to new DeflateStream behaviour in .NET 6
This commit is contained in:
Родитель
638771287d
Коммит
5cedd14dc0
18
BUILDING.md
18
BUILDING.md
|
@ -1,23 +1,23 @@
|
|||
# Building Infer.NET from its source code
|
||||
|
||||
- [Building with Visual Studio 2019](#building-with-visual-studio-2019)
|
||||
- [Building with Visual Studio](#building-with-visual-studio)
|
||||
- [Building from the command line](#building-from-the-command-line)
|
||||
|
||||
To build from source, you must first clone the repository.
|
||||
Next decide whether you want to use a code editor like Visual Studio (recommended) or the command line.
|
||||
When building, you must select a configuration.
|
||||
All of the Infer.NET libraries target .NET Standard 2.0. Projects that produce executables (including test projects) mostly target .NET Framework 4.6.2, .NET Core 3.1, or both depending on build configuration:
|
||||
All of the Infer.NET libraries target .NET Standard 2.0. Projects that produce executables (including test projects) mostly target .NET Framework 4.6.2, .NET 6, or both depending on build configuration:
|
||||
|
||||
| Configurations | Targeted Frameworks |
|
||||
|:---|---:|
|
||||
| Debug, Release | both .NET Framework 4.6.2 and .NET Core 3.1 |
|
||||
| Debug, Release | both .NET Framework 4.6.2 and .NET 6 |
|
||||
| DebugFull, ReleaseFull | .NET Framework 4.6.2 only |
|
||||
| DebugCore, ReleaseCore | .NET Core 3.1 only |
|
||||
| DebugCore, ReleaseCore | .NET 6 only |
|
||||
|
||||
|
||||
## Building with Visual Studio 2019
|
||||
## Building with Visual Studio
|
||||
|
||||
1. If you don't have Visual Studio 2019, you can install the free [Visual Studio 2019 Community](https://visualstudio.microsoft.com/vs/community/).
|
||||
1. If you don't have Visual Studio, you can install the free [Visual Studio Community Edition](https://visualstudio.microsoft.com/vs/community/).
|
||||
1. Start Visual Studio.
|
||||
1. Select `File -> Open -> Project/Solution` and open the `Infer.sln` solution file located in your cloned repository.
|
||||
1. Select a build configuration using `Build -> Configuration Manager...`. After switching between configurations that change the targeted frameworks, Visual Studio currently requires you to close and re-open the solution file using `File -> Close Solution` and `File -> Open`.
|
||||
|
@ -37,12 +37,12 @@ All of the Infer.NET libraries target .NET Standard 2.0. Projects that produ
|
|||
|
||||
## Building from the command line
|
||||
|
||||
The core components of Infer.NET run on .NET Core 3.1. Some optional code, such as the [Examples Browser](https://dotnet.github.io/infer/userguide/The%20examples%20browser.html), use [Windows Forms](https://docs.microsoft.com/en-us/dotnet/framework/winforms/) and therefore require .NET framework or Mono.
|
||||
The core components of Infer.NET run on .NET Core. Some optional code, such as the [Examples Browser](https://dotnet.github.io/infer/userguide/The%20examples%20browser.html), use [Windows Forms](https://docs.microsoft.com/en-us/dotnet/framework/winforms/) and therefore require .NET framework or Mono.
|
||||
Some samples, such as the [Monty Hall problem](https://dotnet.github.io/infer/userguide/Monty%20Hall%20problem.html), use [WPF](https://docs.microsoft.com/en-us/visualstudio/designers/introduction-to-wpf) and therefore require Windows.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
* **[.NET Core 3.1 SDK](https://www.microsoft.com/net/download/)** to build and run .NET Standard and .NET Core projects.
|
||||
* **[.NET SDK](https://www.microsoft.com/net/download/)** to build and run .NET Standard and .NET Core projects.
|
||||
|
||||
* (Optional) On Windows, the **[.NET framework developer pack](https://www.microsoft.com/net/download)**. On other platforms, **[Mono](https://www.mono-project.com/download/stable/)** (version 5.0 and higher) and the **[NuGet](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools)** package manager.
|
||||
|
||||
|
@ -76,7 +76,7 @@ There are three test assemblies in the solution:
|
|||
- **TestPublic.dll** in the folder `test/TestPublic`.
|
||||
- **Microsoft.ML.Probabilistic.Learners.Tests.dll** in the folder `test/Learners/LearnersTests`.
|
||||
|
||||
Depending on the build configuration and targeted framework, the assemblies will be located in the `bin/Debug<Core|Full>/<net5.0|net462>` or `bin/Release<Core|Full>/<net5.0|net462>` subdirectories
|
||||
Depending on the build configuration and targeted framework, the assemblies will be located in the `bin/Debug<Core|Full>/<net6.0|net462>` or `bin/Release<Core|Full>/<net6.0|net462>` subdirectories
|
||||
of the test project.
|
||||
|
||||
Runner executes tests in parallel by default. However, some test category must be run
|
||||
|
|
|
@ -14,6 +14,6 @@ steps:
|
|||
inputs:
|
||||
targetType: 'inline'
|
||||
script: dotnet Evaluator.dll InferNetRunsOnly.xml
|
||||
workingDirectory: ${{ format('src/Learners/Runners/Evaluator/bin/{0}/net5.0', parameters.Configuration) }}
|
||||
workingDirectory: ${{ format('src/Learners/Runners/Evaluator/bin/{0}/net6.0', parameters.Configuration) }}
|
||||
displayName: Running Evaluator
|
||||
continueOnError: true
|
|
@ -19,7 +19,7 @@ steps:
|
|||
- task: UseDotNet@2
|
||||
inputs:
|
||||
packageType: 'sdk'
|
||||
version: '5.x'
|
||||
version: '6.x'
|
||||
|
||||
- script: |
|
||||
dotnet build /p:DisableImplicitNuGetFallbackFolder=true --configuration $(BuildConfiguration)Core Infer.sln
|
||||
|
|
|
@ -13,7 +13,7 @@ resources:
|
|||
trigger: none # disable CI build
|
||||
|
||||
pool:
|
||||
vmImage: 'windows-2019'
|
||||
vmImage: 'windows-latest'
|
||||
|
||||
# Cannot use matrix strategy to create jobs for different platforms,
|
||||
# since then the platform is given as a variable which cannot be passed as a parameter to a template,
|
||||
|
|
|
@ -14,7 +14,7 @@ steps:
|
|||
- task: UseDotNet@2
|
||||
inputs:
|
||||
packageType: 'sdk'
|
||||
version: '5.x'
|
||||
version: '6.x'
|
||||
|
||||
- script: |
|
||||
echo Checking $(Build.Repository.LocalPath)\src\Runtime\Factors\FactorDocs.xml...
|
||||
|
|
|
@ -17,7 +17,7 @@ jobs:
|
|||
- job: Win64 # Hosted Windows agent, VS 2017, testing on x64
|
||||
timeoutInMinutes: 120
|
||||
pool:
|
||||
vmImage: windows-2019
|
||||
vmImage: windows-latest
|
||||
steps:
|
||||
- task: NuGetToolInstaller@1
|
||||
inputs:
|
||||
|
@ -41,7 +41,7 @@ jobs:
|
|||
- job: Win32 # Hosted Windows agent, VS 2017, testing on x86
|
||||
timeoutInMinutes: 120
|
||||
pool:
|
||||
vmImage: windows-2019
|
||||
vmImage: windows-latest
|
||||
steps:
|
||||
- task: NuGetToolInstaller@1
|
||||
inputs:
|
||||
|
|
|
@ -11,7 +11,7 @@ steps:
|
|||
- task: UseDotNet@2
|
||||
inputs:
|
||||
packageType: 'sdk'
|
||||
version: '5.x'
|
||||
version: '6.x'
|
||||
|
||||
- script: |
|
||||
dotnet build /p:DisableImplicitNuGetFallbackFolder=true --configuration $(buildConfiguration)Core Infer.sln
|
||||
|
|
|
@ -22,7 +22,7 @@ jobs:
|
|||
- task: UseDotNet@2
|
||||
inputs:
|
||||
packageType: 'sdk'
|
||||
version: '5.x'
|
||||
version: '6.x'
|
||||
|
||||
- script: |
|
||||
dotnet build --configuration $(BuildConfiguration)Core Infer.sln
|
||||
|
@ -37,7 +37,7 @@ jobs:
|
|||
- task: UseDotNet@2
|
||||
inputs:
|
||||
packageType: 'sdk'
|
||||
version: '5.x'
|
||||
version: '6.x'
|
||||
|
||||
- script: |
|
||||
dotnet build --configuration $(BuildConfiguration)Core Infer.sln
|
||||
|
@ -149,10 +149,10 @@ jobs:
|
|||
condition: in(variables.SignType, 'real', 'test')
|
||||
|
||||
- task: UseDotNet@2
|
||||
displayName: Get dotnet 5.x
|
||||
displayName: Get dotnet 6.x
|
||||
inputs:
|
||||
packageType: 'sdk'
|
||||
version: '5.x'
|
||||
version: '6.x'
|
||||
|
||||
- task: DotNetCoreCLI@2
|
||||
displayName: Restore Infer.sln to enable packaging.
|
||||
|
|
|
@ -41,7 +41,7 @@ if (!(Test-Path $projPath)) {
|
|||
& "$dotnetExe" build "$projPath" /p:Configuration=Release
|
||||
|
||||
Write-Host "Run PrepareSource for InferNet_Copy_Temp folder"
|
||||
$prepareSourcePath = [IO.Path]::GetFullPath((join-path $sourceDirectory 'src/Tools/PrepareSource/bin/Release/net5.0/Microsoft.ML.Probabilistic.Tools.PrepareSource.dll'))
|
||||
$prepareSourcePath = [IO.Path]::GetFullPath((join-path $sourceDirectory 'src/Tools/PrepareSource/bin/Release/net6.0/Microsoft.ML.Probabilistic.Tools.PrepareSource.dll'))
|
||||
& "$dotnetExe" "$prepareSourcePath" "$destinationDirectory"
|
||||
|
||||
Write-Host "Install nuget package docfx.console"
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0-windows</TargetFramework>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0-windows;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0-windows;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0-windows</TargetFramework>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0-windows;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0-windows;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -20,18 +20,18 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup Condition="'$(IsWindows)'=='true'">
|
||||
<TargetFramework>net5.0-windows</TargetFramework>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(IsWindows)'!='true'">
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup Condition="'$(IsWindows)'=='true'">
|
||||
<TargetFrameworks>net5.0-windows;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0-windows;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(IsWindows)'!='true'">
|
||||
<TargetFramework>net5.0;net462</TargetFramework>
|
||||
<TargetFramework>net6.0;net462</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -19,19 +19,19 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
<!-- No need to generate code twice -->
|
||||
<IgnorePostBuildNetCore>true</IgnorePostBuildNetCore>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'net5.0'">
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0'">
|
||||
<RunPostBuildNetCore Condition="$(IgnorePostBuildNetCore) != 'true'">true</RunPostBuildNetCore>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
@ -19,19 +19,19 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
<!-- No need to generate code twice -->
|
||||
<IgnorePostBuildNetCore>true</IgnorePostBuildNetCore>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'net5.0'">
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0'">
|
||||
<RunPostBuildNetCore Condition="$(IgnorePostBuildNetCore) != 'true'">true</RunPostBuildNetCore>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
<DefineConstants>TRACE</DefineConstants>
|
||||
<RootNamespace>Microsoft.ML.Probabilistic.Learners.Runners</RootNamespace>
|
||||
<Configurations>Debug;Release;DebugFull;DebugCore;ReleaseFull;ReleaseCore</Configurations>
|
||||
<!-- Migrate WebClient to HttpClient usage. -->
|
||||
<NoWarn>SYSLIB0014;$(NoWarn)</NoWarn>
|
||||
</PropertyGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(Configuration)'=='DebugFull' OR '$(Configuration)'=='ReleaseFull'">
|
||||
|
@ -18,12 +20,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace Microsoft.ML.Probabilistic.Serialization
|
|||
MatType dataType = (MatType) ReadInt();
|
||||
int numBytes = ReadInt();
|
||||
byte[] bytes = new byte[numBytes];
|
||||
if (reader.Read(bytes, 0, numBytes) < numBytes) throw new EndOfStreamException();
|
||||
if (Read(reader, bytes, 0, numBytes) < numBytes) throw new EndOfStreamException();
|
||||
if (dataType == MatType.COMPRESSED)
|
||||
{
|
||||
// MAT file compression uses Zlib format, which is the same as Deflate but with an extra header and footer.
|
||||
|
@ -573,7 +573,7 @@ namespace Microsoft.ML.Probabilistic.Serialization
|
|||
{
|
||||
string header = ReadString(124);
|
||||
byte[] bytes = new byte[4];
|
||||
if (reader.Read(bytes, 0, 4) < 4) throw new EndOfStreamException();
|
||||
if (Read(reader, bytes, 0, 4) < 4) throw new EndOfStreamException();
|
||||
if ((bytes[0] != 0x00) || (bytes[1] != 0x01) || (bytes[2] != 'I') || (bytes[3] != 'M'))
|
||||
throw new NotImplementedException("Unrecognized header");
|
||||
return header.TrimEnd(' ');
|
||||
|
@ -586,7 +586,7 @@ namespace Microsoft.ML.Probabilistic.Serialization
|
|||
protected int ReadInt()
|
||||
{
|
||||
byte[] bytes = new byte[4];
|
||||
if (reader.Read(bytes, 0, 4) < 4) throw new EndOfStreamException();
|
||||
if (Read(reader, bytes, 0, 4) < 4) throw new EndOfStreamException();
|
||||
return BitConverter.ToInt32(bytes, 0);
|
||||
}
|
||||
|
||||
|
@ -597,7 +597,7 @@ namespace Microsoft.ML.Probabilistic.Serialization
|
|||
protected uint ReadUInt()
|
||||
{
|
||||
byte[] bytes = new byte[4];
|
||||
if (reader.Read(bytes, 0, 4) < 4) throw new EndOfStreamException();
|
||||
if (Read(reader, bytes, 0, 4) < 4) throw new EndOfStreamException();
|
||||
return BitConverter.ToUInt32(bytes, 0);
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,7 @@ namespace Microsoft.ML.Probabilistic.Serialization
|
|||
protected short ReadInt16()
|
||||
{
|
||||
byte[] bytes = new byte[2];
|
||||
if (reader.Read(bytes, 0, 2) < 2) throw new EndOfStreamException();
|
||||
if (Read(reader, bytes, 0, 2) < 2) throw new EndOfStreamException();
|
||||
return BitConverter.ToInt16(bytes, 0);
|
||||
}
|
||||
|
||||
|
@ -619,7 +619,7 @@ namespace Microsoft.ML.Probabilistic.Serialization
|
|||
protected ushort ReadUInt16()
|
||||
{
|
||||
byte[] bytes = new byte[2];
|
||||
if (reader.Read(bytes, 0, 2) < 2) throw new EndOfStreamException();
|
||||
if (Read(reader, bytes, 0, 2) < 2) throw new EndOfStreamException();
|
||||
return BitConverter.ToUInt16(bytes, 0);
|
||||
}
|
||||
|
||||
|
@ -630,7 +630,7 @@ namespace Microsoft.ML.Probabilistic.Serialization
|
|||
protected long ReadInt64()
|
||||
{
|
||||
byte[] bytes = new byte[8];
|
||||
if (reader.Read(bytes, 0, 8) < 8) throw new EndOfStreamException();
|
||||
if (Read(reader, bytes, 0, 8) < 8) throw new EndOfStreamException();
|
||||
return BitConverter.ToInt64(bytes, 0);
|
||||
}
|
||||
|
||||
|
@ -641,7 +641,7 @@ namespace Microsoft.ML.Probabilistic.Serialization
|
|||
protected ulong ReadUInt64()
|
||||
{
|
||||
byte[] bytes = new byte[8];
|
||||
if (reader.Read(bytes, 0, 8) < 8) throw new EndOfStreamException();
|
||||
if (Read(reader, bytes, 0, 8) < 8) throw new EndOfStreamException();
|
||||
return BitConverter.ToUInt64(bytes, 0);
|
||||
}
|
||||
|
||||
|
@ -652,7 +652,7 @@ namespace Microsoft.ML.Probabilistic.Serialization
|
|||
protected float ReadSingle()
|
||||
{
|
||||
byte[] bytes = new byte[4];
|
||||
if (reader.Read(bytes, 0, 4) < 4) throw new EndOfStreamException();
|
||||
if (Read(reader, bytes, 0, 4) < 4) throw new EndOfStreamException();
|
||||
return BitConverter.ToSingle(bytes, 0);
|
||||
}
|
||||
|
||||
|
@ -663,7 +663,7 @@ namespace Microsoft.ML.Probabilistic.Serialization
|
|||
protected double ReadDouble()
|
||||
{
|
||||
byte[] bytes = new byte[8];
|
||||
if (reader.Read(bytes, 0, 8) < 8) throw new EndOfStreamException();
|
||||
if (Read(reader, bytes, 0, 8) < 8) throw new EndOfStreamException();
|
||||
return BitConverter.ToDouble(bytes, 0);
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,7 @@ namespace Microsoft.ML.Probabilistic.Serialization
|
|||
protected string ReadString(int length)
|
||||
{
|
||||
byte[] bytes = new byte[length];
|
||||
if (reader.Read(bytes, 0, length) < length) throw new EndOfStreamException();
|
||||
if (Read(reader, bytes, 0, length) < length) throw new EndOfStreamException();
|
||||
return ParseString(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
|
@ -766,5 +766,18 @@ namespace Microsoft.ML.Probabilistic.Serialization
|
|||
if (row != matrix.GetLength(0)) throw new InferRuntimeException("Expected " + matrix.GetLength(0) + " rows, but were " + row + " rows.");
|
||||
return matrix;
|
||||
}
|
||||
|
||||
protected int Read(Stream stream, byte[] bytes, int offset, int count)
|
||||
{
|
||||
// https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/partial-byte-reads-in-streams
|
||||
var totalRead = 0;
|
||||
while (totalRead < count)
|
||||
{
|
||||
var byteRead = stream.Read(bytes, offset + totalRead, count - totalRead);
|
||||
if (byteRead == 0) break;
|
||||
totalRead += byteRead;
|
||||
}
|
||||
return totalRead;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>Microsoft.ML.Probabilistic.Tools.BuildFactorDoc</RootNamespace>
|
||||
<AssemblyName>Microsoft.ML.Probabilistic.Tools.BuildFactorDoc</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<AssemblyName>Microsoft.ML.Probabilistic.Tools.PrepareSource</AssemblyName>
|
||||
<RootNamespace>Microsoft.ML.Probabilistic.Tools.PrepareSource</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
<AddSyntheticProjectReferencesForSolutionDependencies>false</AddSyntheticProjectReferencesForSolutionDependencies>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -20,12 +20,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -18,14 +18,16 @@ namespace Microsoft.ML.Probabilistic.Tests.Core
|
|||
Dictionary<string, object> dict = MatlabReader.Read(Path.Combine(TestUtils.DataFolderPath, "IRT2PL_10_250.mat"));
|
||||
Assert.Equal(5, dict.Count);
|
||||
Matrix m = (Matrix)dict["Y"];
|
||||
Assert.True(m.Rows == 250);
|
||||
Assert.True(m.Cols == 10);
|
||||
Assert.True(m[0, 1] == 0.0);
|
||||
Assert.True(m[1, 0] == 1.0);
|
||||
Assert.Equal(250, m.Rows);
|
||||
Assert.Equal(10, m.Cols);
|
||||
Assert.Equal(0.0, m[0, 1]);
|
||||
Assert.Equal(1.0, m[1, 0]);
|
||||
m = (Matrix)dict["difficulty"];
|
||||
Assert.True(m.Rows == 10);
|
||||
Assert.True(m.Cols == 1);
|
||||
Assert.Equal(10, m.Rows);
|
||||
Assert.Equal(1, m.Cols);
|
||||
Assert.True(MMath.AbsDiff(m[1], 0.7773) < 2e-4);
|
||||
m = (Matrix)dict["p"];
|
||||
Assert.Equal(0.68150001272133187, m[0, 7]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
</When>
|
||||
<When Condition="'$(Configuration)'=='DebugCore' OR '$(Configuration)'=='ReleaseCore'">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net5.0;net462</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net462</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
|
|
@ -15,7 +15,7 @@ then
|
|||
configuration=Release
|
||||
fi
|
||||
|
||||
compath=/bin/${configuration}/net5.0/
|
||||
compath=/bin/${configuration}/net6.0/
|
||||
|
||||
# filter for parallel test run
|
||||
#parallel_filter='-notrait Platform=x86 -notrait Category=OpenBug -notrait Category=BadTest -notrait Category=CompilerOptionsTest -notrait Category=CsoftModel -notrait Category=ModifiesGlobals -notrait Category=DistributedTest -notrait Category=Performance'
|
||||
|
|
Загрузка…
Ссылка в новой задаче