High Performance Computation for N-D Tensors in .NET, similar API to NumPy.
See the codeNumPy for .NET
NumSharp is a native .NET array library with a NumPy-shaped API: NDArray,
broadcasting, slicing views, dtype-aware np.* functions, unmanaged storage,
and runtime-generated kernels with cpu-acceleration for performance-sensitive numerical code.
The compatibility target is NumPy 2.x. When NumSharp behavior and NumPy behavior differ, NumPy is treated as the source of truth and aligns.
NumSharp lets C# and F# code use a NumPy-like programming model without embedding CPython. It is intended for scientific computing, numerical utilities, machine learning infrastructure, and projects that want NumPy-style array operations in ordinary .NET code.
NumSharp's edge is utilizing the power of C#'s dynamic IL generation and fused kernels translating to assembly generated with JIT optimizations and SIMD CPU acceleration. This edge leads the design of NumSharp's backend and by that to higher performance mark than NumPy on many functions as can be seen in Performance.
NumSharp focuses on:
Click here to see code Getting Started
NDArray - N-dimensional arrays with shape, strides, offsets,
slicing, and view semantics. Start with NDArray fundamentals
and NDArray.np.* API surface - Creation, manipulation, math, reductions,
comparisons, logic, random sampling, I/O, and formatting. Browse the
API reference.np.evaluate expressions for reducing intermediate allocations. See
NDIter.NumSharp's Coverage & Support Dashboard is presenting the full implementation roadmap to complete 100% NumPy porting with an explorer allowing you to quickly check your favorite functions!
NumSharp benchmarks are published as tracked release snapshots, not ad hoc numbers. The latest checked-in snapshot compares NumSharp with NumPy 2.4.2 across the operation matrix, supported dtypes, three size tiers, and the NDIter, layout, operand, cast, and fusion subsystems.
Install the core package:
dotnet add package NumSharp
Use familiar NumPy-style calls:
using NumSharp;
var a = np.arange(12).reshape(3, 4);
var window = a[":, 1::2"];
Console.WriteLine(window);
Console.WriteLine(np.sum(window, axis: 0));
For Python readers, the intended shape is deliberately close:
import numpy as np
a = np.arange(12).reshape(3, 4)
window = a[:, 1::2]
print(window.sum(axis=0))
Build:
dotnet build test/NumSharp.Tests/NumSharp.Tests.csproj --configuration Release
Run the normal CI-style unit test filter:
dotnet test test/NumSharp.Tests/NumSharp.Tests.csproj \
--configuration Release \
--no-build \
--framework net8.0 \
--filter "TestCategory!=OpenBugs&TestCategory!=HighMemory"
CI runs on Windows, Linux, and macOS for net8.0 and net10.0.
If you need to call the full CPython NumPy runtime from .NET, including Python extension modules NumSharp does not implement, see Numpy.NET. NumSharp is a native .NET implementation with a NumPy-shaped API; Numpy.NET bridges into Python.
NumSharp is released under the Apache License 2.0.
NumSharp is part of the SciSharp ecosystem for machine learning, mathematics, science, and engineering on .NET.
Overall
Maintained
Code review
NuGet
Latest release
Releases this year
2,130 followers · starred Jan 2019
143 followers · starred Apr 2019
503 followers · starred Aug 2019
73 followers · starred Mar 2023
High Performance Computation for N-D Tensors in .NET, similar API to NumPy.
See the codeNumPy for .NET
NumSharp is a native .NET array library with a NumPy-shaped API: NDArray,
broadcasting, slicing views, dtype-aware np.* functions, unmanaged storage,
and runtime-generated kernels with cpu-acceleration for performance-sensitive numerical code.
The compatibility target is NumPy 2.x. When NumSharp behavior and NumPy behavior differ, NumPy is treated as the source of truth and aligns.
NumSharp lets C# and F# code use a NumPy-like programming model without embedding CPython. It is intended for scientific computing, numerical utilities, machine learning infrastructure, and projects that want NumPy-style array operations in ordinary .NET code.
NumSharp's edge is utilizing the power of C#'s dynamic IL generation and fused kernels translating to assembly generated with JIT optimizations and SIMD CPU acceleration. This edge leads the design of NumSharp's backend and by that to higher performance mark than NumPy on many functions as can be seen in Performance.
NumSharp focuses on:
Click here to see code Getting Started
NDArray - N-dimensional arrays with shape, strides, offsets,
slicing, and view semantics. Start with NDArray fundamentals
and NDArray.np.* API surface - Creation, manipulation, math, reductions,
comparisons, logic, random sampling, I/O, and formatting. Browse the
API reference.np.evaluate expressions for reducing intermediate allocations. See
NDIter.NumSharp's Coverage & Support Dashboard is presenting the full implementation roadmap to complete 100% NumPy porting with an explorer allowing you to quickly check your favorite functions!
NumSharp benchmarks are published as tracked release snapshots, not ad hoc numbers. The latest checked-in snapshot compares NumSharp with NumPy 2.4.2 across the operation matrix, supported dtypes, three size tiers, and the NDIter, layout, operand, cast, and fusion subsystems.
Install the core package:
dotnet add package NumSharp
Use familiar NumPy-style calls:
using NumSharp;
var a = np.arange(12).reshape(3, 4);
var window = a[":, 1::2"];
Console.WriteLine(window);
Console.WriteLine(np.sum(window, axis: 0));
For Python readers, the intended shape is deliberately close:
import numpy as np
a = np.arange(12).reshape(3, 4)
window = a[:, 1::2]
print(window.sum(axis=0))
Build:
dotnet build test/NumSharp.Tests/NumSharp.Tests.csproj --configuration Release
Run the normal CI-style unit test filter:
dotnet test test/NumSharp.Tests/NumSharp.Tests.csproj \
--configuration Release \
--no-build \
--framework net8.0 \
--filter "TestCategory!=OpenBugs&TestCategory!=HighMemory"
CI runs on Windows, Linux, and macOS for net8.0 and net10.0.
If you need to call the full CPython NumPy runtime from .NET, including Python extension modules NumSharp does not implement, see Numpy.NET. NumSharp is a native .NET implementation with a NumPy-shaped API; Numpy.NET bridges into Python.
NumSharp is released under the Apache License 2.0.
NumSharp is part of the SciSharp ecosystem for machine learning, mathematics, science, and engineering on .NET.
Overall
Maintained
Code review
NuGet
Latest release
Releases this year
2,130 followers · starred Jan 2019
143 followers · starred Apr 2019
503 followers · starred Aug 2019
73 followers · starred Mar 2023