Defining Input/Output Data Types of an Offline Model
Overview
During model conversion, you can specify the data types, formats, and precision modes of the input and output nodes.
For example, the offline model of the TensorFlow ResNet-50 network requires Float16 input, the MaxPoolWithArgmax operator must be specified as the output operator (the corresponding node name is fp32_vars/MaxPoolWithArgmax), and the data type of the output node must be set to FP16. In this scenario, --input_fp16_nodes, --out_nodes, and --output_type allow you to implement those functions.
Procedure
This section takes the TensorFlow ResNet50 network model for illustration. Click here to download the model file (*.pb) of the ResNet50 network.
- Log in to the development environment as the CANN running user and upload the model file (.pb) used for model conversion to any directory in the development environment, for example, $HOME/module/.
- Run the following command (the path and file arguments in the command are for reference only):
atc --model=$HOME/module/resnet50_tensorflow_1.7.pb --framework=3 --output=$HOME/module/out/tf_resnet50 --soc_version=<soc_version> --input_fp16_nodes="Placeholder" --out_nodes="fp32_vars/MaxPoolWithArgmax:0" --output_type="fp32_vars/MaxPoolWithArgmax:0:FP16"The key options are described as follows:
- --input_fp16_nodes: specifies the names of the Float16 input nodes.
- --out_nodes: specifies the output nodes of the model. In this example, the MaxPoolWithArgmax operator is specified as the output node.
- --output_type: specifies the data type of the output nodes. In this example, Float16 is specified as the data type.
- --model: specifies the path of the ResNet50 model file.
- --framework: specifies the original framework type. The value 3 indicates TensorFlow.
For details about the options, see Command Line Options. If the following information is displayed, the model conversion is successful. If the model conversion fails, locate the fault by referring to "Error Codes".1ATC run success, welcome to the next use.
Find the generated offline model (for example, tf_resnet50.om) in the directory specified by the output argument. Figure 1 shows the MaxPoolWithArgmax operator as the output operator of the model (the figure can be opened by using the Netron visualization software).
