Skip to content

Commit 336d0f7

Browse files
committed
Add KP model list
1 parent acaf43e commit 336d0f7

File tree

5 files changed

+121
-1
lines changed

5 files changed

+121
-1
lines changed

docs/dev_guides/kernel_primitive_api/example_cn.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ API 示例
33

44
- `ElementwiseAdd <./add_example_cn.html>`_ : 加法操作,输入和输出具有相同 Shape。
55
- `Reduce <./reduce_example_cn.html>`_ : 针对最高维进行规约操作。
6+
- `Model <./model_example_cn.html>`_ : Resnet50执行流程。
67

78
.. toctree::
89
:hidden:
910

1011

1112
add_example_cn.md
1213
reduce_example_cn.md
14+
model_example_cn.md

docs/dev_guides/kernel_primitive_api/example_en.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ API Examples
33

44
- `ElementwiseAdd <./add_example_en.html>`_ : Addition operation, the input and output shapes are the same.
55
- `Reduce <./reduce_example_en.html>`_ : Only the highest dimension is involved in reduce.
6-
6+
- `Model <./model_example_en.html>`_ : Execution process of resnet50.
77
.. toctree::
88
:hidden:
99

1010

1111
add_example_en.md
1212
reduce_example_en.md
13+
model_example_en.md
Loading
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# 示例 - Model
2+
## 模型运行说明
3+
+ 在 GPU 平台上默认使用 Kernel Primitive API 编写的算子。
4+
+ 在 XPU 平台上使用 Kernel Primitive API 编写的算子需要开启FLAGS\_run\_kp\_kernel环境变量。
5+
6+
### XPU Kernel Primitive API Paddle模型运行
7+
8+
以 resnet50 为例展示 XPU2 KP 模型运行的基本流程
9+
10+
+ 1. 下载 Paddle XPU2 KP 并安装,当前仅支持 python3.7</br>
11+
```
12+
pip install https://paddle-qa.bj.bcebos.com/paddle-pipeline/v2.3.0/xpu2_kp_py37/latest/paddlepaddle_xpu-2.3.0-cp37-cp37m-linux_x86_64.whl
13+
```
14+
+ 2. 下载模型库并安装</br>
15+
```
16+
git clone -b develop https://github.com/PaddlePaddle/PaddleClas.git
17+
cd PaddleClas
18+
python -m pip install -r requirements.txt
19+
```
20+
+ 3. 下载数据集<br>
21+
```
22+
cd dataset
23+
rm -rf ILSVRC2012
24+
wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_CIFAR100.tar
25+
tar xf whole_chain_CIFAR100.tar
26+
ln -s whole_chain_CIFAR100 ILSVRC2012
27+
cd ILSVRC2012
28+
mv train.txt train_list.txt
29+
mv test.txt val_list.txt
30+
```
31+
+ 4. 模型运行</br>
32+
```
33+
cd ../..
34+
export FLAGS_selected_xpus=0
35+
export FLAGS_run_kp_kernel=1
36+
export XPUSIM_DEVICE_MODEL=KUNLUN2
37+
nohup python tools/train.py \
38+
-c ppcls/configs/ImageNet/ResNet/ResNet50.yaml \
39+
-o Global.device=xpu > ResNet50_xpu2.log &
40+
```
41+
+ 5. 成功截图如下:</br>
42+
![Model](./images/example_model.png)
43+
44+
### XPU2 Kernel Primitive API 模型列表
45+
46+
序号 | 模型名称 | 类别
47+
-- | -- | --
48+
1 | resnet50 | 图像分类
49+
2 | deepfm | 推荐网络
50+
3 | wide&deep | 推荐网络
51+
4 | yolov3-darknet53 | 目标检测
52+
5 | ssd-resnet34 | 目标检测
53+
6 | orc-db | 文本检测
54+
7 | bert-base | 自然语言
55+
8 | transformer | 自然语言
56+
9 | gpt-2 | 自然语言
57+
10 | unet | 图像分割
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Model
2+
## Description
3+
+ On the GPU platform, the operator written by the kernel primitive API is used by default.
4+
+ Operators written using the kernel primitive API on the XPU platform need to enable FLAGS\_run\_kp\_kernel environment variables.
5+
6+
### XPU kernel primitive API model example
7+
8+
Take resnet50 as an example to show the basic process of XPU2 KP model operation
9+
10+
+ 1. Download and install paddle XPU2 KP. Currently, only python3.7 is supported</br>
11+
```
12+
pip install https://paddle-qa.bj.bcebos.com/paddle-pipeline/v2.3.0/xpu2_kp_py37/latest/paddlepaddle_xpu-2.3.0-cp37-cp37m-linux_x86_64.whl
13+
```
14+
15+
+ 2. Download model library and install</br>
16+
```
17+
git clone -b develop https://github.com/PaddlePaddle/PaddleClas.git
18+
cd PaddleClas
19+
python -m pip install -r requirements.txt
20+
```
21+
22+
+ 3. Downloading datasets <br>
23+
24+
```
25+
cd dataset
26+
rm -rf ILSVRC2012
27+
wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_CIFAR100.tar
28+
tar xf whole_chain_CIFAR100.tar
29+
ln -s whole_chain_CIFAR100 ILSVRC2012
30+
cd ILSVRC2012
31+
mv train.txt train_list.txt
32+
mv test.txt val_list.txt
33+
```
34+
35+
+ 4. Model operation</br>
36+
```
37+
cd ../..
38+
export FLAGS_selected_xpus=0
39+
export FLAGS_run_kp_kernel=1
40+
export XPUSIM_DEVICE_MODEL=KUNLUN2
41+
nohup python tools/train.py \
42+
-c ppcls/configs/ImageNet/ResNet/ResNet50.yaml \
43+
-o Global.device=xpu > ResNet50_xpu2.log &
44+
```
45+
+ 5. Creenshot is as follows: </br>
46+
![Model](./images/example_model.png)
47+
48+
### XPU2 Kernel Primitive API Model List
49+
Number | Model Name | Category
50+
-- | -- | --
51+
1 | resnet50 | Image Classification
52+
2 | deepfm | Recommendation Network
53+
3 | wide&deep | Recommendation Network
54+
4 | yolov3-darknet53 | Object Detection
55+
5 | ssd-resnet34 | Object Detection
56+
6 | orc-db | Text Detection
57+
7 | bert-base | Natural Language Processing
58+
8 | transformer | Natural Language Processing
59+
9 | gpt-2 | Natural Language Processing
60+
10 | unet | Image Segmentation

0 commit comments

Comments
 (0)