--framework
Applicable Products
All processors
Description
Sets the framework of the original network model.
See Also
None
Arguments
Argument:
- 0: Caffe
- 1: Model file in .air format of the MindSpore framework or standard .air file exported from TorchAir through export
- 3: TensorFlow
- 5: ONNX
Restrictions:
- This option is optional when --mode is set to 1. The Caffe, TensorFlow, and ONNX frameworks are supported. When this option is configured, ensure that --om matches --framework. When this option is left unconfigured, conversion from the offline model to a JSON file is performed. See the following examples:
--mode=1 --framework=0 --om=$HOME/module/resnet50.prototxt --mode=1 --framework=3 --om=$HOME/module/resnet50_tensorflow.pb --mode=1 --framework=5 --om=$HOME/module/resnet50.onnx
- This option is required when --mode is set to 0 or 3. The Caffe, TensorFlow, MindSpore, and ONNX frameworks are supported.
- If this option is set to 0, the Caffe network model is used. The model includes a .prototxt model file and a .caffemodel weight file. The op name and op type fields of the two files must be the same (case-sensitive).
- If this option is set to 3, the TensorFlow network model is used. Only the FrozenGraphDef format (model files with a .pb file extension) is supported. The .pb file is stored in Protobuf format. The network model and weight data are stored in the same file.
- If this option is set to 5, the ONNX network model is used. Operators of opset v11 to v18 in the ai.onnx operator domain are supported. For PyTorch models (.pth), they must first be converted into an ONNX model or exported as a standard *.air file via TorchAir's export method before model conversion can proceed.
- If this option is set to 1 and the MindSpore network model is used, note the following restrictions:
- Only model files in *.air format are convertible.
- --mode can only be set to 0.
- --input_format can only be set to NCHW. Other values are invalid, but the model will be successfully converted.
- Under the MindSpore framework, --input_shape, --out_nodes, --is_output_adjust_hw_layout, --input_fp16_nodes, --is_input_adjust_hw_layout, and --op_name_map do not take effect, but the model will be successfully converted.
- If the model size exceeds 2 GB, the *.air file, weight folder, and weight file in the folder are generated when the model is saved in the MindSpore framework. Ensure that the weight folder is stored in the same directory as the *.air file when converting the model. Otherwise, errors are reported during model conversion.
Suggestions and Benefits
None
Example
- ONNX:
--mode=0 --framework=5 --model=$HOME/module/resnet50.onnx --output=$HOME/module/out/onnx_resnet50 --soc_version=<soc_version> - TensorFlow:
--mode=0 --framework=3 --model=$HOME/module/resnet50_tensorflow.pb --output=$HOME/module/out/tf_resnet50 --soc_version=<soc_version> - Caffe:
--mode=0 --framework=0 --model=$HOME/module/resnet50.prototxt --weight=$HOME/module/resnet50.caffemodel --output=$HOME/module/out/caffe_resnet50 --soc_version=<soc_version> - .air model files:
--mode=0 --framework=1 --model=$HOME/module/ResNet50.air --output=$HOME/module/out/ResNet50_mindspore --soc_version=<soc_version>
Restrictions
- Certain Caffe models (such as Faster R-CNN, YOLOv3, YOLOv2, and SSD) contain operators that are not defined in the original Caffe framework, such as ROIPooling, Normalize, PSROI Pooling, and Upsample. To support these models on the AI processor, customization is required to reduce the complexities of custom operator development and postprocessing programming. For details, see Custom Caffe Network Modification.
- Original TensorFlow models containing control flow operators (such as Switch, Merge, LoopCond, Case, and While) cannot be directly converted using the ATC tool. To convert such models, you must first transform them into models that use function-type operators, and then use ATC to generate an offline model adapted to the AI processor. For details, see Custom Network Modification (TensorFlow).
Parent topic: Input Options