# US 2025/0156159 A1 · Computation graph optimization method, data processing method and related product

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2025/0156159 A1
- Document ID: US20250156159A1
- Status: Published application
- Kind: A1
- Application number: 18/714,317
- Filed: 2022-11-18
- Published: 2025-05-15
- Earliest claimed: 2021-11-29
- Assignees: Cambricon Technologies Corporation Limited
- Applicants: Cambricon Technologies Corporation Limited
- Inventors: GANG SHAN; YUEFENG LIANG; FENGYANG SI; WEI GU; XIUCHUAN ZHAI; JIN WANG; JINHONG ZHOU
- Web page: https://patentgrep.com/patent/US20250156159A1

## CPC

- G06F 8/41: Compilation
- G06F 8/36: Software reuse
- G06N 3/04: Architecture, e.g. interconnection topology
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

A computing apparatus performing a computing graph optimization method is included in a combined processing apparatus. The combined processing apparatus includes an interface apparatus and other processing apparatus. The computing apparatus interacts with other processing apparatus to jointly complete a computing operation specified by a user. The combined processing apparatus further includes a storage apparatus which is connected to the computing apparatus and other processing apparatus respectively and is configured to store data of the computing apparatus and other processing apparatus. The disclosed scheme may optimize data access by constructing a view-class operator subgraph. By optimizing the view-class operator subgraph, memory moving and operator calling on the device side may be reduced. By reversely deducing a view-class operator that causes tensor data to become a memory discontiguous state, a suitable computing library operator may be called to convert the tensor data into a memory contiguous state.

## Claims

### Claim at position 1

1: A computing graph optimization method, comprising:
traversing an operator associated with tensor data in a computing graph; and
extracting the operator to construct a view-class operator subgraph when the operator is a view-class operator, wherein the view-class operator subgraph is used to perform memory data contiguity processing.

### Claim at position 2 (depends on 1)

2: The method of claim 1, wherein extracting the operator to construct the view-class operator subgraph comprises:
associatively caching operator information and an operator sequence number of the operator; and
adding the operator sequence number to the view-class operator subgraph.

### Claim at position 3 (depends on 2)

3: The method of claim 2, wherein extracting the operator to construct the view-class operator subgraph further comprises:
checking whether the operator information of the operator has been cached;
generating the operator sequence number for the operator and performing the caching and adding if the operator information of the operator is not cached; and
adding the operator sequence number of the operator, which has been cached, to the view-class operator subgraph if the operator information of the operator has been cached.

### Claim at position 4 (depends on 2)

4: The method of claim 2, wherein the operator information of the operator comprises at least one of followings: description information of input data of the operator, description information of output data of the operator, and computation parameters of the operator.

### Claim at position 5 (depends on 1)

5: The method of any one of claim 1, wherein extracting the operator to construct the view-class operator subgraph further comprises:
when the operator is a multi-branch operator, constructing a view-class operator subgraph with a corresponding number of branches based on the multi-branch operator.

### Claim at position 6

6: A computing graph optimization method, comprising:
acquiring a view-class operator subgraph of tensor data in a computing graph, wherein the view-class operator subgraph comprises a view-class source operator associated with the tensor data;
replacing the source operator with a target operator whose specified function is interchangeable with that of the source operator according to a function of the source operator in the view-class operator subgraph; and
fusing a plurality of contiguous identical target operators into a single target operator to generate a fused view-class operator subgraph.

### Claim at position 7 (depends on 6)

7: The method of claim 6, wherein fusing the plurality of contiguous identical target operators into the single target operator comprises:
merging dimension operations of the plurality of target operators, such that the single target operator after the fusion is equivalent to the plurality of target operators before the fusion.

### Claim at position 8 (depends on 6)

8: The method of claim 6, further comprising:
adjusting a position of a specific type of target operator for postponement processing after the fusion is performed, wherein the specific type of target operator is an expand-class operator that causes an increase in memory data.

### Claim at position 9 (depends on 8)

9: The method of claim 8, wherein adjusting the position of the specific type of target operator for the postponement processing comprises:
according to positions of the specific type of target operator before and after the adjustment, modifying parameters of target operators between the two positions in the view-class operator subgraph to adapt to the adjustment.

### Claim 10

(canceled)

### Claim 11

(canceled)

### Claim at position 12 (depends on 1)

