Repository navigation
Java interface #5
Description
Activity
Nice!
Moving this comment here from #3:
There's a testsuite with fairly good converge, but currently it's mostly Python with a few C++ tests. There's also a lot of functionality for building graphs that's currently Python only, in particular the automatic differentiation functionality, though that doesn't matter for evaluation of graphs in Java. There are plans to move this functionality into the underlying C++ in future, at which point Java SWIG bindings would be more useful for creating graphs.
If someone takes up the Java SWIG challenge, we'd be happy to accept it upstream pending review, etc., at which point it would be part of our continuous testing. The details of accepting contributions is in flux at the moment, but that will stabilize.
Hello guys
We are also interested in adapting TensorFlow for Java. @ravwojdyla Have you, by any chance, started working on the Swig Interface for Java? If you have, we could join our efforts and collaborate on thatReacted by levonk, Xiong Jun Wu(熊君武), dripp1, Kirill Zotov and Wenbo TianHello,
I am working on a SWIG wrap of the main C++ API. You can see my progress thus far on my fork, but what's up there is not finished; I'm currently experiencing a problem in which#include "tensorflow/core/lib/core/error_codes.pb.h"is unable to be resolved and I cannot find the intended file anywhere within the project files. Input of any kind would be greatly appreciated.There are javacpp preset available for libiraries like Caffe and OpenCV. See also bytedeco/javacpp-presets#111. Java-cpp enable also IOS with RoboVM
@girving Initial commit at bytedeco/javacpp-presets@374e1d5
/cc @saudet
@pslam - I was able to work just a little bit on this - could definitely use some help!
Hi guys, I believe I have pretty functional bindings for JavaCPP: https://github.com/bytedeco/javacpp-presets/tree/master/tensorflow. Let me know if you see anything that could be done with SWIG, but not JavaCPP. I could definitely use the feedback. (Thanks for the cc @bhack!)
Reacted by Fabrizio Milo, Andre Pemmelaar, Jiecheng Z and Henry SaputraReacted by Jiecheng Z and Henry SaputraVery nicely done @saudet! I have almost finished a SWIG wrap, but it seems that your implementation works just as well. I do not see anything that my SWIG wrap can do that yours cannot do. JavaCPP seems very cool, I'll have to look into using it for future projects.
Hi @kylevedder, have you resolved the issue related to
error_codes.pb.h?
[Edited]
All .pb.h files are compiled from .proto@tngan Yes, that is what I discovered as well. Additionally, the
.protofiles in this project require ProtoBuff3 to be used. I'm using Ubuntu 14.04 and ProtoBuff3 was not available in my package manager, so I compiled it from source, which I got from the 3.0.0 beta release.The current roadblock which I am trying to solve is how to get ProtoBuff to recurse over the entire file tree and compile the
.protofiles into.hand.ccfiles; doing each folder piecemeal results in failures due to unsatisfied dependencies upon other yet to be compiled.protofiles.@kylevedder Are your SWIG wrappers in a separate repository or are you working in the tensorflow repository?
protocworks similar to other compilers. If you are working in the tensorflow repository or are using Bazel, then you would need to set up the protobuf build targets and the dependencies among them.If you are working in a separate repository and using a different build system, then you would need to use the protobuf plugin for that build system.
I'd be happy to help you set up the build if you would like.
@davidzchen Thank you for the offer, any and all help is greatly appreciated.
What I have thus far:
I have already setup Bazel and gotten it to compile into a
.whlfile, which I then handed over topipand confirmed that I can run the First TensorFlow program.I have generated SWIG wrapper files in my forked repository. They are in a folder under
core/javaWrapper. [link]What I am trying to do:
Ultimately, my goal is to generate a
.sofile which than can be called as a native library in Java. Currently, I'm attempting to use g++ to compile the entire system into a.sofile; however, the.protofiles need to first be expanded into.hs and.ccs prior to this compilation, and that is what I am trying to do withprotoc.You can see my attempt at a wrap script here to potentially get a better idea of what it is I am getting at, although thus far all of my attempts at using
protochas been directory by directory and, consequently, not in the script.Finally, any feedback on areas of improvement would be greatly appreciated. Thanks!
160 remaining items
Load more actions- added 7 commits that reference this issue
on Apr 9, 2025 - added 5 commits that reference this issue
on Jul 28, 2025 - added a commit that references this issue
on Nov 26, 2025
Issue to trace effort of swig interface for java. Started implementation - will update with progress. If anyone has any comments/tips - please feel welcome to join the discussion!