Overview
General Restrictions
Before model conversion, pay attention to the following restrictions:
- To convert a network such as Faster R-CNN to an offline model adapted to the Ascend AI Processor, you must modify the .prototxt model file by referring to Custom Network Modification.
- The tool converts models implemented in Caffe, TensorFlow, MindSpore, and ONNX only. If the original framework is Caffe, MindSpore, or ONNX, the input data is of type fp32, fp16 (by configuring --input_fp16_nodes, which is not supported by MindSpore), or uint8 (by configuring AIPP). If the original framework is TensorFlow, the input data is of type fp16, fp32, uint8, int32, int64, or bool.
- For a Caffe model, op name and op type in the model file (.prototxt) and weight file (.caffemodel) must be the consistent (case sensitive).
- For a TensorFlow model, only the FrozenGraphDef format is supported.
- Inputs with dynamic shapes are not supported, for example, NHWC = [?, ?, ?, 3]. The dimension sizes must be static.
- For a Caffe model, the input data is up to 4-dimensional and operators such as reshape and expanddim do not support 5D output. A TensorFlow model is subject to the restrictions of each operator.
- Except the const operator, the input and output at all layers in a model must meet the condition dim! = 0.
- Only the operators listed in Caffe Operator Specifications are supported, and the defined operator restrictions must be met.
- Only the operators listed in Operator Specifications (TensorFlow) are supported.
Command-line Options
- If options queried with the atc --help command are not described in Table 2-1, they are reserved or applicable to other chip versions. You do not need to pay attention to such options.
- You can use one of the following commands to convert a model as required.
- atc param1=value1 param2=value2 ... (No space is allowed before value. Otherwise, it will be truncated, and the value of param is null.)
- atc param1 value1 param2 value2 ...
- Whether an option is required depends on the mode argument (0 or 3).
Option |
Description |
Required/Optional |
Default |
---|---|---|---|
Displays help information. |
Optional |
N/A |
|
Sets the work mode. |
Optional |
0 |
|
Sets the model file directory, including the file name. |
Required |
N/A |
|
Sets the weight file directory, including the file name. |
Optional |
N/A |
|
Sets the directory (including the file name) of the offline model or original model file to be converted to JSON format. |
Optional |
N/A |
|
Sets the framework of the original model. |
Required |
N/A |
|
Sets the input data format. |
Optional |
NCHW (Caffe) NHWC (TensorFlow) |
|
Sets the input shape. |
Optional |
N/A |
|
Sets dynamic batch size choices. Applies to the scenario where image count per inference batch is unfixed. |
Optional |
N/A |
|
Sets dynamic image size choices. Applies to the scenario where the resolution of images input for inference is unfixed. |
Optional |
N/A |
|
Sets dynamic dimension size choices in ND format. Applies to the scenario where the dimension size for inference is unfixed. |
Optional |
N/A |
|
Sets the single-operator definition file, used to convert a single-operator JSON file into an offline model adapted to the Ascend AI Processor. |
Optional |
N/A |
|
|
Required |
N/A |
|
Sets the output data type of a network or an output node. |
Optional |
N/A |
|
Sets the precheck result file directory, including the file name. |
Optional |
check_result.json |
|
Sets the directory (including the file name) of the JSON file converted from the offline model or original model file. |
Optional |
N/A |
|
Sets the target SoC version. |
Required |
N/A |
|
Sets the number of AI Cores for model build. |
Optional |
2 |
|
Sets the output nodes. |
Optional |
N/A |
|
Sets the name of the FP16 input node. |
Optional |
N/A |
|
Sets the configuration file directory (including the file name) of an operator to be inserted, for example, the aipp operator for data preprocessing. |
Optional |
N/A |
|
Sets the directory (including the file name) of the mapping configuration file of a custom operator. The function of a custom operator varies according to the network. You can specify the mapping between the custom operator and the actual custom operator running on the network. |
Optional |
N/A |
|
Sets the data type and format of the network inputs to fp16 and NC1HWC0, respectively. |
Optional |
false |
|
Sets the data type and format of the network outputs to fp16 and NC1HWC0, respectively. |
Optional |
false |
|
Enables memory reuse. |
Optional |
0 |
|
Sets the fusion switch configuration file directory, including the file name. |
Optional |
N/A |
|
Enables specific fusion rules in build. |
Optional |
N/A |
|
Enables small channel optimization. If enabled, performance benefits are generated at the first convolutional layer with channel <= 4. |
Optional |
0 |
|
Enables buffer optimization. |
Optional |
l2_optimize |
|
Selects the operator precision mode. |
Optional |
force_fp16 |
|
Selects the operator auto tuning mode. |
Optional |
N/A |
|
Selects the operator implementation mode. |
Optional |
high_performance |
|
Lists the operator types. The listed operators use the mode specified by the --op_select_implmode option. |
Optional |
N/A |
|
Enables TBE operator debug during operator build. |
Optional |
0 |
|
Dumps a JSON file with shape information. |
Optional |
0 |
|
Sets the level of logs to be printed during ATC model conversion. |
Optional |
null |