Skip to content

Commit 6adcdfb

Browse files
authored
Fix the title in contribute pages. (#138)
Signed-off-by: YiYing He <yiying@secondstate.io>
1 parent aba39b7 commit 6adcdfb

File tree

18 files changed

+290
-32
lines changed

18 files changed

+290
-32
lines changed

docs/contribute/source/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"position": 2,
44
"link": {
55
"type": "generated-index",
6-
"description": "we will learn how to the WasmEdge Plugin System."
6+
"description": "Here's the guides for building WasmEdge and its plug-ins from source on various platforms."
77
}
88
}

docs/contribute/source/build_from_src.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
sidebar_position: 1
33
---
44

5-
# Build WasmEdge from source
5+
# Build Guide
66

77
Please follow this guide to build and test WasmEdge from the source code.
88

docs/contribute/source/docker.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Developers can use the `docker pull wasmedge/wasmedge:{tag_name}` command to pul
1212

1313
| tag name | arch | based operating system | LLVM version | ENVs | compatibility | comments |
1414
| --- | --- | --- | --- | --- | --- | --- |
15-
| `latest` | x86_64 | Ubuntu 20.04 LTS | 12.0.0 | CC=clang, CXX=clang++ | Ubuntu 20.04+ | This is for CI, will always use the latest Ubuntu LTS release |
16-
| `ubuntu-build-gcc` | x86_64 | Ubuntu 20.04 LTS | 12.0.0 | CC=gcc, CXX=g++ | Ubuntu 20.04+ | This is for CI, will always use the latest Ubuntu LTS release |
17-
| `ubuntu-build-clang` | x86_64 | Ubuntu 20.04 LTS | 12.0.0 | CC=clang, CXX=clang++ | Ubuntu 20.04+ | This is for CI, will always use the latest Ubuntu LTS release |
15+
| `latest` | x86_64 | Ubuntu 22.04 LTS | 15.0.7 | CC=clang, CXX=clang++ | Ubuntu 22.04+ | This is for CI, will always use the latest Ubuntu LTS release |
16+
| `ubuntu-build-gcc` | x86_64 | Ubuntu 22.04 LTS | 15.0.7 | CC=gcc, CXX=g++ | Ubuntu 22.04+ | This is for CI, will always use the latest Ubuntu LTS release |
17+
| `ubuntu-build-clang` | x86_64 | Ubuntu 22.04 LTS | 15.0.7 | CC=clang, CXX=clang++ | Ubuntu 22.04+ | This is for CI, will always use the latest Ubuntu LTS release |
1818
| `ubuntu2004_x86_64` | x86_64 | Ubuntu 20.04 LTS | 10.0.0 | CC=gcc, CXX=g++ | Ubuntu 20.04+ | This is for developers who familiar with Ubuntu 20.04 LTS release |
1919
| `ubuntu2104_armv7l` | armhf | Ubuntu 21.04 | 12.0.0 | CC=gcc, CXX=g++ | Ubuntu 21.04+ | This is for armhf release |
20-
| `manylinux2014_x86_64` | x86_64 | CentOS 7, 7.9.2009 | 12.0.0 | CC=gcc, CXX=g++ | Ubuntu 16.04+, CentOS 7+ | This is for developers who familiar with CentOS on x86_64 architecture |
21-
| `manylinux2014_aarch64` | aarch64 | CentOS 7, 7.9.2009 | 12.0.0 | CC=gcc, CXX=g++ | Ubuntu 16.04+, CentOS 7+ | This is for developers who familiar with CentOS on aarch64 architecture |
20+
| `manylinux2014_x86_64` | x86_64 | CentOS 7, 7.9.2009 | 16.0.5 | CC=gcc, CXX=g++ | Ubuntu 16.04+, CentOS 7+ | This is for developers who familiar with CentOS on x86_64 architecture |
21+
| `manylinux2014_aarch64` | aarch64 | CentOS 7, 7.9.2009 | 16.0.5 | CC=gcc, CXX=g++ | Ubuntu 16.04+, CentOS 7+ | This is for developers who familiar with CentOS on aarch64 architecture |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"label": "Build WasmEdge",
2+
"label": "Supported Platforms",
33
"position": 3,
44
"link": {
55
"type": "generated-index",
6-
"description": "we will learn how to build WasmEdge from source on different OSes."
6+
"description": "We will learn how to build WasmEdge from source on different platfroms."
77
}
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"label": "WasmEdge Plugin",
2+
"label": "Build Plug-ins",
33
"position": 4,
44
"link": {
55
"type": "generated-index",
6-
"description": "In this chapter, we will learn how to build WasmEdge Plugins from source"
6+
"description": "In this chapter, we will learn how to build WasmEdge plug-ins from source."
77
}
88
}

