# US 2021/0286860 A1 · Method and device for matrix multiplication optimization using vector registers

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

- Number: US 2021/0286860 A1
- Document ID: US20210286860A1
- Status: Published application
- Kind: A1
- Application number: 16/818,833
- Filed: 2020-03-13
- Published: 2021-09-16
- Earliest claimed: 2020-03-13
- Assignees: Alibaba Group Holding Limited
- Applicants: Alibaba Group Holding Limited
- Inventors: Guoyang CHEN; Yu PU; Yongzhi ZHANG; Weifeng ZHANG; Yuan XIE
- Web page: https://patentgrep.com/patent/US20210286860A1

## CPC

- G06F 17/16: Matrix or vector computation {, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization (matrix transposition G06F7/78)}
- G06N 3/04: Architecture, e.g. interconnection topology
- G06N 3/0464: Convolutional networks [CNN, ConvNet]
- G06N 3/0495: Quantised networks; Sparse networks; Compressed networks
- G06N 3/063: using electronic means
- G06N 3/082: modifying the architecture, e.g. adding, deleting or silencing nodes or connections
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

Methods and devices, the method including receiving a matrix of a neural network model; classifying at least a portion of the matrix as a first section based on a first distribution pattern of non-zero elements of the portion of the matrix; and identifying memory addresses of the non-zero elements in the first section of the matrix for loading, according to a first order determined based on the first distribution pattern, the non-zero elements in the first section into one or more vector registers.

## Claims

### Claim 1

A method comprising:
receiving a matrix of a neural network model;
classifying at least a portion of the matrix as a first section based on a first distribution pattern of non-zero elements of the portion of the matrix; and
identifying memory addresses of the non-zero elements in the first section of the matrix for loading, according to a first order determined based on the first distribution pattern, the non-zero elements in the first section into one or more vector registers.

### Claim 2 (depends on 1)

The method of claim 1, wherein identifying the memory addresses of the non-zero elements in the first section of the matrix for loading, according to a first order determined based on the first distribution pattern, the non-zero elements in the first section into the one or more vector registers comprises:
identifying the memory addresses of the non-zero elements in a first row of the first section of the matrix for loading the non-zero elements in the first row into a first vector register of the one or more vector registers.

### Claim 3 (depends on 1)

The method of claim 1, wherein identifying the memory addresses of the non-zero elements in the first section of the matrix for loading, according to a first order determined based on the first distribution pattern, the non-zero elements in the first section into one or more vector registers comprises:
identifying the memory addresses of the non-zero elements in a second row of the first section of the matrix for loading the non-zero elements in the second row into a second vector register of the one or more vector registers.

### Claim 4 (depends on 3)

The method of claim 3, wherein the matrix is a weight matrix of the neural network model, the method further comprising:
receiving an input matrix of the neural network model;
performing a matrix multiplication operation between the weight matrix and the input matrix by multiplying the non-zero elements in the first row in the first section of the weight matrix with corresponding elements in the input matrix based on the identified memory addresses of the non-zero elements in the first row in the first section, and multiplying the non-zero elements in the second row in the first section of the weight matrix with corresponding elements in the input matrix based on the identified memory addresses of the non-zero elements in the second row in the first section.

### Claim 5 (depends on 1)

The method of claim 1, wherein the portion of the matrix is a first portion, the method further comprising:
classifying at least a second portion of the matrix as a second section based on a second distribution pattern of non-zero element of the second portion of the matrix that is different from the first distribution pattern.

### Claim 6 (depends on 5)

The method of claim 5, further comprising:
identifying memory addresses of the non-zero elements of the second section of the matrix for loading, according to a second order determined based on the second distribution pattern, the non-zero elements in the second section into one or more vector registers.

### Claim 7 (depends on 5)

The method of claim 5, wherein classifying at least the second portion of the matrix as the second section comprises:
determining whether the second distribution pattern comprises a second group of non-zero elements occupying a second number of rows and a second number of columns, the second number of the occupied rows being equal to or greater than the second number of the occupied columns.

### Claim 8 (depends on 1)

The method of claim 1, wherein classifying at least the first portion of the matrix as the first section comprises:
determining whether the first distribution pattern comprises a first group of non-zero elements occupying a first number of rows and a first number of columns, the first number of the occupied rows being smaller than the first number of the occupied columns.

### Claim 9 (depends on 1)

The method of claim 1, wherein
the matrix is a pruned matrix.

