-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Classes of torchvision\ops #790
Comments
TORCHVISION.OPSsuggestion: Need to approach this ALSO from the perspective of Onnx contributed Ops flowchart TD
image-->|com.microsoft.vision\nops| TorchSharp\nmodel-->|com.microsoft.vision\nops| output\nimage
|
Why there are no Torchaudio.ops? Are they in here? e.g. com.microsoft.audio flowchart TD
audio-->|com.microsoft.audio\nops| TorchSharp\nmodel-->|com.microsoft.audio\nops| output\naudio
|
Most of the Torchtext.ops are here com.microsoft.nlp flowchart TD
text-->|com.microsoft.nlp\nops| TorchSharp\nmodel-->|com.microsoft.nlp\nops| output\ntext
|
Probably ONNX runtime approach is not related to this.
@NiklasGustafsson I don't know about what happened to |
There's a small number of ops in torchvision.ops. Feel free to contribute more, if you have time. It would be good to have an issue to track them. I'll open something up. |
BTW, it seems like FFMPEG is disabled by default in PyTorch, now: https://pytorch.org/vision/stable/#torchvision.set_video_backend You have to build from source to enable it, apparently. |
seems there is no prebuild package for torchvision, what is the best way to add it after build from source? |
TorchVision is now available on NuGet: https://www.nuget.org/packages/TorchVision, starting with version 0.98.1, when it was split out from TorchSharp. |
I try to call the native method from torchvision, torch.ops.torchvision.nms how to do it in TorchSharp? |
I believe someone already implemented nms in C#. TorchSharp/src/TorchVision/Ops.cs Line 48 in 2f89e58
|
To answer your question, though -- I haven't understood where the native code binaries and header files for TV are to be found. If you figure that out, we should bundle it in with the other native code we already have. |
They are under https://github.com/pytorch/vision/tree/main/torchvision/csrc/ops, contains cpu and cuda implementations. |
Have you found where pre-built binaries are available for download? |
no, only build from source. |
Note that the current libtorch binaries are 1.11, with CUDA 11.3 -- that will matter for building compatible TV binaries, I believe. |
For Onnxruntime, here is some preliminary discussion how to register Onnx Ops |
Fortunately I have done the build, there are 3 files, torchvision.dll, torchvision.exp, torchvision.lib, |
@xhuan8 -- this is really cool! There are a couple of things to think about next:
So, we have to decide where these native libraries go, whether in the same package as the managed TorchVision binaries, or in a separate one. It will depend on the overall size (separate Windows + MacOS + Linux binaries), as well as whether a CUDA backend can be loaded on a machine without a CUDA-capable GPU. This will impact the library names we pick, too. |
Also, how to automate the build -- do we do this manually and add the binaries to the build, or do we somehow integrate the pytorch/vision repo into the TorchSharp build process? We should consider pytorch/text and pytorch/audio at the same time. Thanks for doing this work, it's going to make a huge difference! |
@GeorgeS2019 -- I love your enthusiasm for ONNX runtime ops. However, I want to say that TorchSharp is about providing a .NET layer on top of the native library (libraries) underlying PyTorch. Nothing less, nothing more. It's simplistic, perhaps, but the main point is that it simple. Other projects can and should go beyond TorchSharp and provide all kinds of additional features, including interactions with ONNX. Thus, ONNX runtime ops (contributed or not) lie outside the scope of what TorchSharp will be designed for. |
try to load torchvision native dll with LoadLibrary, it fails with error 1114, @NiklasGustafsson @kaiidams do you have any idea? |
@xhuan8 FYI: could be interesting and the example involves TorchScript, however not related to TorchSharp, more investigation needed. |
@xhuan8 If this is the build from torchvision, it is a C++ torchvision library. You'll need to make a C wrapper so that C# can use it with P/Invoke.
If Torch C++ provides
|
@NiklasGustafsson To build torchvision.dll you'll need Python (and zlib, libpng, CUDA, etc) I think it should be built outside TorchSharp. |
Yeah, you're right... Ideally, we would re-implement the C++ bodies of TorchVision in C# -- that would solve a lot of problems. |
@xhuan8 -- would that be feasible, do you think? To just re-implement the ops in C# using Torch operators, like how nms() was implemented? |
@NiklasGustafsson It takes time to implement with C# and verify the correctness, and also not sure how is the performace without cuda. |
If the ops are implemented in terms of TorchSharp ops, CUDA should come for free. That name is a C++ mangled name, which means that it's missing the 'extern "C"' declaration. |
Same as I asked about Faster RCNN -- you've been working on this, it appears. Anything ready for a PR? |
@NiklasGustafsson |
Is there any plan to add classes of torchvision/ops?
roi_align and boxes are required, they are not implemented in TorchSharp
The text was updated successfully, but these errors were encountered: