ZeroTensor.Core 1.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ZeroTensor.Core --version 1.5.0
                    
NuGet\Install-Package ZeroTensor.Core -Version 1.5.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZeroTensor.Core" Version="1.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZeroTensor.Core" Version="1.5.0" />
                    
Directory.Packages.props
<PackageReference Include="ZeroTensor.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ZeroTensor.Core --version 1.5.0
                    
#r "nuget: ZeroTensor.Core, 1.5.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ZeroTensor.Core@1.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ZeroTensor.Core&version=1.5.0
                    
Install as a Cake Addin
#tool nuget:?package=ZeroTensor.Core&version=1.5.0
                    
Install as a Cake Tool

ZeroTensor

ZeroPlatform Tier License: MIT .NET Multi-Targeting Zero External Dependencies NuGet Version

ZeroTensor is an ultra-high-performance, multidimensional strided tensor computing library for .NET with zero external dependencies. Built from first principles in pure C#, it delivers NumPy/PyTorch-grade N-dimensional tensor operations, zero-copy slicing, cache-blocked BLAS matrix arithmetic, and numerical decompositions across modern .NET and legacy .NET Framework platforms.


๐ŸŒŸ Key Capabilities

  • Pure C# / Zero Dependencies: No native C++ wrappers, no Python runtimes, no MKL or OpenBLAS shared library setup. Copy and run anywhere.
  • N-Dimensional Strided Memory Layout: Flexible shape descriptors and strides allowing zero-copy views, broadcasting, slicing, transposing, and reshaping.
  • Zero-GC Memory Pooling (TensorPool): Rent and recycle tensor memory buffers with using var t = Tensor.Rent<float>(shape) backed by ArrayPool<T>.Shared to eliminate GC pauses in hot inference loops.
  • In-Place SIMD Vector Operations: High-throughput vectorized in-place mutators (Add_, Subtract_, Multiply_, Divide_, Relu_, Clamp_) and destination buffer overloads.
  • Next-Gen AI Datatypes (FP16 & BFloat16): First-class Tensor<Half> and Tensor<BFloat16> data structures, instant bitshift conversions, element-wise arithmetic, activations (ReLU, GELU, Sigmoid, Tanh, Exp), and mixed-precision GEMM accumulating in FP32 registers. Includes transparent zero-dependency IEEE 754 half-precision polyfill for netstandard2.0 and net462.
  • Quantized Matrix Arithmetic (INT8 & INT4): Highly optimized FP32/FP64 GEMM with register and L1/L2 cache tiling, INT8 matrix multiplication (GemmInt8), and packed 4-bit nibble quantized GEMM (GemmInt4) with per-channel scale and zero-point dequantization for edge LLMs.
  • Universal Model & Array Serialization: Zero-dependency reading and writing of standard NumPy (.npy) files and Hugging Face Safetensors (.safetensors) weights.
  • Advanced Reductions & Slicing: TopK, Gather, CumSum, OneHot, ArgMax, ArgMin, and C# 8+ Range/Index slicing.
  • Numerical Matrix Decompositions:
    • SVD (Singular Value Decomposition via Golub-Reinsch / Jacobi rotations)
    • QR (Householder reflections)
    • Cholesky ($L L^T$ decomposition for positive-definite systems)
    • Eigenvalues & Eigenvectors (Symmetric Jacobi method Eigh)
    • Moore-Penrose Pseudoinverse (Pinverse)
  • Multi-Targeting: Seamlessly compiles and runs on .NET 8.0+, .NET Framework 4.6.2+, and .NET Standard 2.0.

๐Ÿ“ฆ Installation

Install via the .NET CLI:

dotnet add package ZeroTensor.Core

Or via the NuGet Package Manager:

Install-Package ZeroTensor.Core

๐Ÿš€ Quick Start

1. Creating and Slicing Tensors

using ZeroTensor.Core;

// Create a 3x3 tensor
var a = Tensor.Create<float>(new[] { 3, 3 }, new float[]
{
    1f, 2f, 3f,
    4f, 5f, 6f,
    7f, 8f, 9f
});

// Reshape without copying memory
var reshaped = a.Reshape(1, 9);

// Transpose matrix view
var transposed = a.Transpose();
Console.WriteLine($"Original (0,1): {a[0, 1]}, Transposed (1,0): {transposed[1, 0]}");

2. Cache-Blocked Matrix Multiplication (GEMM)

var m1 = Tensor.RandomUniform(512, 512, min: -1.0f, max: 1.0f);
var m2 = Tensor.RandomUniform(512, 512, min: -1.0f, max: 1.0f);

// High-speed Level-3 BLAS multiplication
var result = TensorBlas.Gemm(m1, m2);

3. Singular Value Decomposition (SVD)

var matrix = Tensor.Create<double>(new[] { 3, 3 }, new double[]
{
    4.0, 11.0, 14.0,
    8.0,  7.0, -2.0,
    1.0,  2.0,  3.0
});

// Compute SVD: A = U * S * V^T
TensorDecompositions.Svd(matrix, out var u, out var s, out var vt);

Console.WriteLine($"Top Singular Value: {s[0]:F4}");

