Tensor/Node/Graph

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

Figure 1 Computational graph represented 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 × 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 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. It is used to identify the operator in a graph and must be unique. 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

Specifies the type of an operator. Each operator is implemented based on the operator type on the graph. 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. Each graph name must be unique on the same 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.