Introduction to Graph Modes
Graph Engine (GE) is the control center for the compilation and running of computational graphs. It supports the execution of neural networks on the CANN platform in graph mode.
The graph mode is a running mode of the neural network model. In the graph mode, a user first constructs a computational graph by using a model computation process, and then delivers the graph to Ascend hardware for execution by using GE. Another running mode of the neural network is a single-operator mode. In the single-operator mode, each computing operation is executed immediately after being delivered. Compared with the single-operator mode, GE in graph mode can use technologies such as computational graph optimization, multi-stream parallelism, memory overcommitment, and model offload to accelerate model execution and reduce the model memory usage.
GE provides a unified graph development API, supports the access of multiple AI frameworks, and allows developers to customize graph structures. This flexibility helps developers quickly and efficiently deploy neural network models on Ascend hardware.
Key Technologies and Benefits
In general, the graph mode has a global perspective and can be better optimized in terms of compilation optimization, memory, and lifecycle management to obtain better memory and performance benefits.
Use Cases
Based on the GE capabilities, CANN supports the following graph modes:
|
Use Case |
Description |
|---|---|
|
Run the PyTorch network script in graph mode. |
|
|
Run the TensorFlow network script in graph mode. |
|
|
If you have a trained ONNX or PB model, you can use either of the following methods to run the model on the Ascend platform in graph mode:
|
|
|
Construct a graph that can run on the Ascend hardware based on the Ascend graph construction API provided by GE. |
|
|
If you encounter an operator that is not supported by the Ascend Operator Library (AOL) when executing the PyTorch/TensorFlow network or constructing an Ascend graph based on the operator prototype, you need to develop a custom operator and then import the custom operator to the graph. |