# US 2020/0272464 A1 · Matrix Computation Engine

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

- Number: US 2020/0272464 A1
- Document ID: US20200272464A1
- Status: Published application
- Kind: A1
- Application number: 16/818,200
- Filed: 2020-03-13
- Published: 2020-08-27
- Earliest claimed: 2017-11-01
- Assignees: Apple Inc.
- Applicants: Apple Inc.
- Inventors: Eric Bainville; Tal Uliel; Erik Norden; Jeffry E. Gonion; Ali Sazegari
- Web page: https://patentgrep.com/patent/US20200272464A1

## CPC

- G06F 9/30014: {with variable precision}
- G06F 7/5443: {Sum of products (for applications thereof, see the relevant places, e.g. G06F17/10, H03H17/00)}
- G06F 9/30036: {Instructions to perform operations on packed data, e.g. vector, tile or matrix operations}
- G06F 9/30043: {LOAD or STORE instructions; Clear instruction}
- G06F 9/30109: {having multiple operands in a single register}
- G06F 9/3887: {controlled by a single instruction for multiple data lanes [SIMD]}
- G06F 17/16: Matrix or vector computation {, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization (matrix transposition G06F7/78)}
- G06N 3/044: Recurrent networks, e.g. Hopfield networks
- G06N 3/0442: characterised by memory or gating, e.g. long short-term memory [LSTM] or gated recurrent units [GRU]
- G06N 3/063: using electronic means
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

In an embodiment, a matrix computation engine is configured to perform matrix computations (e.g. matrix multiplications). The matrix computation engine may perform numerous matrix computations in parallel, in an embodiment. More particularly, the matrix computation engine may be configured to perform numerous multiplication operations in parallel on input matrix elements, generating resulting matrix elements. In an embodiment, the matrix computation engine may be configured to accumulate results in a result memory, performing multiply-accumulate operations for each matrix element of each matrix.

## Claims

### Claim at position 1

1-20. (canceled)

### Claim 21

An apparatus comprising:
a processor configured to detect a matrix computation instruction, wherein the processor comprises a first cache;
a matrix computation engine coupled to the processor, wherein:
the processor is configured to transmit the matrix computation instruction to the matrix computation engine;
the matrix computation engine is configured to perform a matrix multiplication operation in response to the matrix computation instruction;
the matrix computation engine comprises at least two input memories configured to store input vectors of matrices for the matrix multiplication operation and an output memory configured to accumulate an output vector of matrices; and
the matrix computation engine comprises a multiply accumulate (MAC) circuit configured to perform the matrix multiplication operation on the input vectors of matrices, generating the output vector of matrices for the output memory; and
a second cache coupled to the processor and the matrix computation engine, wherein:
the matrix computation engine is configured to access data in the second cache responsive to a memory instruction from the processor; and
the second cache is configured to ensure cache coherence with the first cache responsive to the memory instruction.

### Claim 22 (depends on 21)

The apparatus as recited in claim 21 wherein the MAC circuit comprises a plurality of MACs, each MAC configured to generate one matrix element of one matrix in the output vector.

### Claim 23 (depends on 22)

The apparatus as recited in claim 22 wherein a number of the plurality of MACs is at least equal to a number of matrix elements in the output vector.

### Claim 24 (depends on 21)

The apparatus as recited in claim 21 wherein the MAC circuit is configured to perform matrix multiplications on matrix elements having a first size, and wherein a first input vector stored in one of the at least two input memories includes matrix elements having a second size less than the first size, wherein the matrix computation engine is configured to map matrix elements from the first input vector to second matrix elements having the first size using a lookup table, wherein the second matrix elements are provided to the MAC circuit for the matrix multiplication operation.

### Claim 25 (depends on 24)

The apparatus as recited in claim 24 wherein the lookup table is programmable from the processor.

### Claim 26 (depends on 24)

The apparatus as recited in claim 24 wherein the lookup table is stored in one of the at least two input memories.

### Claim 27 (depends on 21)

The apparatus as recited in claim 21 wherein the matrix computation engine comprises an instruction buffer configured to store a plurality of instructions transmitted to the matrix computation engine by the processor to be executed by the matrix computation engine.

### Claim 28

A matrix computation engine comprising:
a first operand memory configured to store a first vector comprising a first plurality of matrices;
a second operand memory configured to store a second vector comprising a second plurality of matrices; and
a plurality of multiply-accumulate (MAC) circuits coupled to the first operand memory and the second operand memory, wherein the plurality of MAC circuits are configured to multiply the first vector and the second vector to generate a result vector comprising a third plurality of matrices, wherein a number of the plurality of MAC circuits is at least equal to a number of matrix elements in the third plurality of matrices.

### Claim 29 (depends on 28)

The matrix computation engine as recited in claim 28 further comprising an output memory configured to store the result vector comprising the third plurality of matrices, wherein the plurality of MAC circuits are configured to add a previous value of the result vector from the output memory to a result of the first vector and the second vector.

### Claim 30 (depends on 28)

The matrix computation engine as recited in claim 28 wherein the plurality of MAC circuits are configured to multiple matrix elements of a first size, and wherein at least the first plurality of matrices have matrix elements of a second size that is smaller than the first size, and wherein the matrix computation engine comprises a lookup table mapping matrix elements of the second size to matrix elements of the first size.

### Claim 31 (depends on 30)

The matrix computation engine as recited in claim 30 wherein the lookup table is programmable.

### Claim 32 (depends on 30)

The matrix computation engine as recited in claim 30 wherein the lookup table is stored in one of the first operand memory or the second operand memory.

### Claim 33 (depends on 28)

The matrix computation engine as recited in claim 28 further comprising an instruction buffer configured to store a plurality of instructions transmitted to the matrix computation engine for execution.

### Claim 34

A method comprising:
receiving a matrix computation instruction from a processor to a matrix computation engine, wherein the processor comprises a first cache;
performing, by the matrix computation engine, a matrix multiplication operation in response to the matrix computation instruction, wherein the matrix computation engine comprises at least two input memories configured to store input vectors of matrices for the matrix multiplication operation and an output memory configured to accumulate an output vector of matrices, and wherein the matrix computation engine comprises a multiply accumulate (MAC) circuit configured to perform the matrix multiplication operation on the input vectors of matrices, generating the output vector of matrices for the output memory;
receiving a memory instruction in the matrix computation engine from the processor;
accessing a second cache in response to the memory instruction by the matrix computation engine, the second cache coupled to the processor and the matrix computation engine; and
ensuring, by the second cache, cache coherence with the first cache responsive to the memory instruction.

### Claim 35 (depends on 34)

The method as recited in claim 34 wherein the MAC circuit comprises a plurality of MACs, each MAC configured to generate one matrix element of one matrix in the output vector.

### Claim 36 (depends on 35)

The method as recited in claim 35 wherein a number of the plurality of MACs is at least equal to a number of matrix elements in the output vector.

### Claim 37 (depends on 34)

The method as recited in claim 34 further comprising
performing, by the MAC circuit, matrix multiplications on matrix elements having a first size, and wherein a first input vector stored in one of the at least two input memories includes matrix elements having a second size less than the first size; and
mapping matrix elements from the first input vector to second matrix elements having the first size using a lookup table in the matrix computation engine, wherein the second matrix elements are provided to the MAC circuit for the matrix multiplication operation.

### Claim 38 (depends on 37)

The method as recited in claim 37 further comprising programming the lookup table from the processor.

### Claim 39 (depends on 37)

The method as recited in claim 37 wherein the lookup table is stored in one of the at least two input memories.

### Claim 40 (depends on 34)

The method as recited in claim 34 wherein the matrix computation engine comprises an instruction buffer, and the method further comprises storing a plurality of instructions receiving by the matrix computation engine from the processor to be executed by the matrix computation engine.
