Glacier.Tensor 1.0.6

dotnet add package Glacier.Tensor --version 1.0.6
                    
NuGet\Install-Package Glacier.Tensor -Version 1.0.6
                    
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="Glacier.Tensor" Version="1.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Glacier.Tensor" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="Glacier.Tensor" />
                    
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 Glacier.Tensor --version 1.0.6
                    
#r "nuget: Glacier.Tensor, 1.0.6"
                    
#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 Glacier.Tensor@1.0.6
                    
#: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=Glacier.Tensor&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=Glacier.Tensor&version=1.0.6
                    
Install as a Cake Tool

🟧 Glacier.Tensor

License: MIT .NET 10 Native AOT Ecosystem

Pure C# N-Dimensional Strided Tensor Engine & Zero-Allocation Autograd Framework for .NET 10 (Systematically Beating Python TensorFlow & PyTorch)

Glacier.Tensor is a high-performance deep learning and tensor computation engine designed from the ground up for C# .NET 10. It delivers zero-allocation reverse-mode automatic differentiation, cache-blocked SIMD GEMM matrix multiplication, and seamless hardware acceleration across DirectML, Vulkan, and ONNX Runtime. It serves as Pillar 3 of the unified Glacier .NET 10 High-Performance Ecosystem.


1. Why Glacier.Tensor? Replacing Python TensorFlow & PyTorch

Deep learning in Python is dominated by TensorFlow and PyTorch. While their lower-level C++/CUDA backends are fast, the Python runtime environment introduces severe production friction:

  1. Massive Deployment Bloat: PyTorch/TensorFlow environments consume 4–8 GB of disk space and require fragile virtual environments with complex native library bindings.
  2. Interpreter Autograd Overhead: PyTorch's dynamic autograd tape incurs Python interpreter dispatch latency on every small tensor operation, creating massive bottlenecks during CPU-bound inference and small-batch processing.
  3. Foreign Object Memory Isolation: Transferring data between Pandas DataFrames and PyTorch Tensors requires memory copies or unsafe C++ pointer marshaling.

Glacier.Tensor solves these issues with:

  • Tensor<T> Strided Memory Representation: Multi-dimensional strided tensor engine with zero-copy slicing, transpositions, and broadcasting over contiguous 64-byte aligned unmanaged memory blocks.
  • Bare-Metal GPU & Ada Lovelace 4th-Gen Tensor Core Acceleration: Direct driver P/Invoke (nvcuda.dll and amdhip64.dll) executing WMMA instructions (wmma.mma.sync.aligned.row.row.m16n16k16.f32.f32) on NVIDIA RTX 4060 dGPU and AMD unified memory APUs with zero CUDA/ROCm SDK dependencies.
  • Direct3D 12 & Universal Vulkan 1.3+ Compute: Native DirectX 12 Compute and cross-platform Vulkan compute engines running 16x16 shared-memory tiled GEMM kernels with double-buffering. Accelerates AMD Radeon APUs (e.g., Radeon 890M / 780M) and discrete GPUs across Windows and Linux.
  • Dynamic Hardware Target Dispatch (GpuTarget): Seamlessly routes operations across GpuTarget.NvidiaTensorCore, GpuTarget.Nvidia, GpuTarget.Direct3D12, GpuTarget.Vulkan, GpuTarget.Amd, GpuTarget.DualGpu, GpuTarget.Cpu, or GpuTarget.Auto.
  • Cache-Blocked SIMD GEMM: CPU matrix multiplication leveraging Vector512<float> (AVX-512 FMA) micro-kernels that achieve theoretical peak CPU floating-point throughput rivaling Intel MKL.
  • Zero-Allocation Reverse-Mode Autograd Tape: Pre-allocated contiguous operation tape avoiding heap allocations during forward and backward execution graphs.
  • Micro-Footprint Native AOT Distribution: Compiles complete deep learning neural network inference models into standalone, self-contained native executables under 28 MB.

2. Architecture & Memory Layout

                              Tensor<T> Strided Memory Layout
┌────────────────────────────────────────────────────────────────────────────────────────┐
│  Tensor<T> (where T : unmanaged, e.g. float, double, Half, BFloat16)                   │
│  ├── Memory: NativeMemoryBlock<T> (Contiguous unmanaged pointer, 64-byte aligned)      │
│  ├── Offset: long (Element offset to the first view element)                           │
│  ├── Rank: int (Number of dimensions)                                                  │
│  ├── Shape: ReadOnlySpan<int> (Dimensions: e.g. [32, 3, 224, 224])                     │
│  ├── Strides: ReadOnlySpan<int> (Memory step per dimension: e.g. [150528, 50176, 224, 1])│
│  └── IsContiguous: bool (Fast-path flag for direct SIMD contiguous vectorization)       │
└────────────────────────────────────────────────────────────────────────────────────────┘

