Custom Operator Samples
MindStudio provides custom operator samples, covering multiple AI frameworks such as MindSpore, TensorFlow, and PyTorch. To open a sample project, perform the following steps:
- Navigate to the dialog box for project importing.
- On the MindStudio welcome page, click Open in the Welcome to MindStudio window.
- On the MindStudio project page, choose from the top menu bar.
- In the Open File or Project window, select the folder of the sample project.
The sample project is stored in MindStudio/plugins/ascend-foundation/samples/operator_demo_projects/cann/ under the MindStudio installation directory.
The following shows the CANN directory structure. Select the sample project to be opened and perform operations such as operator build and deployment in the sample project.├── AICPU │ ├── Onnx │ └── Tensorflow ├── DSL │ ├── Mindspore │ ├── Onnx │ ├── PyTorch │ └── Tensorflow └── TIK ├── Mindspore ├── PyTorch └── Tensorflow - Click OK to import the sample project.
In the Import Support Configuration dialog box, set parameters and click Create.
Table 1 Import Support Configuration dialog box Parameter
Value
Type
Project type.
- Ascend Operator
- Ascend App
- Ascend Training
Select Ascend Operator from the drop-down list.
Framework
Original framework of the operator.
- MindSpore
- PyTorch
- TensorFlow
- ONNX
Set this parameter based on the framework of the opened sample project.
- During replacement of the CANN package, the cann directory in the operator sample project is overwritten. If the CANN package is modified, back it up before replacing it.
- The custom operator template code is used only for reference during operator development. Product-based development using the custom operator template is not supported.
- To build an ONNX operator, the protoc version must be 3.13.0.
- In the current Windows version:
- In the custom operator sample code, semantics that cannot be identified may be marked with red wavy lines, which does not affect the normal development process. You can ignore it.
- If the Case Names list in the UT configuration information is empty, the TE or TBE module may have been imported to the UT code of the operator sample. This sample does not support UTs.
- In the ST phase, configure the following environment variables by referring to 3:
ASCEND_HOME=/usr/local/Ascend/ascend-toolkit/latest ASCEND_OPP_PATH=${ASCEND_HOME}/opp
Parent topic: Other Functions and Operations