### Claim 10 (depends on 1)

The method of claim 1, further comprising
generating an instruction set based on the memory addresses of the non-zero elements in the first section of the matrix to load the non-zero elements in the first section into the one or more vector registers.

### Claim 11 (depends on 10)

The method of claim 10, wherein generating an instruction set based on the memory addresses of the non-zero elements in the first section of the matrix to load the non-zero elements in the first section into the one or more vector registers comprises:
generating one or more instructions of the instruction set based on the memory addresses of the non-zero elements in the first row of the first section of the matrix to load the non-zero elements in the first row of the first section into the first vector register.

### Claim 12

An apparatus comprising:
a memory storing a set of instructions; and
one or more processors configured to execute the set of instruction to cause the apparatus to perform:
receiving a matrix of a neural network model,
classifying at least a portion of the matrix as a first section based on a first distribution pattern of non-zero elements of the portion of the matrix, and
identifying memory addresses of the non-zero elements in the first section of the matrix for loading, according to a first order determined based on the first distribution pattern, the non-zero elements in the first section into one or more vector registers.

### Claim 13

A non-transitory computer readable medium that stores a set of instructions that is executable by at least one processor of a computer to cause the computer to perform a method, the method comprising:
receiving a matrix of a neural network model;
classifying at least a portion of the matrix as a first section based on a first distribution pattern of non-zero elements of the portion of the matrix; and
identifying memory addresses of the non-zero elements in the first section of the matrix for loading, according to a first order determined based on the first distribution pattern, the non-zero elements in the first section into one or more vector registers.

### Claim 14 (depends on 13)

The non-transitory computer readable medium of claim 13, wherein identifying the memory addresses of the non-zero elements in the first section of the matrix for loading, according to a first order determined based on the first distribution pattern, the non-zero elements in the first section into the one or more vector registers comprises:
identifying the memory addresses of the non-zero elements in a first row of the first section of the matrix for loading the non-zero elements in the first row into a first vector register of the one or more vector registers.

### Claim 15 (depends on 13)

The non-transitory computer readable medium of claim 13, wherein identifying the memory addresses of the non-zero elements in the first section of the matrix for loading, according to a first order determined based on the first distribution pattern, the non-zero elements in the first section into the one or more vector registers comprises:
identifying the memory addresses of the non-zero elements in a second row of the first section of the matrix for loading the non-zero elements in the second row into a second vector register of the one or more vector registers.

### Claim 16 (depends on 15)

The non-transitory computer readable medium of claim 15, wherein the matrix is a weight matrix of the neural network model, the set of instructions that are executable by the at least one processor of a computer to cause the computer to further perform:
receiving an input matrix of the neural network model;
performing a matrix multiplication operation between the weight matrix and the input matrix by multiplying the non-zero elements in the first row in the first section of the weight matrix with corresponding elements in the input matrix based on the identified memory addresses of the non-zero elements in the first row in the first section, and multiplying the non-zero elements in the second row in the first section of the weight matrix with corresponding elements in the input matrix based on the identified memory addresses of the non-zero elements in the second row in the first section.

### Claim 17 (depends on 13)

The non-transitory computer readable medium of claim 13, wherein the portion of the matrix is a first portion, the set of instructions that are executable by the at least one processor of a computer to cause the computer to further perform:
classifying at least a second portion of the matrix as a second section based on a second distribution pattern of non-zero element of the second portion of the matrix that is different from the first distribution pattern.

### Claim 18 (depends on 17)

The non-transitory computer readable medium of claim 17, wherein the set of instructions that are executable by the at least one processor of a computer to cause the computer to further perform:
identifying memory addresses of the non-zero elements of the second section of the matrix for loading, according to a second order determined based on the second distribution pattern, the non-zero elements in the second section into one or more vector registers.

### Claim 19 (depends on 17)

The non-transitory computer readable medium of claim 17, wherein classifying at least the second portion of the matrix as the second section comprises:
determining whether the second distribution pattern comprises a second group of non-zero elements occupying a second number of rows and a second number of columns, the second number of the occupied rows being equal to or greater than the second number of the occupied columns.

### Claim 20 (depends on 13)

The non-transitory computer readable medium of claim 13, wherein classifying at least the first portion of the matrix as the first section comprises:
determining whether the first distribution pattern comprises a first group of non-zero elements occupying a first number of rows and a first number of columns, the first number of the occupied rows being smaller than the first number of the occupied columns.
