
ModelArts GA UMN 06052022 from R&D R&D provided a new version of the ModelArts User Manual in May 2022. Depends-On: #11 Reviewed-by: Artem Goncharov <Artem.goncharov@gmail.com>
21 KiB
Conversion Templates
ModelArts provides the following conversion templates based on different AI frameworks:
TF-FrozenGraph-To-Ascend-C32
Convert the model trained by the TensorFlow framework and saved in frozen_graph format. The converted model can run on the Ascend. The custom operators (TBE operators) developed based on Tensor Based Engine (TBE) can be used for conversion.
Parameter |
Description |
---|---|
input_shape |
Enter the shape of the input data of the model, for example, input_name1:n1,c1,h1,w1;input_name2:n2,c2,h2,w2. input_name must be the node name in the network model before model conversion. This parameter is mandatory when the model has dynamic shape input. For example, in input_name1:? ,h,w,c, the question mark (?) indicates the batch size, that is, the number of images processed at a time. It is used to convert the original model with a dynamic shape into an offline model with a fixed shape. The batch feature is not supported. The batch value of the input_shape can only be 1. During the conversion, the system parses the input model to obtain the input tensor and prints it in the log. If you do not know the input tensor of the used model, refer to the parsing result in the log. |
input_format |
NCHW and NHWC are supported. The default format is NHWC. For the TensorFlow framework, the default value is NHWC. To use the NCHW format, you need to specify NCHW. For the Caffe framework, only the NCHW format is supported. |
out_nodes |
Specifies the output node, for example, node_name1:0;node_name1:1;node_name2:0. node_name must be the node name in the network model before model conversion. The digit after each colon (:) indicates the sequence number of the output. For example, node_name1:0 indicates the 0th output of node_name1. If the output node is not specified, the output of the last operator layer serves as the model output by default. To check the parameters of a specific operator layer, specify the operator layer by using this parameter. During the conversion, the system parses the input model to obtain the output node and prints it in the log. If you do not know the input tensor of the used model, refer to the parsing result in the log. |
net_format |
Specifies the preferred data format for network operators. Possible values are ND (N cannot be more than 4) and 5D. This parameter only takes effect if the input data of operators on the network supports both ND and 5D formats. ND indicates that operators in the model are converted into the NCHW format. 5D indicates that . 5D is the default value. |
fp16_high_prec |
Specifies whether to generate a high-precision FP16 Davinci model. 0 is the default value, indicating that a common FP16 Da Vinci model with better inference performance is generated. The value 1 indicates that a high-precision FP16 Da Vinci model with better inference precision is generated. High-precision models support only Caffe operators (Convolution, Pooling, and FullConnection) and TensorFlow operators (tf.nn.conv2d and tf.nn.max_poo). |
output_type |
FP32 is the default value and is recommended for classification and detection networks. For image super-resolution networks, UINT8 is recommended for better inference performance. |
enable_l2dynamic |
L2 dynamic optimization switch. This parameter may affect the inference performance of the network model. If the performance does not meet the requirement, you can disable this function to verify the impact on the performance. true is the default value, indicating that L2 dynamic optimization is enabled. false indicates that L2 dynamic optimization is disabled. |
TF-SavedModel-To-Ascend-C32
Convert the model trained by the TensorFlow framework and saved in saved_model format. The converted model can run on the Ascend. The custom operators (TE operators) developed based on TE can be used for conversion.
Parameter |
Description |
---|---|
input_shape |
Enter the shape of the input data of the model, for example, input_name1:n1,c1,h1,w1;input_name2:n2,c2,h2,w2. input_name must be the node name in the network model before model conversion. This parameter is mandatory when the model has dynamic shape input. For example, in input_name1:? ,h,w,c, the question mark (?) indicates the batch size, that is, the number of images processed at a time. It is used to convert the original model with a dynamic shape into an offline model with a fixed shape. The batch feature is not supported. The batch value of the input_shape can only be 1. During the conversion, the system parses the input model to obtain the input tensor and prints it in the log. If you do not know the input tensor of the used model, refer to the parsing result in the log. |
input_format |
NCHW and NHWC are supported. The default format is NHWC. For the TensorFlow framework, the default value is NHWC. To use the NCHW format, you need to specify NCHW. For the Caffe framework, only the NCHW format is supported. |
out_nodes |
Specifies the output node, for example, node_name1:0;node_name1:1;node_name2:0. node_name must be the node name in the network model before model conversion. The digit after each colon (:) indicates the sequence number of the output. For example, node_name1:0 indicates the 0th output of node_name1. If the output node is not specified, the output of the last operator layer serves as the model output by default. To check the parameters of a specific operator layer, specify the operator layer by using this parameter. During the conversion, the system parses the input model to obtain the output node and prints it in the log. If you do not know the input tensor of the used model, refer to the parsing result in the log. |
net_format |
Specifies the preferred data format for network operators. Possible values are ND (N cannot be more than 4) and 5D. This parameter only takes effect if the input data of operators on the network supports both ND and 5D formats. ND indicates that operators in the model are converted into the NCHW format. 5D indicates that . 5D is the default value. |
fp16_high_prec |
Specifies whether to generate a high-precision FP16 Davinci model. 0 is the default value, indicating that a common FP16 Da Vinci model with better inference performance is generated. The value 1 indicates that a high-precision FP16 Da Vinci model with better inference precision is generated. High-precision models support only Caffe operators (Convolution, Pooling, and FullConnection) and TensorFlow operators (tf.nn.conv2d and tf.nn.max_poo). |
output_type |
FP32 is the default value and is recommended for classification and detection networks. For image super-resolution networks, UINT8 is recommended for better inference performance. |
enable_l2dynamic |
L2 dynamic optimization switch. This parameter may affect the inference performance of the network model. If the performance does not meet the requirement, you can disable this function to verify the impact on the performance. true is the default value, indicating that L2 dynamic optimization is enabled. false indicates that L2 dynamic optimization is disabled. |