Once we switch to LLVM 3.7.1
<https://github.com/JuliaLang/julia/issues/9336>, it will no longer require
a special build of Julia to use Cxx.jl. That is one of the reasons why that
issue is a high priority – a lot of work has gone into is lately and it
should happen in a few weeks. Once LLVM 3.7.1 proves stable on master, we
could even potentially backport the change to release-0.4 so that you can
use Cxx with 0.4 out of the box.

Regarding using TensorFlow from languages other than Python, Keno and Tony
have looked into this in some depth and here's what they found. At first
glance TensorFlow's Python interface follows the design pattern that lots
of high quality interfaces to C++ do, which is the following:

user Python code ⟺
handwritten python API ⟺
SWIG Python API ⟺
C++ code


However, if you look a bit closer, it's actually the following:

user Python code ⟺
handwritten python API ⟺
ProtoBuf generated serialization format ⟺
SWIG generated Python API ⟺
Hand Written C++ Interface ⟺
(ProtoBuf if parsing ⟺)
C++ code


The interaction is considerably more involved than might be naively
imagined. This design resembles LLVM’s approach of having a well-defined,
serializable intermediate format, to serve as a stable interface between
high-level code and low-level computational libraries and regression tests.
However, the downside is that each high-level language has to implement its
own version of this. In Julia we have both PyCall and Cxx, so we can easily
interact with and reuse either the Python one or the C++ one.

So the suggestion on TensorFlow’s website that having SWIG support alone
will immediately make it possible to use TensorFlow from various languages
appears to be somewhat misleading: SWIG is only used to wrap ~20 functions
which have a simple C interface. If you look at the TensorFlow source,
you'll see that there's about a 2:1 ratio of C++ to Python code, so in its
current incarnation, using TensorFlow from any language *without* Python
seems unlikely. Given that you can't use TensorFlow without Python, Julia
is in a good position since it's very good at talking to both Python and
C++.


On Mon, Dec 14, 2015 at 2:17 PM, Phil Tomson <[email protected]> wrote:

> TensorFlow is written in C++ and they use SWIG to generate wrappers for
> Python. There is no Julia target for SWIG, but looking at some discussions
> here seems to indicate that SWIG for Julia is kind of pointless given that
> things like Cxx.jl exist.
>
> However, Cxx.jl requires special dev versions of both Julia and LLVM so
> it's not an "out of the box" experience just yet.
>
> There was a thread on TensorFlow here a few weeks back, I'm wondering if
> anyone was was working on Julia/TensorFlow interoperability?
>
> Are there alternatives to Cxx.jl for this kind of thing? Will Cxx.jl ever
> be at the point where we can use it with a standard release of Julia?
>
> Phil
>

Reply via email to