Compiling an Operator
Compile the operator code to generate the operator binary file and operator description file as follows:
- Obtain the DDK version number, which is required for compiling the operator.
Check the DDK version number in $HOME/tools/che/ddk/ddk/ddk_info.
As shown in Figure 1, the VERSION field indicates the current DDK version.
- Set the version number and compile the operator.
- Run the following command in the customop_te/operator directory to enter the python interaction mode:
python
- In python interaction mode, run the following commands in sequence to set the DDK version number:
from topi.cce import te_set_version
import subprocess
te_set_version("1.3.T18.B850")
Figure 2 shows an example.
- Run the following commands to compile the reduction.py file to generate the binary file and description file of the operator:
subprocess.call("python reduction.py",shell=True)
Figure 3 Compiling operator files - Exit the python interaction mode.
quit(0)
- Run the following command in the customop_te/operator directory to enter the python interaction mode:
- After the operator compilation is completed, the kernel_meta folder is generated in the current operator directory. This folder contains the operator binary file *.o (with operators to run on AI Core) or *.so (with operators to run on AI CPU) and operator description file *.json.
- The *.o or *.so file is the binary file of the operator.
- The .json file is the operator description file, which is used to define operator properties and resources required for running.
The .json file is parsed as follows:
{ "binFileName":"Reduction", // Binary file name of the generated operator "binFileSuffix":".o", // Extension of the generated operator binary file. For the operators to be running on AI CPU, the generated binary file name is suffixed by .so. "blockDim":1, // Number of AI Cores used for calculation "kernelName":"Reduction__kernel0", // Name of the kernel function of the operator "magic":"RT_DEV_BINARY_MAGIC_ELF", // The operation target is AI Core. If the value of magic is RT_DEV_BINARY_MAGIC_ELF_AICPU, the operation target is AI CPU. "sha256":"d5158df2ff2e64743eec7f527ddd9078b99c1d670f5adbd8b789224657ab0f91" // Value obtained after the .o file is encrypted }
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