Java, Machine Learning & AI

What is project Panama and why is it important for Machine Learning on Java Platform

Panama is the new API  for interconnecting Java with native code, which provides Java the ability for faster and easier communication with native libraries required for machine learning applications. The vision is that non-java libraries should be easily accessible to Java developers
Very good and easy to follow overview given at the session at Oracle Code One conference. Some of the main points:

Some problems with current JNI approach

  • No support for off heap data (only DYI solutions Unsafe, ByteBuffer)
  • No JIT optimizations
  • Requires writing and building native code
  • Maintaining JNI bindings can be big overhead

Why is Panama better

  • No native methods like in JNI. Panama uses interfaces with annotations
  • Rich API for off-heap data
  • Allows JIT compiler optimizations
  • Support for native arrays with Array<X>
  • Callbacks for communication between Java and native code
  • Jextract tool for automaticly generating interfaces from header files for specific native library (Tested with Tensorflow, Open CL)
  • Reduces 90% of the work required for creating Java bindings for native libraries
  • 4-5 time faster then JNI with link to native (experimental)
    faster then official Java bindings for Tensorflow

TODO

  • still needs work to be done on optimizing upcalls back to java (10x more expensive than JNI at the moment )

More: https://openjdk.java.net/projects/panama/