Skip to content

Commit 715c423

Browse files
committed
Upgrade all projects from netstandard2.0/netcoreapp2.x to net8.0;net10.0 multi-target
All 7 projects now target net8.0 and net10.0, dropping netstandard2.0, netcoreapp2.1, and netcoreapp2.2. LangVersion bumped from 12.0 to latest. Target framework changes: - NumSharp.Core: netstandard2.0 → net8.0;net10.0 - NumSharp.Bitmap: netstandard2.0 → net8.0;net10.0 - NumSharp.UnitTest: net8.0 → net8.0;net10.0 - NumSharp.Benchmark: net8.0 → net8.0;net10.0 - NeuralNetwork.NumSharp: netstandard2.0 → net8.0;net10.0 - NumSharp.Examples: netcoreapp2.2 → net8.0;net10.0 - NumSharp.ConsumePackage: netcoreapp2.1 → net8.0;net10.0 Removed redundant NuGet packages: - System.Memory (4.5.5) — built into net8.0+ runtime - System.Runtime.CompilerServices.Unsafe (6.0.0) — built into net8.0+ runtime Removed from: NumSharp.Core, NumSharp.UnitTest, NumSharp.Benchmark Code fixes required by the upgrade: - SteppingExtension.cs, SteppingOverArray.cs: disambiguate array.Reverse() calls to array.AsEnumerable().Reverse() — in net8.0+, MemoryExtensions.Reverse(Span<T>) takes precedence over LINQ's Enumerable.Reverse<T>() for arrays, returning void instead of IEnumerable - ShallowWater.cs: fix stale 'using NumSharp.Core' → 'using NumSharp' Carried forward from dev (uncommitted): - UnmanagedStorage.Slicing.cs: broadcast slice fix — materialize broadcast data into contiguous memory with Clean() shape before slicing, preventing stride mismatch when broadcast strides [1,0] are applied to contiguous data layout [3,1] Test results: identical on both TFMs (1601 passed, 50 failed, 36 skipped), matching the dev branch baseline exactly. Zero regressions from the upgrade.
1 parent 142890d commit 715c423

11 files changed

Lines changed: 28 additions & 26 deletions

File tree

examples/NeuralNetwork.NumSharp/NeuralNetwork.NumSharp.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
55
<Platforms>AnyCPU;x64</Platforms>
66
<SignAssembly>true</SignAssembly>
77
<AssemblyOriginatorKeyFile>Open.snk</AssemblyOriginatorKeyFile>
88
<Configurations>Debug;Release</Configurations>
9-
<LangVersion>12.0</LangVersion>
9+
<LangVersion>latest</LangVersion>
1010
</PropertyGroup>
1111

1212
<ItemGroup>

src/NumSharp.Bitmap/NumSharp.Bitmap.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard2.0</TargetFramework>
3+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
44
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
55
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
66
<Authors>Eli Belash, Haiping Chen, Meinrad Recheis</Authors>
@@ -15,7 +15,7 @@
1515
<RepositoryType>git</RepositoryType>
1616
<PackageTags>Numpy, NumSharp, MachineLearning, Math, Scientific, Numeric, Mathlab, SciSharp</PackageTags>
1717
<PackageLicenseUrl></PackageLicenseUrl>
18-
<LangVersion>12.0</LangVersion>
18+
<LangVersion>latest</LangVersion>
1919
<PackageIconUrl>https://avatars3.githubusercontent.com/u/44989469?s=200&amp;v=4</PackageIconUrl>
2020
<PackageId>NumSharp.Bitmap</PackageId>
2121
<Product>NumSharp.Bitmap</Product>

src/NumSharp.Core/Backends/Unmanaged/UnmanagedStorage.Slicing.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,16 @@ private UnmanagedStorage GetViewInternal(params Slice[] slices)
9696
if (!_shape.IsRecursive && slices.All(s => Equals(Slice.All, s)))
9797
return Alias();
9898

99-
//handle broadcasted shape
99+
//handle broadcasted shape: materialize broadcast data into contiguous memory,
100+
//then slice the contiguous result. We must use a Clean() shape (not the broadcast
101+
//shape) so that strides match the contiguous data layout. Using _shape.Slice(slices)
102+
//would attach broadcast strides [1,0] to contiguous data [3,1], causing wrong offsets.
100103
if (_shape.IsBroadcasted)
101-
return Clone().Alias(_shape.Slice(slices));
104+
{
105+
var clonedData = CloneData();
106+
var cleanShape = _shape.Clean();
107+
return new UnmanagedStorage(clonedData, cleanShape).GetViewInternal(slices);
108+
}
102109

103110
return Alias(_shape.Slice(slices));
104111
}

src/NumSharp.Core/NumSharp.Core.csproj

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netstandard2.0</TargetFramework>
3+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
44
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
55
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
66
<Authors>Eli Belash, Haiping Chen, Meinrad Recheis, Deepak Kumar Battini</Authors>
@@ -15,7 +15,7 @@
1515
<RepositoryType>git</RepositoryType>
1616
<PackageTags>Numpy, NumSharp, MachineLearning, Math, Scientific, Numeric, Mathlab, SciSharp</PackageTags>
1717
<PackageLicenseUrl></PackageLicenseUrl>
18-
<LangVersion>12.0</LangVersion>
18+
<LangVersion>latest</LangVersion>
1919
<PackageIconUrl>https://avatars3.githubusercontent.com/u/44989469?s=200&amp;v=4</PackageIconUrl>
2020
<PackageId>NumSharp</PackageId>
2121
<Product>NumSharp</Product>
@@ -79,10 +79,7 @@
7979
<None Include="Operations\Elementwise\Templates\Default.Op.Equals.template.cs" />
8080
</ItemGroup>
8181

82-
<ItemGroup>
83-
<PackageReference Include="System.Memory" Version="4.5.5" />
84-
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
85-
</ItemGroup>
82+
<!-- System.Memory and System.Runtime.CompilerServices.Unsafe are built into net8.0+ -->
8683

8784
<ItemGroup>
8885
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />

src/NumSharp.Core/Utilities/SteppingExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public static T[] Step<T>(this T[] array, int step)
1616
if (step == 1)
1717
return array;
1818
if (step == -1)
19-
return array.Reverse().ToArray();
20-
var stepped_enumerable = Step(step < 0 ? array.Reverse().GetEnumerator() : array.OfType<T>().GetEnumerator(), Math.Abs(step));
19+
return array.AsEnumerable().Reverse().ToArray();
20+
var stepped_enumerable = Step(step < 0 ? array.AsEnumerable().Reverse().GetEnumerator() : array.OfType<T>().GetEnumerator(), Math.Abs(step));
2121
return stepped_enumerable.ToArray();
2222
}
2323

test/NumSharp.Benchmark/NumSharp.Benchmark.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
6-
<LangVersion>12.0</LangVersion>
5+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
6+
<LangVersion>latest</LangVersion>
77
<Platforms>AnyCPU;x64</Platforms>
88
<ApplicationIcon />
99
<Win32Resource />
@@ -18,8 +18,7 @@
1818
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
1919
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
2020
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.2" />
21-
<PackageReference Include="System.Memory" Version="4.5.5" />
22-
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
21+
<!-- System.Memory and System.Runtime.CompilerServices.Unsafe are built into net8.0+ -->
2322
</ItemGroup>
2423

2524
<ItemGroup>

test/NumSharp.ConsumePackage/NumSharp.ConsumePackage.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
66
</PropertyGroup>
77

88
<PropertyGroup>

test/NumSharp.Examples/NumSharp.Examples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
66
</PropertyGroup>
77

88
<ItemGroup>

test/NumSharp.Examples/ShallowWater.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using NumSharp.Core;
2+
using NumSharp;
33
using System.Collections;
44
using System.Collections.Generic;
55

test/NumSharp.UnitTest/NumSharp.UnitTest.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7-
<LangVersion>12.0</LangVersion>
7+
<LangVersion>latest</LangVersion>
88
<Platforms>AnyCPU</Platforms>
99
<AssemblyOriginatorKeyFile>Open.snk</AssemblyOriginatorKeyFile>
1010
<Configurations>Debug;Release;Publish</Configurations>
@@ -37,8 +37,7 @@
3737
<PackageReference Include="FluentAssertions" Version="5.10.3" />
3838
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
3939
<PackageReference Include="OpenCover" Version="4.7.922" />
40-
<PackageReference Include="System.Memory" Version="4.5.5" />
41-
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
40+
<!-- System.Memory and System.Runtime.CompilerServices.Unsafe are built into net8.0+ -->
4241
</ItemGroup>
4342

4443
<ItemGroup>

0 commit comments

Comments
 (0)