docs/develop/rust/command.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Application developers for WasmEdge can use our Rust interface crate to access t
1717

1818
```toml
1919
[dependencies]
20-
rust_process_interface_library = "0.1.3"
20+
wasmedge_process_interface = "0.2.1"
2121
```
2222

2323
In the Rust application, you can now use the API methods to start a new process for the operating system command program, pass in arguments via the `arg()` method as well as via the `STDIN`, and receives the return values via the `STDOUT`.

docs/develop/rust/hello_world.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_position: 2
44

55
# Hello world
66

7-
Before we start, make sure [you have Rust and WasmEdge installed](setup).
7+
Before we start, make sure [you have Rust and WasmEdge installed](setup.md).
88

99
## A simple main app
1010

docs/develop/rust/tensorflow.md

Lines changed: 130 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,133 @@ sidebar_position: 7
44

55
# TensorFlow Interface
66

7-
WIP
7+
Developers can use [WASI-NN](/category/neural-networks-for-wasi) to inference the models. However, for the TensorFlow and TensorFlow-Lite users, the WASI-NN APIs are not so friendly to retrieve the input and output tensors. Therefore WasmEdge provides the TensorFlow related plug-in and rust SDK for inferencing models in WASM.
8+
9+
## Prerequisite
10+
11+
Please make sure that you [Rust and WasmEdge installed](setup.md).
12+
13+
Developers will add the [`wasmedge_tensorflow_interface` crate](https://crates.io/crates/wasmedge_tensorflow_interface) as a dependency to their `Rust -> Wasm` applications. For example, add the following line to the application's `Cargo.toml` file.
14+
15+
```toml
16+
[dependencies]
17+
wasmedge_tensorflow_interface = "0.3.0"
18+
```
19+
20+
Developers will bring the functions of `wasmedge_tensorflow_interface` into scope within their `Rust -> Wasm` application's code. For example, adding the following code to the top of their `main.rs`
21+
22+
```rust
23+
use wasmedge_tensorflow_interface;
24+
```
25+
26+
## Image Loading And Conversion
27+
28+
In this crate, we provide several functions to decode and convert images into tensors by using the `WasmEdge-Image` host functions.
29+
30+
For using these funcions in WASM and executing in WasmEdge, users should [install WasmEdge with WasmEdge-Image plug-in](../../start/install.md#wasmedge-image-plug-in).
31+
32+
For decoding the `JPEG` images, there are:
33+
34+
```rust
35+
// Function to decode JPEG from buffer and resize to RGB8 format.
36+
pub fn load_jpg_image_to_rgb8(img_buf: &[u8], w: u32, h: u32) -> Vec<u8>
37+
// Function to decode JPEG from buffer and resize to BGR8 format.
38+
pub fn load_jpg_image_to_bgr8(img_buf: &[u8], w: u32, h: u32) -> Vec<u8>
39+
// Function to decode JPEG from buffer and resize to RGB32F format.
40+
pub fn load_jpg_image_to_rgb32f(img_buf: &[u8], w: u32, h: u32) -> Vec<f32>
41+
// Function to decode JPEG from buffer and resize to BGR32F format.
42+
pub fn load_jpg_image_to_rgb32f(img_buf: &[u8], w: u32, h: u32) -> Vec<f32>
43+
```
44+
45+
For decoding the `PNG` images, there are:
46+
47+
```rust
48+
// Function to decode PNG from buffer and resize to RGB8 format.
49+
pub fn load_png_image_to_rgb8(img_buf: &[u8], w: u32, h: u32) -> Vec<u8>
50+
// Function to decode PNG from buffer and resize to BGR8 format.
51+
pub fn load_png_image_to_bgr8(img_buf: &[u8], w: u32, h: u32) -> Vec<u8>
52+
// Function to decode PNG from buffer and resize to RGB32F format.
53+
pub fn load_png_image_to_rgb32f(img_buf: &[u8], w: u32, h: u32) -> Vec<f32>
54+
// Function to decode PNG from buffer and resize to BGR32F format.
55+
pub fn load_png_image_to_rgb32f(img_buf: &[u8], w: u32, h: u32) -> Vec<f32>
56+
```
57+
58+
Developers can load, decode, and resize image as following:
59+
60+
```rust
61+
let mut file_img = File::open("sample.jpg").unwrap();
62+
let mut img_buf = Vec::new();
63+
file_img.read_to_end(&mut img_buf).unwrap();
64+
let flat_img = wasmedge_tensorflow_interface::load_jpg_image_to_rgb32f(&img_buf, 224, 224);
65+
// The flat_img is a vec<f32> which contains normalized image in rgb32f format and resized to 224x224.
66+
```
67+
68+
## Inferring TensorFlow And TensorFlow-Lite Models
69+
70+
For using the `TFSession` struct to inference the TensorFlow models and executing in WasmEdge, users should install the [WasmEdge-TensorFlow plug-in with dependencies](../../start/install.md#wasmedge-tensorflow-plug-in).
71+
72+
For using the `TFLiteSession` struct and to inference the TensorFlow-Lite models executing in WasmEdge, users should install the [WasmEdge-TensorFlowLite plug-in with dependencies](../../start/install.md#wasmedge-tensorflow-lite-plug-in).
73+
74+
### Create Session
75+
76+
First, developers should create a session to load the TensorFlow or TensorFlow-Lite model.
77+
78+
```rust
79+
// The mod_buf is a vec<u8> which contains the model data.
80+
let mut session = wasmedge_tensorflow_interface::TFSession::new(&mod_buf);
81+
```
82+
83+
The above function is create the session for TensorFlow frozen models. Developers can use the `new_from_saved_model` function to create from saved-models:
84+
85+
```rust
86+
// The mod_path is a &str which is the path to saved-model directory.
87+
// The second argument is the list of tags.
88+
let mut session = wasmedge_tensorflow_interface::TFSession::new_from_saved_model(model_path, &["serve"]);
89+
```
90+
91+
Or use the `TFLiteSession` to create a session for inferring the `tflite` models.
92+
93+
```rust
94+
// The mod_buf is a vec<u8> which contains the model data.
95+
let mut session = wasmedge_tensorflow_interface::TFLiteSession::new(&mod_buf);
96+
```
97+
98+
### Prepare Input Tensors
99+
100+
```rust
101+
// The flat_img is a vec<f32> which contains normalized image in rgb32f format.
102+
session.add_input("input", &flat_img, &[1, 224, 224, 3])
103+
.add_output("MobilenetV2/Predictions/Softmax");
104+
```
105+
106+
### Run TensorFlow Models
107+
108+
```rust
109+
session.run();
110+
```
111+
112+
### Convert Output Tensors
113+
114+
```rust
115+
let res_vec: Vec<f32> = session.get_output("MobilenetV2/Predictions/Softmax");
116+
```
117+
118+
## Build And Execution
119+
120+
After completing your code, you can follow the command to compile into WASM.
121+
122+
```bash
123+
cargo build --target=wasm32-wasi
124+
```
125+
126+
The output WASM file will be at `target/wasm32-wasi/debug/` or `target/wasm32-wasi/release`.
127+
128+
Please refer to [WasmEdge CLI](../../start/build-and-run/cli.md) for WASM execution.
129+
130+
## Examples
131+
132+
Work in progress. Will update soon.
133+
134+
## Old WasmEdge TensorFlow extension
135+
136+
Work in progress. Will update soon.

docs/start/build-and-run/cli.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_position: 1
44

55
# The `wasmedge` CLI
66

7-
After intalling WasmEdge, you can use the `wasmedge` CLI to execute a WASM files. We will cover how to run WASM files with WasmEdge on your own machine and Docker images.
7+
After installing WasmEdge, you can use the `wasmedge` CLI to execute a WASM files. We will cover how to run WASM files with WasmEdge on your own machine and Docker images.
88

99
The `wasmedge` binary is a command line interface (CLI) program that runs WebAssembly programs.
1010

@@ -269,7 +269,7 @@ confidence: 0.8941176470588236
269269

270270
## Docker images for the CLI tools
271271

272-
The Docker images in this section are mostly used for development purposes. They allow you to use WasmEdge tools in containerized Linux environments. If you want to containerize WASM apps, check out [this](../getting-started/quick_start_docker) section.
272+
The Docker images in this section are mostly used for development purposes. They allow you to use WasmEdge tools in containerized Linux environments. If you want to containerize WASM apps, check out [this](../getting-started/quick_start_docker.md) section.
273273

274274
The `wasmedge/slim:{version}` Docker images provide a slim WasmEdge images built with [DockerSlim](https://dockersl.im) every releases.
275275

i18n/zh/docusaurus-plugin-content-docs/current/contribute/source/_category_.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"position": 2,
44
"link": {
55
"type": "generated-index",
6-
"description": "we will learn how to the WasmEdge Plugin System."
6+
"description": "Here's the guides for building WasmEdge and its plug-ins from source on various platforms."
77
}
88
}

0 commit comments

Comments
 (0)