Skip to content

Java interface #5

Description

@ravwojdyla

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!

Activity

  1. girving commented on Nov 9, 2015

    @girving
    Contributor

    Nice!

  2. girving commented on Nov 9, 2015

    @girving
    Contributor

    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.

  3. pslam commented on Nov 18, 2015

    @pslam

    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 that

  4. kylevedder commented on Nov 22, 2015

    @kylevedder

    Hello,
    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.

  5. bhack commented on Nov 22, 2015

    @bhack
    Contributor

    There are javacpp preset available for libiraries like Caffe and OpenCV. See also bytedeco/javacpp-presets#111. Java-cpp enable also IOS with RoboVM

  6. bhack commented on Nov 22, 2015

    @bhack
    Contributor
  7. bhack commented on Nov 22, 2015

    @bhack
    Contributor
  8. ravwojdyla commented on Nov 22, 2015

    @ravwojdyla
    Author

    @pslam - I was able to work just a little bit on this - could definitely use some help!

  9. saudet commented on Nov 23, 2015

    @saudet

    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!)

  10. kylevedder commented on Nov 23, 2015

    @kylevedder

    Very 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.

  11. tngan commented on Nov 23, 2015

    @tngan

    Hi @kylevedder, have you resolved the issue related to error_codes.pb.h ?
    [Edited]
    All .pb.h files are compiled from .proto

  12. kylevedder commented on Nov 23, 2015

    @kylevedder

    @tngan Yes, that is what I discovered as well. Additionally, the .proto files 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 .proto files into .h and .cc files; doing each folder piecemeal results in failures due to unsatisfied dependencies upon other yet to be compiled .proto files.

  13. davidzchen commented on Nov 24, 2015

    @davidzchen
    Contributor

    @kylevedder Are your SWIG wrappers in a separate repository or are you working in the tensorflow repository? protoc works 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.

  14. kylevedder commented on Nov 24, 2015

    @kylevedder

    @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 .whl file, which I then handed over to pip and 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 .so file 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 .so file; however, the .proto files need to first be expanded into .hs and .ccs prior to this compilation, and that is what I am trying to do with protoc.

    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 protoc has been directory by directory and, consequently, not in the script.

    Finally, any feedback on areas of improvement would be greatly appreciated. Thanks!

  15. 160 remaining items

  16. added 7 commits that reference this issue on Apr 9, 2025
  17. added 2 commits that reference this issue on Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions