Help Center/ Atlas 300 Application (Model 3000)/ TE Custom Operator Development Guide/ Creating a Custom Operator Development Project
Updated on 2022-03-13 GMT+08:00

Creating a Custom Operator Development Project

  1. Log in to the DDK server as the DDK installation user ascend.
  2. Create a workspace directory.

    mkdir $HOME/tools/projects

  3. 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

  4. 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