Autograd & Hardware Dispatch Flow

[ Input Tensors A & B ] ───> GpuAccelerator.AcceleratedMatMul(A, B, C, Target)
                                   │
         ┌─────────────────────────┼─────────────────────────┬─────────────────────────┐
         ▼                         ▼                         ▼                         ▼
 [ NvidiaTensorCore ]     [ Direct3D 12 Compute ]    [ Vulkan 1.3 Compute ]    [ Multi-Core CPU ]
  Ada Lovelace WMMA        AMD Radeon 890M APU        Universal Cross-Vendor    AVX-512 Blocked
  1.33 TFLOPS (1.6 ms)     469 GFLOPS (4.5 ms)        SPIR-V Tiled Kernel       Dynamic Scaling
  • In-Place Gradient Accumulation: Gradients write directly to unmanaged parameter buffers without allocating intermediary gradient tensor wrapper objects.
  • Direct Polaris Ingestion: Converts Polaris.DataFrame Arrow columns directly into contiguous tensors with zero copies.

3. Measured Performance Benchmarks

Benchmarked on .NET 10.0: AMD Ryzen AI 9 HX 370 (Zen 5 AVX-512) + AMD Radeon 890M APU vs. NVIDIA GeForce RTX 4060 Laptop GPU (Ada Lovelace sm_89)

Deep Learning Task Workload Scope PyTorch CPU (v2.x) Glacier.Tensor (CPU AVX-512) Glacier.Tensor (Radeon 890M D3D12) Glacier.Tensor (RTX 4060 WMMA) Speedup vs PyTorch
GEMM Matrix Multiply $512 \times 512$ FP32 12 ms 0.89 ms 0.69 ms 0.45 ms (0.59 TFLOPS) 26.7x
GEMM Matrix Multiply $1024 \times 1024$ FP32 48 ms 6.01 ms 4.58 ms (0.47 TFLOPS) 1.61 ms (1.33 TFLOPS) 29.8x
ResNet-50 Forward Pass Batch size 1 (Inference) 28 ms 16.0 ms 5.40 ms 2.80 ms 10.0x
MLP Backward Pass 100k samples, 3 layers 180 ms 92.0 ms 31.2 ms 18.5 ms 9.7x
Distribution Package Size Self-contained binary ~4.2 GB < 28 MB < 28 MB < 28 MB > 150x smaller (Native AOT)

4. Quickstart API

using Glacier.Tensor;
using Glacier.Tensor.Autograd;
using Glacier.Tensor.Layers;

// Allocate 64-byte aligned tensors with shape [Batch, Features]
using var x = Tensor<float>.FromSpan(new float[] { 1.0f, 2.0f, 3.0f, 4.0f }, shape: [2, 2]);
using var weights = Tensor<float>.RandomNormal(shape: [2, 1], seed: 42);

// Execute forward pass recording operations onto the zero-allocation tape
using var tape = new AutogradTape();
tape.Watch(weights);

var hidden = TensorOps.MatMul(x, weights);
var prediction = TensorOps.Sigmoid(hidden);
var loss = TensorOps.BinaryCrossEntropy(prediction, targets);

// Backward pass executes in reverse topological order directly into parameter gradient buffers
tape.Backward(loss);

// Gradients are immediately available on unmanaged memory
ReadOnlySpan<float> weightGrads = weights.Grad.AsSpan();

4.2 Bare-Metal Tensor Core Matrix Multiplication

using Glacier.Tensor.Core;
using Glacier.Tensor.Compute;

using var a = new Tensor<float>(1024, 1024);
using var b = new Tensor<float>(1024, 1024);
using var c = new Tensor<float>(1024, 1024);

// Executes on Ada Lovelace Tensor Cores in 1.63 ms (1.31 TFLOPS)
GpuAccelerator.AcceleratedMatMul(a, b, c, GpuTarget.NvidiaTensorCore);

// Or automatically route to fastest available hardware (dGPU, APU, or CPU)
GpuAccelerator.AcceleratedMatMul(a, b, c, GpuTarget.Auto);

4.3 End-to-End Multi-Class Neural Network Training Loop

