Skip to content

refactor: migrate to AiDotNet.Tensors NuGet package - #741

Merged
ooples merged 9 commits into
masterfrom
refactor/use-tensors-nuget-pkg
Jan 22, 2026
Merged

ooples merged 9 commits into
masterfrom
refactor/use-tensors-nuget-pkg

Conversation

@ooples

@ooples ooples commented Jan 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

This PR migrates from the embedded AiDotNet.Tensors source code to using the NuGet packages from the spun-out AiDotNet.Tensors repository.

Changes

  • Replace embedded Tensors project reference with NuGet packages:
    • AiDotNet.Tensors v0.3.0 - Core tensor operations
    • AiDotNet.Native.OpenBLAS v0.3.0 - CPU BLAS acceleration
    • AiDotNet.Native.CLBlast v0.3.0 - GPU OpenCL acceleration
  • Exclude polyfills already provided by the Tensors package
  • Update benchmark and test console projects for NuGet compatibility
  • Remove references to internal types (OneDnnProvider, BlasProvider) that are not exposed via NuGet

Notes

  • OneDNN support will be added once AiDotNet.Tensors v0.4.0 is released (PR Added new regression and normalization options #4 pending in Tensors repo)
  • GPU tuning tests that rely on internal Tensors types have been excluded from compilation
  • All builds pass for both net10.0 and net471 targets

Test plan

  • Main library builds (net10.0 and net471)
  • Benchmark tests build
  • Test console builds
  • Run unit tests
  • Verify native DLLs are copied to output

🤖 Generated with Claude Code

- Replace AiDotNet.Tensors project reference with NuGet package v0.1.0
- Remove src/AiDotNet.Tensors folder (now in separate repo)
- Remove src/AiDotNet.Native.CLBlast folder (now in Tensors package)
- Remove src/AiDotNet.Native.OpenBLAS folder (now in Tensors package)
- Remove src/AiDotNet.Native.OneDNN placeholder folder
- Remove tests/AiDotNet.Tensors.Tests (now in separate repo)
- Remove tests/AiDotNet.Tensors.Benchmarks (now in separate repo)
- Update testconsole and GpuDiagnostic to use NuGet package
- Clean up solution file to remove deleted project references

The AiDotNet.Tensors code has been spun out to a separate repository
and published to NuGet: https://www.nuget.org/packages/AiDotNet.Tensors/

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 21, 2026 18:58
@vercel

vercel Bot commented Jan 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
aidotnet-playground-api Ready Ready Preview, Comment Jan 21, 2026 11:53pm

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the AiDotNet.Tensors project from a local project reference to a published NuGet package (v0.1.0), separating tensor operations into an independent, versioned package. The changes remove the local tensor implementation code and native library folders, replacing them with NuGet package references.

Changes:

  • Removed local AiDotNet.Tensors source code (~220K lines) and tests
  • Removed native library folders (CLBlast, OpenBLAS, OneDNN)
  • Updated project references to use AiDotNet.Tensors NuGet package v0.1.0
  • Updated test and diagnostic projects to consume the NuGet package

Reviewed changes

Copilot reviewed 44 out of 374 changed files in this pull request and generated no comments.

File Description
Multiple CUDA kernel files Complete removal of local CUDA kernel implementations (optimizer, octonion, normalization, neural net, mesh pool, LSTM, locally connected, hyperbolic, GRU, fused, FP16)
CudaSyncPoint.cs Removal of CUDA synchronization point implementation
ActivationType.cs Removal of activation type enum definition
IsExternalInit.cs Removal of .NET Framework compatibility shim

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai

coderabbitai Bot commented Jan 21, 2026 •

Copy link
Copy Markdown
Contributor

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Summary by CodeRabbit

  • Chores
    • Removed GPU acceleration stack and CUDA/cuDNN-based kernels/utilities.
    • Removed native BLAS and acceleration packaging (OpenBLAS, CLBlast, OneDNN); guidance moved to NuGet.
    • Removed several advanced CPU engines and tensor compatibility helpers (sparse, hyperbolic, advanced-algebra, SIMD/Half shims).
    • Simplified project structure, CI/docs workflows, and updated benchmark diagnostics to reflect packaging changes.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This PR removes the AiDotNet.Tensors project and many native/GPU integrations: solution/project entries, native packaging (CLBlast/OneDNN/OpenBLAS), compatibility shims, CPU/GPU engines, DirectGpu/CUDA/cuBLAS/cuDNN bindings, and embedded CUDA kernel providers.

Changes

Cohort / File(s) Summary
Solution & Projects
AiDotNet.sln, src/AiDotNet.Tensors/AiDotNet.Tensors.csproj, src/AiDotNet.Native.*/*
Removed the AiDotNet.Tensors project and native packaging projects; deleted solution Project entries and ProjectConfigurationPlatform mappings.
Native packaging & targets
src/AiDotNet.Native.CLBlast/*, src/AiDotNet.Native.OpenBLAS/*, src/AiDotNet.Native.OneDNN/*
Deleted .csproj packaging metadata, build/targets files, native runtime packaging directives, and LICENSE.OpenBLAS.txt.
Compatibility shims
src/AiDotNet.Tensors/Compatibility/*
(HalfCompat.cs, IsExternalInit.cs, SimdCompat.cs)
Removed polyfills/shims for Half, IsExternalInit, and SIMD/Vector types.
Global engine & thresholds
src/AiDotNet.Tensors/Engines/AiDotNetEngine.cs, .../AdaptiveThresholds.cs
Deleted global engine management, GPU-context helpers, and adaptive threshold configuration types.
CPU engines & BLAS
src/AiDotNet.Tensors/Engines/*
(CpuAdvancedAlgebraEngine.cs, CpuHyperbolicManifoldEngine.cs, CpuSparseEngine.cs, CpuNativeBlas.cs)
Removed multiple CPU engine implementations and the native BLAS loader/integration.
GPU transfer & buffers
src/AiDotNet.Tensors/Engines/AsyncGpuTransfer.cs
Deleted asynchronous GPU transfer subsystem (AsyncGpuTransfer, GpuBuffer, DoubleBuffer, TransferType).
CUDA/cuBLAS/cuDNN interop
src/AiDotNet.Tensors/Engines/CuBlasNative.cs, .../CuDnnNative.cs
Removed P/Invoke bindings and high-level CUDA/cuBLAS/cuDNN wrapper/context classes.
DirectGpu infra (CUDA)
src/AiDotNet.Tensors/Engines/DirectGpu/*, .../CUDA/*
(CudaNativeBindings.cs, CudaEvent.cs, CudaStream.cs, CudaSyncPoint.cs, ActivationType.cs)
Deleted DirectGpu driver bindings, streams/events/sync primitives, enums and helpers.
CUDA kernel providers
src/AiDotNet.Tensors/Engines/DirectGpu/CUDA/Kernels/*
Removed many embedded CUDA kernel source providers and kernel-name registries (GetSource/GetKernelNames) across convolution, attention, FFT, RNN, optimizers, fused kernels, etc.
Benchmarks & diagnostics
AiDotNetBenchmarkTests/*
Removed native DLL copy/packaging blocks; replaced dynamic oneDNN/OpenBLAS availability checks with static messages/comments.
CI workflow
.github/workflows/sonarcloud.yml
Adjusted workflow test matrix and expanded disk-space cleanup and docs deployment steps.

Sequence Diagram(s)

sequenceDiagram
  participant App as Application
  participant Engine as AiDotNetEngine
  participant DirectGpu as DirectGpu Layer
  participant Native as CUDA/cuBLAS/cuDNN
  participant GPU as Device GPU

  App->>Engine: request tensor operation (e.g., MatMul)
  Engine->>DirectGpu: select DirectGpu backend, create context
  DirectGpu->>Native: allocate/copy buffers, launch kernel
  Native->>GPU: execute kernel / cuBLAS/cuDNN calls
  GPU-->>Native: complete, return results
  Native-->>DirectGpu: signal completion, copy back
  DirectGpu-->>Engine: deliver result
  Engine-->>App: return result
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

Poem

🐇 I nudged the kernels, soft and light,

I left a meadow open, bright.
Streams and events took their bow,
A quiet patch for code to grow now.
Hopping on, I cheer the change.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: migrating from embedded source code to NuGet packages for AiDotNet.Tensors.
Description check ✅ Passed The description is well-structured and directly related to the changeset, explaining the migration from embedded Tensors source to NuGet packages with specific package versions and related changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/use-tensors-nuget-pkg

Comment @coderabbitai help to get the list of available commands and usage tips.

- Update AiDotNet.Tensors from v0.2.0 to v0.3.0
- Add AiDotNet.Native.OpenBLAS v0.3.0 (now includes native DLL)
- Update AiDotNet.Native.CLBlast to v0.3.0
- Remove references to internal types (OneDnnProvider, BlasProvider)
- Exclude GPU tuning tests that require internal Tensors types
- Update benchmark and testconsole projects for NuGet package compatibility

Note: OneDNN package will be added once v0.4.0 is released with
the updated release workflow.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai coderabbitai Bot added the diffusion Diffusion pipelines and schedulers label Jan 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@AiDotNetBenchmarkTests/TorchSharpCpuComparisonBenchmarks.cs`:
- Line 57: The Console.WriteLine statement that unconditionally prints "AiDotNet
BLAS: enabled (via AiDotNet.Native.OpenBLAS package)" should be changed to a
non-assertive message or gated by an actual runtime check; locate the
Console.WriteLine after creating the CpuEngine instance and either (A) change
the text to indicate the package/reference is present but runtime loading may
vary (e.g., "AiDotNet BLAS: package referenced; runtime native load required")
or (B) query the engine for a native BLAS availability flag (e.g., a
property/method on CpuEngine such as IsNativeBlasLoaded or similar) and only
report "enabled" when that check returns true, otherwise log a
neutral/conditional message that it may not be available at runtime.

Comment thread AiDotNetBenchmarkTests/TorchSharpCpuComparisonBenchmarks.cs Outdated
- Update AiDotNet.Tensors from 0.3.0 to 0.4.0
- Update AiDotNet.Native.OpenBLAS from 0.3.0 to 0.4.0
- Update AiDotNet.Native.CLBlast from 0.3.0 to 0.4.0
- Add AiDotNet.Native.OneDNN 0.4.0 for Intel CPU acceleration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 21, 2026 21:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 48 out of 379 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Change the benchmark log message to reflect that the package is referenced
rather than asserting the native library is loaded at runtime.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace tensor.Data.Span[i] with tensor[i] to use the public
flat indexer API available in the AiDotNet.Tensors NuGet package.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 21, 2026 21:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 48 out of 380 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread AiDotNetBenchmarkTests/Program.cs Outdated
- Replace .Data.Span[i] with [i] (flat indexer)
- Replace .Data.Span with .AsSpan()
- Replace .Data.Length with .Length
- Replace .Data.ToArray() with .ToArray()
- Replace data.AsSpan().CopyTo(t.Data.Span) with t.CopyFromArray(data)

These changes use the public API available from the AiDotNet.Tensors
NuGet package instead of the internal Data property.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 21, 2026 22:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 48 out of 404 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Update AiDotNetBenchmarkTests/Program.cs to work with the
AiDotNet.Tensors NuGet package public API.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ooples
ooples force-pushed the refactor/use-tensors-nuget-pkg branch from d49780f to a410ac0 Compare January 21, 2026 22:24
@coderabbitai coderabbitai Bot added the feature Feature work item label Jan 21, 2026
AsSpan() returns ReadOnlySpan<T> in the NuGet package, so
direct writes to span[i] fail with CS8331. Use tensor[i]
indexer for write operations instead.
Copilot AI review requested due to automatic review settings January 21, 2026 22:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 49 out of 407 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

AiDotNet.Tensors.Tests project moved to separate AiDotNet.Tensors
repository as part of the package spinout.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/sonarcloud.yml (1)

561-591: Remove the Node.js deletion before subsequent uses steps.

Line 586 removes /opt/hostedtoolcache/node, which the runner requires to execute subsequent JavaScript actions (checkout, setup-dotnet, cache, configure-pages, upload-pages-artifact, deploy-pages). Removing this will cause those steps to fail. Either remove this line or defer the Node deletion until after the final uses step.

Proposed fix
-          sudo rm -rf /opt/hostedtoolcache/node || true

@ooples
ooples merged commit b7c25a1 into master Jan 22, 2026
38 checks passed
@ooples
ooples deleted the refactor/use-tensors-nuget-pkg branch January 22, 2026 02:11

This branch was successfully deployed

1 active deployment
Preview — ce3ff9c7 Deployed Jan 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diffusion Diffusion pipelines and schedulers feature Feature work item roadmap Roadmap-tracked item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants