tensorflow / tensorflow

An Open Source Machine Learning Framework for Everyone

Home Page:https://tensorflow.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rust API

adamcrume opened this issue · comments

TensorFlow should have a Rust interface.

Original e-mail:
I'd like to write Rust bindings for TensorFlow, and I had a few questions. First of all, is anyone already working on this, and if so, can I lend a hand? If not, is this something the TensorFlow team would be interested in? I assume that the TensorFlow team would not be willing to commit right now to supporting Rust, so I thought a separate open source project (with the option to fold into the main project later) would be the way to go.

Moving email discussion here:

Rust bindings would be cool! I don't think there's anyone working on rust bindings so far, though it might be worth an email to discuss@tensorflow.org to check. Agreed that a separate project is probably good to start out.

To start the conversation, there are a couple different levels of bindings:

  1. Bindings that do not know about specific ops, but can create graphs "manually" or load them from GraphDefs, evaluate graphs (so that tensorflow models can be run inside rust servers), etc. There's hopefully nothing blocking that.
  2. Autogenerated bindings for each C++ op. We do this for Python, and similar things should work for Rust (ideally with a lot more type safety). I have limited intuition for rust's handling of ad-hoc polymorphism, so I can't judge how easy it'll be to fit tensorflow's notions of polymorphism into rust's. Again, there's hopefully nothing blocking this.
  3. Idiomatic bindings. We currently have a lot of logic in pure Python, including both per-op sugar and key features such as automatic differentiation. We will likely eventually move this to C++, but until then it will be difficult to capture this functionality in rust bindings without duplicating a ton of effort. Unfortunately, automatic differentiation in particular is (mostly) necessary if you want to train models.

It's probably best to shoot for (1) to start and only move to (2) once it's clear how much of (3) will be a blocker for the desired applications.

FWIW, getting something like 1) is pretty straightforward with rust-bindgen and tensor_c_api.h, I put something together the other weekend in https://github.com/ajtulloch/tensorflow-rs/blob/master/src/tf.rs if that's useful.

I would be glad to work on a Rust interface for TensorFlow if nobody is currently working on a solution.

I just launched a project to provide the Rust bindings at https://github.com/google/tensorflow-rust. The build glue is there, but most of the bindings have yet to be written.

Nice! I'm happy to help with any issues you run into.

Cool!

It seems that the Rust bindings are building on top of c_api.h using the approach outlined in the how-to, which is great.

If you run into concerns with the documentation or the C-API, please do create a separate issue

Thanks!

Closing this issue. The Rust bindings have been moved to github.com/tensorflow/rust