Model Conversion
ModelArts model conversion will be taken offline on February 29, 2024. You will be provided with links to download the ATC model conversion tool or MindSpore Lite. ATC converts your model into OM format, and MindSpore Lite converts your model into MindIR format for inference. ModelArts development environment supports the conversion of ONNX or PyTorch models into MindIR format in the CN Southwest-Guiyang1 region.
To deploy the models created in ModelArts or a local PC on the Ascend chip, convert the models to the required formats beforehand.
ModelArts supports model conversion, allowing you to convert a model to a required format.
Model conversion applies to the following scenarios:
- If you use the Caffe (in .caffemodel format) or TensorFlow framework (in frozen_graph or saved_model format) to train a model, you can convert the model to the .om format. The converted model can be deployed and run on Ascend chips.
Constraints
- Only TensorFlow models can be converted. For a TensorFlow model, the input data type is of the INT32, BOOL, UINT8, or FLOAT type.
- ModelArts provides conversion templates for you to choose. For details about the supported templates, see Conversion Templates.
- An OBS directory must be specified in compression/conversion tasks. Ensure that the OBS directory you use and ModelArts are in the same region.
- When importing the converted model to ModelArts, use a model template.
- For a TensorFlow model, the FrozenGraphDef and SavedModel formats are supported. If a model is in the SavedModel format, the model is converted to the FrozenGraphDef format and then to the OM format.
- Inputs with dynamic shapes are not supported, for example, NHWC = [?, ?, ?, 3]. A fixed value needs to be specified during model conversion.
- The input can be up to 4-dimensional. Operators involving dimension changes (such as reshape and expanddim) cannot output five dimensions.
- Except the const operator, the input and output at all layers in a model must meet the condition dim!=0.
- Model conversion does not support models that contain training operators.
- A UINT8 quantized model cannot be converted.
- Model operators support only 2D convolution but do not support 3D convolution. The batch_normalization_1 and FusedBatchNorm operators cannot be converted in batches.
Creating a Model Conversion Task
- Log in to the ModelArts management console and choose AI Application Management > Model Conversion in the navigation pane. The Model Conversion page is displayed.
- Click Create Task in the upper left corner to create a task.
- On the Create Task page, set the conversion task parameters.
- Enter the name and description of the conversion task.
- Set the parameters of the conversion task. For details, see Table 1.
Table 1 Parameters Parameter
Description
Input Framework
Caffe and TensorFlow frameworks support conversion.
Conversion Input Path
Path to the model to be converted. The path must be an OBS path and comply with the ModelArts specifications. For details about the specifications, see Conversion Input Path.
Output Framework
MindSpore is supported.
Conversion Output Path
Path to the converted model. The path must comply with the ModelArts specifications. For details about the specifications, see Conversion Output Path.
Conversion Template
ModelArts provides various templates to define model conversion and the parameters required during the conversion. Conversion Templates details the supported model conversion templates. The drop-down list on the right of the conversion template displays the matching templates based on the selected input and output frameworks.
After you select a template from the drop-down list, the advanced parameters of the template are displayed in the lower part of the page, for example, the precision.
Different conversion templates support different advanced settings. For details about the parameters supported by each template, see Conversion Templates.
Figure 1 Creating a model conversion task
- After entering the task information, click Create now in the lower right corner.
After the task is created, the system automatically switches to the Model Conversion Tasks page. The created conversion task is displayed on the page and is in the Initializing status. The conversion task takes several minutes to complete. When the task status changes to Successful, the task is complete and the model has been converted.
If the task status changes to Failed, click the task name to go to the task details page, view the log information, adjust task parameters based on the log information, and create another conversion task.
Deleting a Model Conversion Task
You can delete unnecessary conversion tasks. However, tasks in the Running or Initializing status cannot be deleted.
Deleted tasks cannot be recovered. Exercise caution when performing this operation.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot