clarkmcc / tensorflow-inference-go

Running TensorFlow model inference in pure Go using Rust WebAssembly

Home Page:https://www.clarkmccauley.com/blog/tensorflow-rust-go-an-unholy-union

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running TensorFlow Models Natively in Go

This project is an example of building and training a Tensorflow model, manually porting it to Rust using candle, compiling the Rust to WebAssembly, and running the WebAssembly module from Go using Scale.

The following files are included:

Running the Example

$ go run main.go
Successfully classified the digit 0 in 1.357ms
Successfully classified the digit 1 in 618.541µs
Successfully classified the digit 2 in 607.417µs
Successfully classified the digit 3 in 636.5µs
Successfully classified the digit 4 in 622.291µs
Successfully classified the digit 5 in 638.375µs
Successfully classified the digit 6 in 666.25µs
Successfully classified the digit 7 in 647.791µs
Successfully classified the digit 8 in 614.666µs
Successfully classified the digit 9 in 608.333µs

Developing

Make sure you have Scale installed.

$ curl -fsSL https://dl.scale.sh | sh

Any changes to the Rust code, or the signature need to be re-compiled to WebAssembly. Run the following to re-generate all the signatures and compile the Rust code to WebAssembly.

$ make generate

About

Running TensorFlow model inference in pure Go using Rust WebAssembly

https://www.clarkmccauley.com/blog/tensorflow-rust-go-an-unholy-union


Languages

Language:Jupyter Notebook 46.5%Language:Rust 44.3%Language:Go 7.9%Language:Makefile 1.3%