Skip to content
.NET bindings for the Pytorch engine
C# C++ C Batchfile Shell CMake Other
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build cleaning up some commented code Jul 22, 2019
docfx Update API docs Jul 30, 2019
docs
ecmadocs/en Update API docs Jul 30, 2019
pkg cleaning up a bit Jul 22, 2019
src Delete unnecessary character Aug 7, 2019
test Merge pull request #114 from sumitdvlp/AvgPool Aug 2, 2019
tools-local/Microsoft.ML.InternalCodeAnalyzer porting some changes for integration of libraries Jun 5, 2019
.editorconfig porting some changes for integration of libraries Jun 5, 2019
.gitattributes porting some changes for integration of libraries Jun 5, 2019
.gitignore Untabify files Jul 20, 2019
BuildToolsVersion.txt porting some changes for integration of libraries Jun 5, 2019
Directory.Build.props re-activating debug builds Jun 13, 2019
Directory.Build.targets porting some changes for integration of libraries Jun 5, 2019
DotnetCLIVersion.netcoreapp.latest.txt porting some changes for integration of libraries Jun 5, 2019
DotnetCLIVersion.txt porting some changes for integration of libraries Jun 5, 2019
LICENSE Update Oct 15, 2018
Makefile Merged changes Jul 17, 2019
README.md Fix a broken link Aug 7, 2019
THIRD-PARTY-NOTICES.TXT Fix build nuget pacakges and build from VS 2019 Jun 12, 2019
TorchSharp.sln don't build native as part of solution Jun 13, 2019
azure-pipelines.yml cleaning up some commented code Jul 22, 2019
build.cmd porting some changes for integration of libraries Jun 5, 2019
build.proj porting some changes for integration of libraries Jun 5, 2019
build.sh make the .sh files executable again Jun 11, 2019
codecov.yml porting some changes for integration of libraries Jun 5, 2019
config.json porting some changes for integration of libraries Jun 5, 2019
dir.traversal.targets porting some changes for integration of libraries Jun 5, 2019
init-tools.cmd porting some changes for integration of libraries Jun 5, 2019
init-tools.msbuild porting some changes for integration of libraries Jun 5, 2019
init-tools.sh make the .sh files executable again Jun 11, 2019
run.cmd porting some changes for integration of libraries Jun 5, 2019
run.sh make the .sh files executable again Jun 11, 2019

README.md

Build Status

TorchSharp

TorchSharp is a .NET library that provides access to the library that powers PyTorch. It is a work in progress, but already provides a .NET API that can be used to perform (1) various operations on ATen Tensors; (2) scoring of TorchScript models; (3) Training of simple neural networks.

Our current focus is to bind the entire API surfaced by libtorch.

Things that you can try:

using AtenSharp;

var x = new FloatTensor (100);   // 1D-tensor with 100 elements
FloatTensor result = new FloatTensor (100);

FloatTensor.Add (x, 23, result);

Console.WriteLine (x [12]);

Discussions

We have a chat room on Gitter Gitter

Building

Windows

Requirements:

  • Visual Studio
  • git
  • cmake (tested with 3.14)

Commands:

  • Building: build.cmd
  • Building from Visual Studio: first build using the command line
  • See all configurations: build.cmd -?
  • Run tests from command line: build.cmd -runtests
  • Build packages: build.cmd -buildpackages

Linux/Mac

Requirements:

  • requirements to run .NET Core 2.0
  • git
  • cmake (tested with 3.14)
  • clang 3.9

Example to fulfill the requirements in Ubuntu 16:

sudo apt-get update
sudo apt-get install git clang cmake libunwind8 curl
sudo apt-get install libssl1.0.0
sudo apt-get install libomp-dev

Commands:

  • Building: ./build.sh
  • Building from Visual Studio: first build using the command line
  • See all configurations: ./build.sh -?
  • Run tests from command line: ./build.sh -runtests
  • Build packages: ./build.sh -buildpackages

Updating package version for new release

To change the pacakage version update this file. Everything is currently considered in preview.

Use the following two MSBuild arguments in order to control the -preview and the build numbers in the name of the nuget packages produced (use one of the two generally):

Name Value Example Version Output
StabilizePackageVersion true 1.0.0
IncludeBuildNumberInPackageVersion false 1.0.0-preview

Sample command: ./build.cmd -release -buildpackages -- /p:StabilizePackageVersion=true

Examples

Porting of the more famous network architectures to TorchSharp is in progress. For the moment we only support MNIST and AlexNet

You can’t perform that action at this time.