Giter Site home page Giter Site logo

ffi-experimental's Introduction

Hasktorch 0.2 Libtorch FFI

Work on ffi bindings into the c++ libtorch library in preparation for 0.2 which targets the pytorch's post 1.0libtorch backend.

General approach is to use generated Declarations.yaml spec instead of header parsing for code generation.

Project Structure

  • codegen/ - code generation, parses Declarations.yaml spec from pytorch and produces ffi/ contents
  • deps/ - submodules for dependencies - libtorch, mklml, pytorch
  • examples/ - high level example models (xor mlp, typed cnn)
  • ffi/- low level FFI bindings to libtorch
  • hasktorch/ - higher level user-facing library, calls into ffi/, used by examples/
  • inline-c/ - submodule to inline-cpp fork used for C++ FFI
  • spec/ - specification files used for codegen/

Getting dependencies

deps/ holds several external dependencies that are retrieved using the deps/get-deps.sh script.

This should be run prior to building

XOR MLP Example

The following steps should run the xor mlp example:

# Download libtorch-binary and other shared library dependencies
pushd deps
# For CPU
./get-deps.sh
# For CUDA-9
# ./get-deps.sh -a cu90
# For CUDA-10
# ./get-deps.sh -a cu100
popd

# Set shared library environment variables
source setenv

stack build examples

stack exec xor_mlp

Running code generation

Code generation is used to build low-level FFI functions.

Note that the code is already generated in this repo under ffi, running this is only needed if changes are being made to the code generation process.

To run:

stack build codegen
stack exec codegen-exe

To get CLI options:

stack exec codegen-exe -- --help

Additional Information

See the wiki for developer information.

Contributions

Contributions/PRs are welcome.

ffi-experimental's People

Contributors

adlucem avatar apaszke avatar austinvhuang avatar junjihashimoto avatar

Watchers

 avatar

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.