# US 12,608,172 B2 · Matrix computing method, chip, and related device

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

- Number: US 12,608,172 B2
- Document ID: US12608172B2
- Status: Granted
- Kind: B2
- Application number: 18/748,393
- Filed: 2024-06-20
- Published: 2024-10-10
- Granted: 2026-04-21
- Earliest claimed: 2021-12-20
- Assignees: Huawei Technologies Co., Ltd.
- Applicants: Huawei Technologies Co., Ltd.
- Inventors: Guangning Fu; Tengyi Lin
- Web page: https://patentgrep.com/patent/US12608172B2

## CPC

- G06F 3/06: Digital input from, or digital output to, record carriers {, e.g. RAID, emulated record carriers or networked record carriers}
- G06F 5/16: Multiplexed systems, i.e. using two or more similar devices which are alternately accessed for enqueue and dequeue operations, e.g. ping-pong buffers
- G06F 3/0656: {Data buffering arrangements}
- G06F 9/3836: {Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution}
- G06F 17/16: Matrix or vector computation {, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization (matrix transposition G06F7/78)}
- G06F 7/5443: {Sum of products (for applications thereof, see the relevant places, e.g. G06F17/10, H03H17/00)}
- Y02D 10/00: Energy efficient computing, e.g. low power processors, power management or thermal management
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- Y02D: CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE

## Abstract

This application provides a matrix computing method, a chip, and a related device. The chip includes a first buffer, is configured to buffer a first vector, and a second buffer is configured to buffer a second vector. A scheduling module generates a selection signal based on a bitmap of the first vector. The selection signal may cause the processing element to obtain, from the first buffer, a group of non-zero elements in the first vector, and cause the processing element to obtain, from the second buffer, a group of elements in the second vector. An operation is performed between the first vector and the second vector based on the group of non-zero elements in the first vector and the group of elements in the second vector. In this application, an element whose value is 0 in one vector may be excluded from computing, to reduce a computing amount.

## Claims

### Claim 1

A chip, comprising:
a first buffer, configured to buffer a first vector;
a second buffer, configured to buffer a second vector;
a first scheduler, configured to generate a first selection signal based on a bitmap of the first vector, wherein the first selection signal causes a first processor to:
obtain, from the first buffer, a first group of non-zero elements in the first vector, and
obtain, from the second buffer, a second group of elements in the second vector, and the bitmap of the first vector indicates a non-zero element in the first vector;
the first processor, configured to implement an operation between the first vector and the second vector based on the first group of non-zero elements and the second group of elements;
a first multiplexer comprising K multi-path multiplexers, each multi-path multiplexer in the first multiplexer is connected to a plurality of data units in the first buffer, and each data unit is connected to at least one multi-path multiplexer, wherein K is an integer greater than 1; and
a second multiplexer comprising K multi-path multiplexers, a connection relationship between an ith multi-path multiplexer in the second multiplexer and a data unit in the second buffer is same as a connection relationship between an ith multi-path multiplexer in the first multiplexer and a data unit in the first buffer.

### Claim 2 (depends on 1)

The chip according to claim 1, wherein
the first multiplexer is configured to:
obtain, from the first buffer, the first group of non-zero elements in the first vector based on the first selection signal, and
input the first group of non-zero elements into the first processor; and
the second multiplexer is configured to:
obtain, from the second buffer, the second group of elements in the second vector based on the first selection signal, and
input the second group of elements into the first processor.

### Claim 3 (depends on 2)

The chip according to claim 2, wherein
the first buffer and the second buffer each comprises W rows and K columns of data units, and each data unit is configured to buffer one element, wherein W is an integer greater than 1.

### Claim 4 (depends on 3)

