Skip to content


Repository files navigation

WasmEdge for Tensorflow Extension (WILL BE DEPRECATED SOON)

The WasmEdge extension will be deprecated soon and be replaced by the WasmEdge-Tensorflow plug-in and the WasmEdge-TensorflowLite plug-in.

The WasmEdge is a high performance WebAssembly runtime optimized for server side applications. This project provides support for accessing with Tensorflow C library.

Getting Started


The WasmEdge Tensorflow shared library and are provided for the WasmEdge-Tensorflow extension of the WasmEdge shared library. The WasmEdge Tensorflow static library libwasmedgeHostModuleWasmEdgeTensorflow.a and libwasmedgeHostModuleWasmEdgeTensorflowLite.a are provided for statical linking when building executables with CMake. When linking with and libwasmedgeHostModuleWasmEdgeTensorflow.a, the TensorFlow shared libraries and are required. When linking with and libwasmedgeHostModuleWasmEdgeTensorflowLite.a, the TensorFlow-Lite shared library is required.

The official TensorFlow release only provide the TensorFlow shared library. You can download and install the pre-built shared libraries:

tar -zxvf WasmEdge-tensorflow-deps-TF-0.12.1-manylinux2014_x86_64.tar.gz
rm -f WasmEdge-tensorflow-deps-TF-0.12.1-manylinux2014_x86_64.tar.gz
ln -sf
ln -sf
ln -sf
ln -sf
tar -zxvf WasmEdge-tensorflow-deps-TFLite-0.12.1-manylinux2014_x86_64.tar.gz
rm -f WasmEdge-tensorflow-deps-TFLite-0.12.1-manylinux2014_x86_64.tar.gz

Prepare the environment

Use our docker image (Recommanded)

Our docker image is based on ubuntu 20.04.

docker pull wasmedge/wasmedge

Or setup the environment manually

Please notice that WasmEdge-Tensorflow requires cmake>=3.11 and libboost>=1.68.

# Tools and libraries
sudo apt install -y \
    software-properties-common \
    cmake \

# WasmEdge supports both clang++ and g++ compilers
# You can choose one of them for building this project
sudo apt install -y gcc g++
sudo apt install -y clang

Get WasmEdge-Tensorflow Source Code

git clone --recursive
cd WasmEdge-tensorflow
git checkout 0.12.1

Build WasmEdge-Tensorflow

WasmEdge-Tensorflow depends on WasmEdge-Core, you have to prepare WasmEdge-Core before you build WasmEdge-Tensorflow. We provides two options for setting up the WasmEdge-Core:

Create and Enter the Build Folder

# After pulling our WasmEdge docker image
docker run -it --rm \
    -v <path/to/your/WasmEdge-tensorflow/source/folder>:/root/WasmEdge-tensorflow \
# In docker
cd /root/WasmEdge-tensorflow
mkdir -p build && cd build

Option 1. Use built-in CMakeLists to get WasmEdge-Core (Recommended)

# In docker
cmake -DCMAKE_BUILD_TYPE=Release .. && make

Option 2. Use specific version of WasmEdge-Core by giving WASMEDGE_CORE_PATH

# In docker
cmake -DWASMEDGE_CORE_PATH=<path/to/WasmEdge/source> -DCMAKE_BUILD_TYPE=Release .. && make

The shared library build/lib/ is the C API to create the wasmedge-tensorflow import object. The header build/include/wasmedge-tensorflow.h is the header of the shared library. The shared library build/lib/ is the C API to create the wasmedge-tensorflowlite import object. The header build/include/wasmedge-tensorflowlite.h is the header of the shared library. The static library build/lib/libwasmedgeHostModuleWasmEdgeTensorflow.a is for executables linking in CMake. The static library build/lib/libwasmedgeHostModuleWasmEdgeTensorflowLite.a is for executables linking in CMake.

WasmEdge-Tensorflow Tools

The tools is moved to the new repository.