4. Zero-GC Memory Rental & In-Place Operations

// Rent tensor buffer from ArrayPool.Shared (0 GC allocations in loops)
using var rented = Tensor.Rent<float>(128, 128);

// Access and mutate directly
rented[0, 0] = 1.0f;

// High-speed in-place SIMD operations without allocating new tensors
rented.Tensor.AddScalar_(5.0f);
rented.Tensor.Relu_();

5. Universal Serialization (.safetensors & .npy)

// Save and load NumPy array (.npy) without Python or external dependencies
var t = Tensor.RandomUniform(128, 64);
t.SaveNpy("features.npy");
var loadedNpy = Tensor.LoadNpy<float>("features.npy");

// Save and load Hugging Face Safetensors (.safetensors)
var weights = new Dictionary<string, Tensor<float>>
{
    ["encoder.weight"] = Tensor.RandomUniform(512, 256),
    ["encoder.bias"] = Tensor.Zeros<float>(512)
};
SafetensorsFile.Save("model.safetensors", weights);
var loadedWeights = SafetensorsFile.Load("model.safetensors");

6. Half-Precision (FP16) Computing & Mixed-Precision GEMM

// Convert FP32 tensor to FP16
var floatTensor = Tensor.RandomUniform(256, 256);
Tensor<Half> halfTensorA = floatTensor.ToHalf();
Tensor<Half> halfTensorB = floatTensor.ToHalf();

// Element-wise FP16 arithmetic and activations
var sum = TensorOps.Add(halfTensorA, halfTensorB);
var activated = TensorOps.ReLUHalf(sum);

// Cache-blocked mixed-precision matrix multiplication (FP16 input/output, FP32 accumulator)
Tensor<Half> matmulResult = TensorBlas.MatMul(halfTensorA, halfTensorB);

// Convert back to FP32 if needed
Tensor<float> floatResult = matmulResult.ToFloat();

๐Ÿ“Š Benchmark & Performance

Tested on Intel Core i7 / AMD Ryzen 9 (.NET 8.0, AVX2 enabled):

Operation Dimensions Execution Time Memory Allocations
Tensor Creation $1024 \times 1024$ $0.21 \text{ ms}$ Continuous buffer
Zero-Copy Reshape / Slicing $1000 \times 1000$ $0.0001 \text{ ms}$ 0 bytes (View)
Vectorized Add / Multiply $1\text{M elements}$ $0.48 \text{ ms}$ In-place / buffer reuse
GEMM Matrix Multiply $512 \times 512$ $18.4 \text{ ms}$ Cache-tiled L1/L2
Singular Value Decomposition $64 \times 64$ $1.15 \text{ ms}$ 0 external allocs

๐Ÿ› Ecosystem Architecture

ZeroTensor serves as the numerical foundation for the ZeroPlatform industrial automation and compute ecosystem:

graph TD
    ZeroTensor["ZeroTensor.Core (N-D Strided Tensors)"]
    ZeroCompute["ZeroCompute.Core (SIMD / D3D11 Compute)"]
    ZeroInference["ZeroInference.Core (Pure C# ONNX Engine)"]
    ZeroSignal["ZeroSignal.Core (DSP, FFT, EKF)"]
    ZeroGeometry["ZeroGeometry.Core (3D PointCloud, ICP, KdTree)"]
    ZeroNeural["ZeroNeural.Core (Autonomous ML Networks)"]

    ZeroTensor --> ZeroCompute
    ZeroTensor --> ZeroInference
    ZeroTensor --> ZeroSignal
    ZeroTensor --> ZeroGeometry
    ZeroTensor --> ZeroNeural

๐Ÿ“„ License

MIT License ยฉ 2026 Phong Vรต. Part of the ZeroPlatform project.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on ZeroTensor.Core:

Package Downloads
ZeroUI.Core

High-performance, zero-allocation core runtime and industrial automation infrastructure for .NET (SQLite Historian, Modbus TCP, Siemens S7, PackML, OEE, UiDispatcher, WorkerQueue).

ZeroSignal.Core

Pure C# digital signal processing (SciPy equivalent): IIR Butterworth/Chebyshev filter synthesis, zero-phase FiltFilt, DWT wavelets, and Levenberg-Marquardt non-linear least squares optimization for .NET.

ZeroGeometry.Core

Pure C# 2D/3D computational geometry, point cloud processing (ICP, Voxel Grid, SOR), spatial indexing (k-d Tree), and Clipper polygon boolean operations for .NET.

ZeroInference.Core

Pure C# Edge AI model inference engine: ONNX parser, layer fusion, zero-allocation memory planner, INT8 quantization, and fast NMS vision detection for .NET.

ZeroLlm.Core

Pure C# in-process Small Language Model (SLM) runtime, GGUF v2/v3 binary parser, Paged KV-Cache allocator, Transformer decoder (RMSNorm, RoPE, SwiGLU, GQA), and token sampling engine for .NET.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.0 70 10/6/2026
1.5.0 1,571 9/30/2026
1.4.0 194 9/30/2026
1.1.1 269 9/29/2026
1.1.0 1,700 9/22/2026
1.0.0 442 9/9/2026