Add Windows ARM64 CPU support for TorchSharp#1549
Open
alinpahontu2912 wants to merge 3 commits intodotnet:mainfrom
Open
Add Windows ARM64 CPU support for TorchSharp#1549alinpahontu2912 wants to merge 3 commits intodotnet:mainfrom
alinpahontu2912 wants to merge 3 commits intodotnet:mainfrom
Conversation
Add support for building, packaging, and distributing TorchSharp on Windows ARM64 (CPU-only, no CUDA). This enables .NET developers on Windows ARM64 devices to use TorchSharp with the stable LibTorch 2.10.0 release. Key changes: - MSBuild: Add win-arm64 RID mapping, archive name, and cmake path (ARM64 archive has different layout: lib/ instead of libtorch/lib/) - Native build: Enable ARM64 cross-compilation from x64 via MSVC amd64_arm64 toolchain and CMake -A ARM64 - Runtime: Detect win-arm64 in Torch.cs nativeRid for correct native library loading - NuGet: Add libtorch-cpu-win-arm64 package and update libtorch-cpu meta-package - CI: Add Windows ARM64 PR validation and native build pipeline jobs (cross-compiled on x64 agents) - LibTorch: ARM64 uses armpl_lp64.dll (ARM Performance Libraries) instead of Intel OpenMP (libiomp5md.dll) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
a1d76cc to
c37e7f2
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Windows ARM64 (CPU-only) support across TorchSharp’s runtime RID detection, build/packaging scripts, redist file lists, and CI packaging pipelines to enable building and distributing win-arm64-native assets.
Changes:
- Add
win-arm64runtime RID detection and new libtorch-cpu win-arm64 packaging inputs (SHA + NuGet project). - Update MSBuild/native build scripts for ARM64 cross-compilation and ARM64-specific LibTorch archive layout.
- Extend Azure Pipelines to validate/build and to produce/package Windows ARM64 artifacts.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/TorchSharp/Torch.cs | Detect win-arm64 for native package/runtime selection. |
| src/Redist/libtorch-cpu/libtorch-win-arm64-shared-with-deps-2.10.0%2Bcpu.zip.sha | Adds SHA pin for the Windows ARM64 LibTorch CPU archive. |
| src/Redist/libtorch-cpu/libtorch-cpu.proj | Adds ARM64-specific Windows DLL list and archive layout differences. |
| src/Native/gen-buildsys-win.bat | Adds CMake generator arch selection for ARM64. |
| src/Native/build.cmd | Enables MSVC cross-compilation setup for ARM64 and passes ARM64 through to CMake. |
| pkg/pack.proj | Adds packaging warning for missing win-arm64 TorchSharp native assets. |
| pkg/libtorch-cpu/libtorch-cpu.nupkgproj | Includes the new win-arm64 libtorch-cpu package as a dependency. |
| pkg/libtorch-cpu-win-arm64/libtorch-cpu-win-arm64.nupkgproj | New NuGet packaging project for libtorch-cpu-win-arm64. |
| azure-pipelines.yml | Adds PR validation job and packaging-stage job/artifact handling for Windows ARM64. |
| Directory.Build.targets | Adds ARM64 Windows CPU native dependency list for examples/tests. |
| Directory.Build.props | Adds win-arm64 RID mapping, ARM64 archive naming, and ARM64-specific CMake path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use ProcessArchitecture instead of OSArchitecture for nativeRid to correctly handle x64 emulation on ARM64 Windows - Add missing '-c Release' configuration to Windows_arm64 CI job - Consolidate duplicate TargetRuntimeID blocks into single block with mutually exclusive conditions - Update VS version list in gen-buildsys-win.bat usage text to include VS2022 and VS2026 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The job template appends \ to buildScript, so including 'Release' after '-c' resulted in 'dotnet build ... -c Release Release', where the trailing 'Release' was interpreted as a project path (MSB1009). Remove the explicit 'Release' so the template provides it, matching the pattern used by the MacOS_arm64 job. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #945
Add support for building, packaging, and distributing TorchSharp on Windows ARM64 (CPU-only, no CUDA). This enables .NET developers on Windows ARM64 devices to use TorchSharp with the stable LibTorch 2.10.0 release.
Key changes: