Tensor/Node/Graph

Ascend Intermediate Representation (Ascend IR) is an abstract data structure dedicated to the Ascend AI Processor. It is used to express the computation process. Based on the GE graph engine capability, algorithm models of mainstream AI frameworks (such as PyTorch, TensorFlow, MindSpore, and PaddlePaddle) can be converted into computational graphs indicated by Ascend IR. Users can also customize computational graphs, based on which subsequent compilation, acceleration, and optimization are performed.

Figure 1 Computation graph indicated by Ascend IR

Ascend IR contains information about three dimensions: tensor, node (operator), and graph.

Tensor

A tensor consists of its data and description, which describes its name, dtype, shape, and format.
Table 1 TensorDesc attributes

Attribute

Definition

name

Indexes a tensor. The name of each tensor must be unique.

shape

Specifies the shape of a tensor, such as (10, ), (1024, 1024), or (2, 3, 4). For example, the shape (3, 4) indicates a 3 x 4 matrix (3 rows and 4 columns), where the first dimension has three elements, and the second dimension has four elements.

Format: (i1, i2, ..., in), where i1 to in are positive integers.

dtype

Specifies the data type of a tensor object.

Value range: float16, float32, int8, int16, int32, uint8, uint16, bfloat16, bool, and more

format

Specifies the physical data layout format. For details, see Data Layout Formats.

Node

A node (operator) consists of its name, type, input, output, and attributes.
Table 2 Operator attributes

Attribute

Definition

name

Specifies the name of an operator, which is used to identify the operator in a graph. The operator name must be unique in a graph. As shown in the following figure, a graph contains operators Conv1, Pool1, and Conv2. Both Conv1 and Conv2 are of the convolution type, and each indicates a convolution operation.

type

Each operator is implemented based on the operator type on the network. Operators of the same type have the same implementation logic. A graph may contain multiple operators of the same type. For example, the graph in the preceding figure contains two convolution operators, Conv1 and Conv2.

input

Specifies the input tensor data of the operator.

output

Specifies the output tensor data of the operator.

Attributes

Defines the operator behavior and function. Common operator attributes include axis, weight, and bias.

Graph

A graph consists of the name, operator list, input operator, and output operator.
Table 3 Graph attributes

Attribute

Definition

name

Specifies the name of a graph, which is used to identify the graph on the network. The graph name must be unique on the network.

Operator list

Indicates the list of all nodes in the graph.

input

Indicates the input operator of the graph.

output

Indicates the output operator of the graph.