Pyatc APIs

Applicable Products

All processors

Function Usage

Pyatc is a Python-encapsulated API of the Ascend Tensor Compiler (ATC) offline model compilation tool. It offers the same functionality as ATC but provides a more flexible integration experience for Python users.

The differences between Pyatc and ATC are as follows:

  • ATC: runs as a separate subprocess. The Python interpreter used during compilation is parsed by the ATC process, which may differ from the user's current terminal environment (for example, Python 3). This can lead to dependency conflicts or path issues.
  • Pyatc: executes compilation logic directly within the main process. It reuses the current Python interpreter and environment variables, ensuring consistency between the compilation and runtime environments. This avoids process isolation and minimizes environment-related issues.

Call Mode

Set environment variables by referring to Environment Setup and select either of the following entries based on the actual application scenario:

  • Command line:
    1
    pyatc [Parameter]
    
  • Python:
    1
    python3 -m ge.pyatc [Parameter]
    

Parameters

The parameters of Pyatc are the same as those of ATC. For details, see Ascend Tensor Compiler (ATC).

Returns

After the call is complete, the process exit code indicates the execution result.

  • 0: success
  • Non-0: failure. Error details are printed to standard output.

Example

1
pyatc --model=resnet50.onnx --framework=5 --soc_version=<soc_version> --output=resnet50

To query the value of <soc_version>, do as follows:

  • For the following products: Run the npu-smi info command on the server where 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 Atlas A3 training products / Atlas A3 inference products : Run the npu-smi info -t board -i id -c chip_id command on the server where the 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.
    • 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.
  • For the Ascend 950PR / Ascend 950DT : Run the npu-smi info -t board -i id command on the server where the 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.

    id indicates the device ID, which is the NPU ID obtained by running the npu-smi info -l command.