12: A data processing method, comprising:
acquiring a view-class operator subgraph of to-be-processed tensor data in response to the tensor data being discontiguous in memory, wherein the view-class operator subgraph is constructed or generated according to the method as claimed in claim 1; and
calling a corresponding kernel to perform data moving according to information of the view-class operator subgraph to convert the tensor data into tensor data that is contiguous in memory.

### Claim at position 13 (depends on 12)

13: The method of claim 12, wherein calling the corresponding kernel to perform the data moving comprises:
analyzing operator types in the view-class operator subgraph, and calling kernels matching the operator types to perform data moving, wherein the kernels move the data by block according to the operator types.

### Claim at position 14

14: A data processing method, comprising:
determining a view-class operator through which a to-be-processed first tensor converts from a memory contiguous state into a memory discontiguous state according to first description information of the first tensor in response to the first tensor being in the memory discontiguous state;
determining a data moving operator in a computing library that needs to be called according to the view-class operator;
determining a parameter required for calling the data moving operator to convert the first tensor from the memory discontiguous state into the memory contiguous state according to the first description information; and
calling the data moving operator according to the parameter to convert the first tensor into the memory contiguous state.

### Claim at position 15 (depends on 14)

15: The method of claim 14, wherein determining the view-class operator experienced by the first tensor comprises:
determining the view-class operator experienced by the first tensor according to first data shape information and first dimension stride information in the first description information.

### Claim at position 16 (depends on 15)

16: The method of claim 15, wherein determining the view-class operator experienced by the first tensor further comprises:
determining the view-class operator experienced by the first tensor to be a rearrangement view-class operator when a data size indicated by the first data shape information is consistent with a memory size to which the first tensor is directed, and the first dimension stride information indicates that each dimension stride is arranged in a non-descending order; or
determining the view-class operator experienced by the first tensor to be an expansion view-class operator when there is a dimension stride with a 0 value in the first dimension stride information, and a data size obtained by adjusting the first data shape information according to a position index of the 0 value is consistent with the memory size to which the first tensor data is directed.

### Claim 17

(canceled)

### Claim at position 18 (depends on 14)

18: The method of claim 14, wherein determining the data moving operator that needs to be called according to the view-class operator comprises:
determining the data moving operator that needs to be called to be a data rearrangement operator when the view-class operator is a rearrangement view-class operator; or
determining the data moving operator that needs to be called to be a data expansion operator when the view-class operator is an expansion view-class operator.

### Claim at position 19 (depends on 14)

19: The method of claim 14, wherein determining the parameter required for calling the data moving operator comprises:
determining second description information of a second tensor serving as an input tensor of the data moving operator; and
determining computation parameter information of the data moving operator.

### Claim at position 20 (depends on 19)

20: The method of claim 19, wherein determining the second description information of the second tensor comprises:
when the data moving operator is a data rearrangement operator, determining a descending arrangement of first dimension stride information in the first description information as second dimension stride information in the second description information of the second tensor, and
converting first data shape information in the first description information according to a rule of converting the first dimension stride information into the descending arrangement to obtain second data shape information in the second description information; or
when the data moving operator is a data expansion operator, acquiring a position index of a 0 value from the first dimension stride information in the first description information,
setting a corresponding position of the first data shape information in the first description information to 1 according to the position index of the 0 value to determine the second data shape information in the second description information, and
determining the second dimension stride information in the second description information according to the second data shape information and a memory contiguity rule.

### Claim 21

(canceled)

### Claim at position 22 (depends on 19)

22: The method of claim 19, wherein determining the computation parameter information of the data moving operator comprises:
when the data moving operator is a data rearrangement operator, taking the second tensor as an input of the data moving operator,
taking the first tensor as an output of the data moving operator, and
deducing the computation parameter information of the data moving operator based on the first description information and the second description information; or
when the data moving operator is a data expansion operator, taking first data shape information as the computation parameter information.

### Claim 23

(canceled)

### Claim at position 24 (depends on 1)

24: A computing apparatus configured to optimize a computing graph or perform data processing, comprising:
a processor configured to perform a program instruction; and
a storage configured to store the program instruction, wherein when the program instruction is loaded and performed by the processor, the processor performs the computing graph optimization method of claim 1.

### Claim 25

(canceled)

### Claim 26

(canceled)

### Claim at position 27 (depends on 12)

27: A computing apparatus configured to optimize a computing graph or perform data processing, comprising:
a processor configured to perform a program instruction; and
a storage configured to store the program instruction, wherein when the program instruction is loaded and performed by the processor, the data processing method of claim 12.
