This library implements the C TensorFlow API adapted for the Scala Native platform.
Scala Native is a unique platform that marries the high level language of Scala but compiles to native code with a lightweight managed runtime which includes a state of the art garbage collector. The combination allows for great programming and the ability to use high performance C language libraries like TensorFlow.
Scala Native uses the Scala compiler to produce NIR (Native Intermediate Representation) that is optimized and then converted to LLVM IR. Finally LLVM code is optimized and compiled by Clang to produce a native executable.
If you are already familiar with Scala Native you can jump right in by adding the following dependency in your
sbt build file.
libraryDependencies += "org.ekrich" %%% "stensorflow" % "x.y.z"
To use in
x.y.z with the version from Maven Central badge above.
All available versions can be seen at the Maven Repository.
Otherwise follow the Getting Started instructions for Scala Native if you are not already setup.
The TensorFlow C library is required and the current version is
Essentially do the following for this platform and version:
$ curl -fsSL https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.7.0.tar.gz \ | tar -xz -C /usr/local
Note: macOS Catalina 10.15.x or greater is required to install TensorFlow via Homebrew although the CI seems to work with 10.14.
$ brew install libtensorflow
libtensorflowavailable on the system.
Reference the link above for Scaladoc. The documentation is a little sparse but hopefully will improve with time.
sbt is installed and any other Scala Native prerequisites are met you can use the following Gitter G8 template instructions to get a fully functional Scala Native application with an example in the body of the main program.
$ sbt new ekrich/stensorflow.g8 $ cd <directory entered after the prompt> $ sbt run
In addition, look at the stensorflow unit tests for other examples of usage.