Using tensorflow.js from C++ via Emscripten

158 views
Skip to first unread message

Jim Lloyd

unread,
Feb 24, 2021, 6:16:02 PM2/24/21
to TensorFlow.js Discussion

I have a moderately large library of C++ code that uses the tensorflow_cc API. I have just started working with Emscripten/emcc and am excited by the potential to port my application to run in node.js using tensorflow.js.

I want to refactor my C++ code so that most of it can be agnostic as to which Tensorflow backend is in use. I expect that this will be done by abstracting Tensor and Model.

Is there a C++ interface to the tensorflow.js API?

To be clear, the Javascript API looks great. I have already confirmed that I can convert my SavedModel format models using tensorflowjs_converter. I am just looking for a clean way to use both of the tensorflow_cc and tensorflow.js backends from my predominantly C++ codebase with a relatively small amount of glue code.

Thanks,

Jim Lloyd

(also posted to stackoverflow)


Jim Lloyd

unread,
Mar 6, 2021, 3:20:47 PM3/6/21
to TensorFlow.js Discussion
I was not able to find the C++ interface that I was looking for, but I did figure out how to call Tensforflow.js from C++. My first crude but working code is available at this gist.

--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfjs/b2be4ffb-b671-4b0d-b909-9490d6dbb56an%40tensorflow.org.

Jason Mayes

unread,
Mar 8, 2021, 11:44:43 AM3/8/21
to Jim Lloyd, TensorFlow.js Discussion
Thanks for sharing your findings Jim.



--




     
  •  Jason Mayes
  •  Senior Developer Relations Engineer, TensorFlow.js
  •  Google
     Follow me or get inspired: #MadeWithTFJS demos on YouTube

   

This email may be confidential and privileged. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.


Reply all
Reply to author
Forward
0 new messages