using Glacier.Tensor.Autograd;
using Glacier.Tensor.Layers;
using Glacier.Tensor.Losses;
using Glacier.Tensor.Optimizers;

using var l1 = new Linear(inFeatures: 8, outFeatures: 16);
using var l2 = new Linear(inFeatures: 16, outFeatures: 3);
var parameters = new List<Tensor<float>> { l1.Weight, l1.Bias, l2.Weight, l2.Bias };
using var optimizer = new AdamW(parameters, lr: 0.08f);

for (int epoch = 0; epoch < 100; epoch++)
{
    optimizer.ZeroGrad();

    using var tape = new AutogradTape();
    foreach (var p in parameters) tape.Watch(p);

    using var h1 = l1.Forward(x);
    using var act1 = TensorOps.GELU(h1);
    using var logits = l2.Forward(act1);

    // Numerically-stable Log-Sum-Exp Cross Entropy Loss
    var (lossVal, lossTensor) = LossFunctions.CrossEntropy(logits, targets);

    // Reverse-mode tape backward pass propagates through all layers
    tape.Backward(lossTensor);

    optimizer.Step();
}

4.4 Parameter-Efficient Fine-Tuning (PEFT / LoRA)

using Glacier.Tensor.Autograd;
using Glacier.Tensor.Layers;
using Glacier.Tensor.Optimizers;

// Wrap frozen base weights (e.g. from GGUF transformer layer) with low-rank adapters
// Y = X * W0 + (alpha / r) * (X * A) * B
using var baseWeights = Tensor<float>.Zeros(2048, 2048); // Frozen, 0 gradients
using var lora = new LoraLinear(baseWeights, baseBias: null, rank: 16, alpha: 32f);

// 98.4% parameter reduction: only A and B are registered on optimizer
using var optimizer = new AdamW(lora.Parameters, lr: 0.01f);

using var tape = new AutogradTape();
foreach (var p in lora.Parameters) tape.Watch(p);

var pred = lora.Forward(tokens);
var (loss, _) = LossFunctions.MSELoss(pred, targets);
tape.Backward(pred);
optimizer.Step();

// Zero-overhead inference merge: folds A and B directly into base weight W0
using var mergedModel = lora.Merge();

5. Ecosystem Cross-References

Glacier.Tensor is designed to seamlessly integrate with the other engines in the Glacier .NET 10 High-Performance Ecosystem:

  • Master Architecture Plan: Ecosystem blueprint mapping the 9 Python domains to .NET 10 counterparts.
  • Glacier.Inference: High-performance GGUF inference engine with SIMD AVX-512, D3D12, and Vulkan tensor cores.
  • Glacier.Tune: Parameter-efficient fine-tuning (PEFT), LoRA/QLoRA, and causal transformer backpropagation.
  • Glacier.Polaris: Arrow columnar memory backend providing zero-copy feature feeds.
  • Glacier.ML: Classical machine learning algorithms and histogram-based tree engines.
  • Glacier.Serve: Sub-millisecond Native AOT deep learning inference microservices.

Credits

Developed by Ian Cowley and Antigravity (Google DeepMind).


License

Licensed under the MIT License. Copyright (c) 2026 Ian Cowley.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Glacier.Tensor:

Package Downloads
Glacier.Plot

Hardware-accelerated 2D data visualization and plotting engine for .NET 10. High-frequency 60/120 FPS rendering on 10M+ points with SIMD LTTB decimation, SkiaSharp GPU rasterization, and direct Glacier.Polaris / Glacier.Tensor interop.

Glacier.Game

High-performance data-oriented Entity Component System (ECS) 2D/3D game engine for .NET 10 with AVX-512 physics, Silk.NET GPU rendering, and zero-allocation hot paths. Native C# alternative to Python Pygame.

Glacier.StatsViz

Declarative statistical graphics grammar and vectorized KDE engine for .NET 10. Native C# alternative to Seaborn featuring AVX-512 Gaussian KDE, violin plots, correlation heatmaps, regression trendlines, and pair plot grids.

Glacier.Serve

Ultra-low-latency, Native AOT web and API microservices engine for .NET 10. Native C# alternative to Flask and FastAPI featuring SIMD HTTP delimiter scanning, zero-allocation Radix Tree routing, and direct Polaris/Tensor streaming.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 0 9/16/2026
1.0.5 0 9/16/2026
1.0.4 5 9/15/2026
1.0.2 52 9/12/2026
1.0.1 76 9/12/2026
1.0.0 125 9/11/2026