Creating a Custom Operator Development Project
- Log in to the DDK server as the DDK installation user ascend.
- Create a workspace directory.
mkdir $HOME/tools/projects
- Create a directory for custom projects.
$ mkdir $HOME/tools/projects/customop_te
Create an operator code directory.
mkdir $HOME/tools/projects/customop_te/operator
Create a directory for storing operator plug-in code.
mkdir $HOME/tools/projects/customop_te/plugin
- Copy the sample code in the DDK to the directory where the operator development project is stored.
- This example describes how to develop a custom operator by using the code of the built-in reduction operator in the DDK and its plug-in. You can create related files for editing.
- In the example, the installation path of the DDK is $HOME/tools/che. If the actual installation path is different from the example path, replace the path in the example command with the actual installation path.
- Copy the sample code file reduction.py of the reduction operator and the sample data generation script data_gen.py used for operator verification in the DDK to the directory where the operator code of the custom project is stored.
cp -rf $HOME/tools/che/ddk/ddk/sample/customop/python/reduction.py $HOME/tools/projects/customop_te/operator/
cp -rf $HOME/tools/che/ddk/ddk/sample/customop/python/data_gen.py $HOME/tools/projects/customop_te/operator/
- Copy the sample code file of the reduction operator plug-in and the Makefile file in the DDK to the directory where the operator plug-in code of the custom project is stored.
cp -rf $HOME/tools/che/ddk/ddk/sample/customop/customop_caffe_demo/caffe_reduction_layer.cpp $HOME/tools/projects/customop_te/plugin/
cp -rf $HOME/tools/che/ddk/ddk/sample/customop/customop_caffe_demo/Makefile $HOME/tools/projects/customop_te/plugin/
- Copy the Caffe network model file in the DDK used in this example to the custom project directory.
cp -rf $HOME/tools/che/ddk/ddk/sample/customop/customop_caffe_demo/model/ $HOME/tools/projects/customop_te/
Table 1 shows the directory structure of the custom operator development project.
Table 1 Directory structure Sample Directory
File
Description
customop_te/operator
reduction.py
Sample code of the reduction operator
data_gen.py
File generated based on reduction operator sample data
customop_te/plugin
caffe_reduction_layer.cpp
Sample code of the reduction operator plug-in (needs to be modified)
Makefile
Compilation rule file of the reduction operator plug-in (needs to be modified)
customop_te/model
deploy_mylenet-1.prototxt
Original model file of the MyLeNet network
mylenet-1.caffemodel
Pre-trained model file of the MyLeNet network
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot