Comments (3)
tch-rs/gen/gen.ml
generates:
- The C wrapper around the libtorch C++ api,
libtch/torch_api_generated.{cpp.h,.h}
. - The rust wrapper using this C api,
src/tensor/c_wrapper_generated.rs
.
It uses theDeclarations.yaml
file generated when compiling libtorch from source.
The generated files are also stored in git so there is no need to run this code generation in the normal build process.
It's only useful to execute it when updating to a new major libtorch version but this is rather infrequent (there was no need to rerun it between 1.0.0 and 1.0.1).
The code generation is in ocaml as it's adapted from the ocaml-torch bindings. To run it you will need a working ocaml install including the dune, base, stdio, and yaml packages, the Declarations.yaml
file and you could run dune exec gen/gen.exe
.
Binding to the library directly would be a bit tricky: it's in C++ so bindgen does not work very well, writing manual wrappers is a bit of a pain as there are more than a thousand functions to expose.
from tch-rs.
With the current release cycle of PyTorch, I hope for that not to be necessary.
However if this becomes a concern, we could certainly consider generating the code in the build process at some point.
from tch-rs.
Very interesting! thanks for the clarifications. Absolutely makes sense to reuse what you've made before.
Would it be able to support more than one major libtorch versions at the same time (in the future)?
from tch-rs.
Related Issues (20)
- Not All Objects are Loaded on GPU for CModule
- error while loading shared libraries: libtorch_cuda.so not found HOT 2
- Fallible Modules
- Increase timeout for `torch-sys` build script download. HOT 1
- `.pt` format is supported by `VarStore::load` but not by `VarStore::save`
- product() equivalent to sum() to create tensor from iterator ?
- torchvision bindings HOT 1
- Converting tch::Tensor to Python Object leads to panic. HOT 4
- pyo3 and windows 11: HOT 1
- Tried to register multiple backend fallbacks for the same dispatch key Conjugate HOT 1
- Is it possible to load weights from VarStore even after applying some operations?
- `try_from` ndarray to tensor using zero copy
- Workflows error when trying to build torch-sys without venv, "torch module not found" HOT 2
- Confusing warning emitted from `Tensor::scatter_reduce`.
- SDPA Flash kernel HOT 6
- when compile with tokenizers library , encounter static libcpmt.lib and dynamic msvcprt.lib conflict link error
- Load model once and run inference across threads?
- Build fails unless I downgrade `google-glog` to 0.6.0. HOT 5
- Copying Scalars from Torch to Rust? HOT 1
- Second-order utils ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tch-rs.