Giter VIP home page Giter VIP logo

tensorflow-android-cpp's Introduction

TensorFlow Inference (cross platform \ shared library)

Description

A C++ library for running a Tensorflow compute graph (run directly, no need for JNI as in libtensorflow_inference.so), both on desktop machines and on Android. Compilation extensively tested on Ubuntu 18.04.1 with Tensorflow release 1.9, Bazel 0.16.1.

Instructions

  1. Create the following directory: tf_source/tensorflow/tensorflow/tools/tfwld. Place all files (except precompiled .so file and WORKSPACE) inside.
  2. Place WORKSPACE file in tf_source/tensorflow. Note the NDK definitions (install location etc.) at the bottom of the file.
  3. Make sure all installations are properly functioning (Tensorflow, Bazel, Clang, NDK).
  4. Change path in BUILD file to the correct path of --version-script (this path points to the file named TensorflowInference.lds)
  5. Open command prompt from tf_source/tensorflow
  6. Run command below

Build

On Android:

(0) Refer to https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android to edit the WORKSPACE to configure the android NDK/SDK.

(1) build command:

bazel build -c opt --copt="-fPIC" --cxxopt='-std=c++11' --crosstool_top=//external:android/crosstool --cpu=arm64-v8a --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --config monolithic tensorflow/tools/tfwld:libTensorflowInference.so

On PC:

bazel build -c opt --copt="-fPIC" --cxxopt='-std=c++11' tensorflow/tools/tfwld:libTensorflowInference.so --verbose_failures

Note - This project is based on the Tensorflow benchmark tool. Compiled library is also available for download (arm-v8a). Check out https://getmudra.com in order to see why this project was born ...

For more info see my blog https://medium.com/@leeor.langer/tensorflow-c-api-for-android-a0c55fe226e8.

tensorflow-android-cpp's People

Contributors

leeor-langer 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.