dotnet / TorchSharp

A .NET library that provides access to the library that powers PyTorch.
MIT License
1.4k stars 182 forks source link

How to use it in maui #1370

Open Barshan-Mandal opened 3 months ago

Barshan-Mandal commented 3 months ago

I want to use torchsharp for android and ios .How can i do it?

yueyinqiu commented 3 months ago

it might be pretty hard... #1083

Barshan-Mandal commented 3 months ago

but there must be a way as we know that c# is not capable enough to do much things like torch

Barshan-Mandal commented 3 months ago

make an easy and seamless integration.you may use pytorch mobile

asieradzk commented 3 months ago

You're not supposed to put torchlib on user devices, its too massive. You pretty much have two options:

  1. Export your models as ONNX and use that for inference.
  2. Build Asp .net core server application hosting TorchSharp stuff and expose it to android/ios frontend.
Barshan-Mandal commented 3 months ago

You're not supposed to put torchlib on user devices, its too massive. You pretty much have two options:

  1. Export your models as ONNX and use that for inference.
  2. Build Asp .net core server application hosting TorchSharp stuff and expose it to android/ios frontend.

but how does onnx exist for embedded devices?

asieradzk commented 3 months ago

You're not supposed to put torchlib on user devices, its too massive. You pretty much have two options:

  1. Export your models as ONNX and use that for inference.
  2. Build Asp .net core server application hosting TorchSharp stuff and expose it to android/ios frontend.

but how does onnx exist for embedded devices?

Something exists. For instance Unity already made two ONNX inference engines that run on mobile. The recent one is called Sentis, you can maybe use that? https://unity.com/products/sentis

NiklasGustafsson commented 3 months ago

TorchSharp supports the platforms that libtorch supports: the CPU backend on Windows X64, MacOS M1/M2/M3, Linux X64. In addition, both Windows and Linux support then libtorch CUDA backends.