The chip according to claim 3, wherein the first scheduler is configured to:
determine, based on the bitmap of the first vector, that an element stored in a kth data unit in data units connected to a jth multi-path multiplexer in the first multiplexer is a non-zero element;
generate a selection signal of the jth multi-path multiplexer; and
send the selection signal of the jth multi-path multiplexer to the jth multi-path multiplexer in the first multiplexer and a jth multi-path multiplexer in the second multiplexer, wherein the first selection signal comprises the selection signal of the jth multi-path multiplexer in the first multiplexer.

### Claim 5 (depends on 4)

The chip according to claim 4, wherein the first vector belongs to a row in a first matrix, and the second vector belongs to a column in a second matrix.

### Claim 6 (depends on 5)

The chip according to claim 5, wherein the chip further comprises a third buffer and a second processor, wherein
the third buffer is configured to buffer a third vector, wherein the third vector belongs to a column in the second matrix other than a column in which the second vector is located, and the first selection signal is further used to cause the second processor to obtain, from the third buffer, a third group of elements in the third vector; and
the second processor is configured to implement an operation between the first vector and the third vector based on the first group of non-zero elements and the third group of elements.

### Claim 7 (depends on 6)

The chip according to claim 6, wherein the chip further comprises a third multiplexer, configured to obtain, from the third buffer, the third group of elements in the third vector based on the first selection signal, and input the third group of elements into the second processor.

### Claim 8 (depends on 5)

The chip according to claim 5, wherein the chip further comprises a fourth buffer, a second scheduler and a third processor, wherein
the fourth buffer is configured to buffer a fourth vector, wherein the fourth vector belongs to a row in the first matrix other than a row in which the first vector is located;
the second scheduler is configured to generate a second selection signal based on a bitmap of the fourth vector, wherein the second selection signal causes the third processor to:
obtain, from the fourth buffer, a fourth group of non-zero elements in the fourth vector, and
obtain, from the second buffer, a fifth group of elements in the second vector, and the bitmap of the fourth vector indicates a non-zero element in the fourth vector; and
the third processor is configured to implement an operation between the fourth vector and the second vector based on the fourth group of non-zero elements and the fifth group of elements.

### Claim 9 (depends on 8)

The chip according to claim 8, wherein the chip further comprises a fourth multiplexer and a fifth multiplexer, wherein
the fourth multiplexer is configured to:
obtain, from the fourth buffer, the fourth group of non-zero elements in the fourth vector based on the second selection signal, and
input the fourth group of non-zero elements into the third processor; and
the fifth multiplexer is configured to:
obtain, from the second buffer, the fifth group of elements in the second vector based on the second selection signal, and
input the fifth group of elements into the third processor.

### Claim 10 (depends on 1)

The chip according to claim 1, wherein the first scheduler is further configured to generate an erasing signal after the operation between the first vector and the second vector is implemented, wherein the erasing signal indicates the first buffer and the second buffer to erase currently buffered data.

### Claim 11

A method for computing matrix on a chip, wherein the method comprises:
buffering, by the chip, a first vector and a second vector, wherein the first vector is buffered in a first buffer, and the second vector is buffered in a second buffer, wherein a plurality of data units in the first buffer are connected to each of K multi-path multiplexers comprised in a first multiplexer of the chip, K is an integer greater than 1, and a connection relationship between an ith multi-path multiplexer in a second multiplexer of the chip comprising K multi-path multiplexers and a data unit in the second buffer is same as a connection relationship between an ith multi-path multiplexer in the first multiplexer and a data unit in the first buffer;
generating, by a first scheduler of the chip, a first selection signal based on a bitmap of the first vector, wherein the first selection signal causes a first processor to:
obtain, from the first buffer, a first group of non-zero elements in the first vector, and
obtain, from the second buffer, a second group of elements in the second vector, and the bitmap of the first vector indicates a non-zero element in the first vector; and
implementing, by the first processor of the chip, an operation between the first vector and the second vector based on the first group of non-zero elements and the second group of elements.

### Claim 12 (depends on 11)

