Custom Operator Loading for Model Conversion
During model conversion, load the custom operator to generate an offline model file. The file is called during model inference.
Perform the following operations in the development environment.
- Set environment variables.
Set environment variables by referring to Conversion Example in the ATC Tool Instructions.
- Load the custom operator plug-in for model conversion.
atc --model=add.pb --framework=3 --output=myModel --out_nodes=add:0 --input_format=NCHW --soc_version={soc_version}
- --model: relative path of the original model file to the directory where the model conversion command is executed.
Download the test model file add.pb for model conversion verification from here.
- --framework: source framework type. The value 3 indicates TensorFlow, and the value 0 indicates Caffe.
- --output: name of the output model file, which can be customized
- --out_nodes: output node. If this parameter is not specified, the operator information at the last layer is output by default. For example, add:0. add indicates the name of a node in the network model before model conversion, and 0 indicates the 0th output.
- --input_format: input data format, NCHW or NHWC.
- soc_version: version of the Ascend AI Processor. Replace it with the actual version.
You can view the supported Ascend AI Processor version in the atc/data/platform_config in the ATC installation directory. The name of the .ini file is value of soc_version.
During model conversion, operators in the custom operator library are searched first to match the operators in the model file. If the matching fails, the built-in operator library is searched.
For details, see ATC Tool Instructions.
- --model: relative path of the original model file to the directory where the model conversion command is executed.