Building a Model

In inference scenarios, it is not yet supported to directly run network models trained under open-source frameworks (such as ONNX and TensorFlow) on Ascend AI Processor. You need to use ATC to convert such a network model into an offline model adapted to the Ascend AI Processor (.om file).

  1. Log in to the development environment as the running user.
  2. Perform model conversion.

    Run the command below to convert the network models trained under open-source frameworks (such as ONNX and TensorFlow) into an .om model file that can be identified by Ascend AI Processor.

    The ONNX model is used as an example. You must have the read and write permissions on the files specified in the command.

    atc --model=$HOME/module/resnet50*.onnx --framework=5 --output=$HOME/module/out/onnx_resnet50 --soc_version=<soc_version>  

    Parameters are listed below. For details about the restrictions, see ATC Instructions.

    • --model: path of the ResNet-50 model file.
    • --framework: source framework type. 5 indicates ONNX.
    • --output: path of the resnet50.om model file. Record this path for future use during app development.
    • --soc_version: version of the Ascend AI Processor. Replace <soc_version> with the actual value.

      To check soc_version of a device, perform the following steps:

      • For the following products: Run the npu-smi info command on the server where Ascend AI Processor is installed to obtain the Name information. The actual value is AscendName. For example, if Name is xxxyy, the actual value is Ascendxxxyy.

        Atlas A2 training products / Atlas A2 inference products

        Atlas 200I/500 A2 inference products

        Atlas inference products

        Atlas training products

      • For the following products: Run the npu-smi info -t board -i id -c chip_id command on the server where Ascend AI Processor is installed to obtain the Chip Name and NPU Name information. The actual value is Chip Name_NPU Name. For example, if the value of Chip Name is Ascendxxx and the value of NPU Name is 1234, the actual value is Ascendxxx_1234. Note that:
        • id: device ID, which is the NPU ID obtained by running the npu-smi info -l command.
        • chip_id: chip ID, which is obtained by running the npu-smi info -m command.

        Atlas A3 training products / Atlas A3 inference products

  • During model conversion, if a message is displayed indicating that some operators are not supported, develop custom operators first by referring to Ascend C Operator Development Guide, and then convert the model again.
  • During model conversion, if a message is displayed, indicating that an operator compilation error has occurred, but the message cannot help you locate the error, contact technical support. (After obtaining the logs, click here to contact technical support.) You need to set the DUMP_GE_GRAPH and DUMP_GRAPH_LEVEL environment variables, convert your model again, and collect graphs in each phase during model conversion. For details about the environment variables and graphs, see ""Reference" > "Dump Graph Details"" in ATC Instructions.
  • For details about the building and inference of models with a dynamic input shape, see Model Inference with Dynamic-Shape Inputs.
  • If the existing network does not meet your requirements, you can use the operators supported by Ascend AI Processor and call graph build APIs to build your own network, and then compile the network into an .om file. For details, see Graph Mode Development Guide.