The method according to claim 11, wherein the method further comprises:
obtaining, by the first multiplexer of the chip and from the first buffer, the first group of non-zero elements in the first vector based on the first selection signal, and inputting the first group of non-zero elements into the first processor; and
obtaining, by the second multiplexer of the chip and from the second buffer, the second group of elements in the second vector based on the first selection signal, and inputting the second group of elements into the first processor.

### Claim 13 (depends on 12)

The method according to claim 12, wherein the first buffer and the second buffer each comprises W rows and K columns of data units, and each data unit is configured to buffer one element, wherein K is an integer greater than 1.

### Claim 14 (depends on 13)

The method according to claim 13, wherein the generating, by a first scheduler of the chip, a first selection signal based on a bitmap of the first vector comprises:
determining, by the first scheduler of the chip based on the bitmap of the first vector, that an element stored in a kth data unit in data units connected to a jth multi-path multiplexer in the first multiplexer is a non-zero element;
generating a selection signal of the jth multi-path multiplexer; and
sending the selection signal of the jth multi-path multiplexer to the jth multi-path multiplexer in the first multiplexer and a jth multi-path multiplexer in the second multiplexer, wherein the first selection signal comprises the selection signal of the jth multi-path multiplexer in the first multiplexer.

### Claim 15 (depends on 14)

The method according to claim 14, wherein the first vector belongs to a row in a first matrix, and the second vector belongs to a column in a second matrix.

### Claim 16 (depends on 15)

The method according to claim 15, wherein the chip further comprises a third buffer and a second processor, and the method further comprises:
buffering, by the chip, a third vector, wherein the third vector is buffered in the third buffer, the third vector belongs to a column in the second matrix other than a column in which the second vector is located, and the first selection signal is further used to cause the second processor to obtain, from the third buffer, a third group of elements in the third vector; and
implementing, by the second processor of the chip, an operation between the first vector and the third vector based on the first group of non-zero elements and the third group of elements.

### Claim 17 (depends on 16)

The method according to claim 16, wherein the chip further comprises a third multiplexer, and the method further comprises:
obtaining, by the third multiplexer of the chip and from the third buffer, the third group of elements in the third vector based on the first selection signal, and inputting the third group of elements into the second processor.

### Claim 18 (depends on 15)

The method according to claim 15, wherein the chip further comprises a fourth buffer, a second scheduler and a third processor, and the method further comprises:
buffering, by the chip, a fourth vector, wherein the fourth vector is buffered in the fourth buffer, and the fourth vector belongs to a row in the first matrix other than a row in which the first vector is located;
generating, by the second scheduler of the chip, a second selection signal based on a bitmap of the fourth vector, wherein the second selection signal causes the third processor to obtain, from the fourth buffer, a fourth group of non-zero elements in the fourth vector, and
obtain, from the second buffer, a fifth group of elements in the second vector, and the bitmap of the fourth vector indicates a non-zero element in the fourth vector; and
implementing, by the third processor of the chip, an operation between the fourth vector and the second vector based on the fourth group of non-zero elements and the fifth group of elements.

### Claim 19 (depends on 18)

The method according to claim 18, wherein the chip further comprises a fourth multiplexer and a fifth multiplexer, and the method further comprises:
obtaining, by the fourth multiplexer of the chip and from the fourth buffer, the fourth group of non-zero elements in the fourth vector based on the second selection signal
inputting the fourth group of non-zero elements into the third processor; and
obtaining, by the fifth multiplexer of the chip and from the second buffer, the fifth group of elements in the second vector based on the second selection signal, and inputting the fifth group of elements into the third processor.

### Claim 20 (depends on 11)

The method according to claim 11, wherein after the implementing an operation between the first vector and the second vector based on the first group of non-zero elements and the second group of elements, the method further comprises:
generating, by the first scheduler of the chip, an erasing signal, wherein the erasing signal indicates the first buffer and the second buffer to erase currently buffered data.
