Giter Club home page Giter Club logo

Comments (3)

LaurentMazare avatar LaurentMazare commented on May 30, 2024 2

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 the Declarations.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.

LaurentMazare avatar LaurentMazare commented on May 30, 2024 1

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.

ehsanmok avatar ehsanmok commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.