Skip to content

Commit

Permalink
Add KP model list
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaTrainingG committed May 31, 2022
1 parent acaf43e commit 336d0f7
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/dev_guides/kernel_primitive_api/example_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ API 示例

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

.. toctree::
:hidden:


add_example_cn.md
reduce_example_cn.md
model_example_cn.md
3 changes: 2 additions & 1 deletion docs/dev_guides/kernel_primitive_api/example_en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ API Examples

- `ElementwiseAdd <./add_example_en.html>`_ : Addition operation, the input and output shapes are the same.
- `Reduce <./reduce_example_en.html>`_ : Only the highest dimension is involved in reduce.

- `Model <./model_example_en.html>`_ : Execution process of resnet50.
.. toctree::
:hidden:


add_example_en.md
reduce_example_en.md
model_example_en.md
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions docs/dev_guides/kernel_primitive_api/model_example_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# 示例 - Model
## 模型运行说明
+ 在 GPU 平台上默认使用 Kernel Primitive API 编写的算子。
+ 在 XPU 平台上使用 Kernel Primitive API 编写的算子需要开启FLAGS\_run\_kp\_kernel环境变量。

### XPU Kernel Primitive API Paddle模型运行

以 resnet50 为例展示 XPU2 KP 模型运行的基本流程

+ 1. 下载 Paddle XPU2 KP 并安装,当前仅支持 python3.7</br>
```
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
```
+ 2. 下载模型库并安装</br>
```
git clone -b develop https://github.com/PaddlePaddle/PaddleClas.git
cd PaddleClas
python -m pip install -r requirements.txt
```
+ 3. 下载数据集<br>
```
cd dataset
rm -rf ILSVRC2012
wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_CIFAR100.tar
tar xf whole_chain_CIFAR100.tar
ln -s whole_chain_CIFAR100 ILSVRC2012
cd ILSVRC2012
mv train.txt train_list.txt
mv test.txt val_list.txt
```
+ 4. 模型运行</br>
```
cd ../..
export FLAGS_selected_xpus=0
export FLAGS_run_kp_kernel=1
export XPUSIM_DEVICE_MODEL=KUNLUN2
nohup python tools/train.py \
-c ppcls/configs/ImageNet/ResNet/ResNet50.yaml \
-o Global.device=xpu > ResNet50_xpu2.log &
```
+ 5. 成功截图如下:</br>
![Model](./images/example_model.png)

### XPU2 Kernel Primitive API 模型列表

序号 | 模型名称 | 类别
-- | -- | --
1 | resnet50 | 图像分类
2 | deepfm | 推荐网络
3 | wide&deep | 推荐网络
4 | yolov3-darknet53 | 目标检测
5 | ssd-resnet34 | 目标检测
6 | orc-db | 文本检测
7 | bert-base | 自然语言
8 | transformer | 自然语言
9 | gpt-2 | 自然语言
10 | unet | 图像分割
60 changes: 60 additions & 0 deletions docs/dev_guides/kernel_primitive_api/model_example_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Model
## Description
+ On the GPU platform, the operator written by the kernel primitive API is used by default.
+ Operators written using the kernel primitive API on the XPU platform need to enable FLAGS\_run\_kp\_kernel environment variables.

### XPU kernel primitive API model example

Take resnet50 as an example to show the basic process of XPU2 KP model operation

+ 1. Download and install paddle XPU2 KP. Currently, only python3.7 is supported</br>
```
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
```

+ 2. Download model library and install</br>
```
git clone -b develop https://github.com/PaddlePaddle/PaddleClas.git
cd PaddleClas
python -m pip install -r requirements.txt
```

+ 3. Downloading datasets <br>

```
cd dataset
rm -rf ILSVRC2012
wget -nc https://paddle-imagenet-models-name.bj.bcebos.com/data/whole_chain/whole_chain_CIFAR100.tar
tar xf whole_chain_CIFAR100.tar
ln -s whole_chain_CIFAR100 ILSVRC2012
cd ILSVRC2012
mv train.txt train_list.txt
mv test.txt val_list.txt
```

+ 4. Model operation</br>
```
cd ../..
export FLAGS_selected_xpus=0
export FLAGS_run_kp_kernel=1
export XPUSIM_DEVICE_MODEL=KUNLUN2
nohup python tools/train.py \
-c ppcls/configs/ImageNet/ResNet/ResNet50.yaml \
-o Global.device=xpu > ResNet50_xpu2.log &
```
+ 5. Creenshot is as follows: </br>
![Model](./images/example_model.png)

### XPU2 Kernel Primitive API Model List
Number | Model Name | Category
-- | -- | --
1 | resnet50 | Image Classification
2 | deepfm | Recommendation Network
3 | wide&deep | Recommendation Network
4 | yolov3-darknet53 | Object Detection
5 | ssd-resnet34 | Object Detection
6 | orc-db | Text Detection
7 | bert-base | Natural Language Processing
8 | transformer | Natural Language Processing
9 | gpt-2 | Natural Language Processing
10 | unet | Image Segmentation

0 comments on commit 336d0f7

Please sign in to comment.