-
Notifications
You must be signed in to change notification settings - Fork 143
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
How can I use a model built with the TorchSparse library in C++? #197
Comments
This is not yet supported. Could you kindly let us know your use case? Thanks! |
Hi, Usecases:
Usage Workflow:
TODOS:
So far I managed the first part, it was quite straightforward, replaces the int parameters of the functions with int64_t and float with double. I'm trying out the second phase now, not sure how it will end up. If someone is interested I can open PRs for each part. |
Small update, Timing:With the examples/example.py I got 1.5-2x speed difference in C++ inference (jit exported) Vs Python (with and without JIT). I expect even further improvements with torchsparse 2.1 algorithms. What had to be done:
Once all this was accomplished, the shared object can be loaded to a C++ program with dlopen or link against it and then load the exported JIT compiled model. |
looking foward for your work |
Any update or work-in-progress branch? I am interested in this feature as well. |
Is there any update? |
Hi, My apologies for the late reply. I managed to get the conversion to work by following the recipe I shared above. However, I'm unable to share that implementation due to reasons. Furthermore, I realised this needed some fundamental changes in the library implementation and should better be done with the coordination of the original authors. Quick startThe process requires the previously mentioned steps. Most crucially:
Results:
RetrospectionI'm not 100% sure if TorchScript is the way to go for this. On one hand, it required significant changes to the codebase, also it was rather intrusive. An alternative I am considering is to convert to ONNX via Torch Dynamo backend (which uses FX tracing -> different set of constraints) and mark the torchscript ops as custom ops. Then the runtime (i.e. TensorRT) can load them as a plugin. Both approaches (torchscript and TensorRT) has their advantages and drawbacks. Both will also need significant changes of the library itself. If there is any more interest, we can start breaking this down to small parts and get it up :) |
Is there an existing issue for this?
Have you followed all the steps in the FAQ?
Current Behavior
I want to build and infer in C++ a Torchsparse model trained in Python.
How do I do this?
I know that when downsampling and upsampling are mixed in Sparse Convolution, the graph cannot be traced using torch.jit.trace.
Error Line
No error lines.
Environment
Full Error Log
No response
The text was updated successfully, but these errors were encountered: