# US 2021/0279587 A1 · Method and apparatus for neural network code generation

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

- Number: US 2021/0279587 A1
- Document ID: US20210279587A1
- Status: Published application
- Kind: A1
- Application number: 17/190,832
- Filed: 2021-03-03
- Published: 2021-09-09
- Earliest claimed: 2020-03-05
- Assignees: Samsung Electronics Co., Ltd.; Snu R&Db Foundation
- Applicants: Samsung Electronics Co., Ltd.; Snu R&Db Foundation
- Inventors: Bernhard EGGER; Minsu KIM; Hyemi MIN
- Web page: https://patentgrep.com/patent/US20210279587A1

## CPC

- G06F 9/5066: {Algorithms for mapping a plurality of inter-dependent sub-tasks onto a plurality of physical CPUs (mappping at compile time, see G06F8/451)}
- G06N 3/082: modifying the architecture, e.g. adding, deleting or silencing nodes or connections
- G06F 8/35: model driven
- G06F 9/5061: {Partitioning or combining of resources}
- G06N 3/0442: characterised by memory or gating, e.g. long short-term memory [LSTM] or gated recurrent units [GRU]
- G06N 3/0455: Auto-encoder networks; Encoder-decoder networks
- G06N 3/0464: Convolutional networks [CNN, ConvNet]
- G06N 3/0475: Generative networks
- G06N 3/063: using electronic means
- G06N 3/045: Combinations of networks
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

A method and an apparatus for generating a code for a neural network operation are disclosed. The method includes receiving information on hardware configured to perform a neural network operation of the neural network, generating, using a processor, a target mapping model mapping the neural network operation on processing elements available to perform the neural network operation based on the information and a structure of the neural network, and generating a code to configure the hardware to perform the neural network operation based on the target mapping model.

## Claims

### Claim 1

A processor-implemented method of generating a code, the method comprising:
receiving information on hardware configured to perform a neural network operation of a neural network;
generating, using a processor, a target mapping model mapping the neural network operation on processing elements available to perform the neural network operation based on the information and a structure of the neural network; and
generating a code to configure the hardware to perform the neural network operation based on the target mapping model.

### Claim 2 (depends on 1)

The method of claim 1, wherein the receiving of the information comprises:
receiving any one or any combination of a number of the processing elements, a structure of the processing element, a memory bandwidth, a frequency, and a memory size.

### Claim 3 (depends on 1)

The method of claim 1, wherein the generating of the target mapping model comprises:
calculating a mapping parameter corresponding to an arbitrary mapping model based on the information and the structure; and
determining the target mapping model based on the mapping parameter.

### Claim 4 (depends on 3)

The method of claim 3, wherein the calculating of the mapping parameter comprises:
determining an operation performance for the arbitrary mapping model based on a partition structure of the neural network;
calculating a memory access size for the arbitrary mapping model based on a loop structure included in the neural network operation; and
calculating the mapping parameter based on the operation performance and the memory access size.

### Claim 5 (depends on 4)

The method of claim 4, wherein the calculating of the operation performance comprises:
calculating a utilization rate of the processing elements based on the partition structure of the neural network; and
calculating the operation performance based on the utilization rate.

### Claim 6 (depends on 4)

The method of claim 4, wherein the calculating of the memory access size comprises:
calculating a number of data reload of the arbitrary mapping model based on the loop structure; and
calculating the memory access size based on the number of data reload and the partition structure.

### Claim 7 (depends on 3)

The method of claim 3, wherein the determining of the target mapping model based on the mapping parameter comprises:
determining an arbitrary mapping model that maximizes the mapping parameter to be the target mapping model.

### Claim 8 (depends on 3)

The method of claim 3, wherein the generating of the target mapping model further comprises:
pruning an inadequate mapping model based on a partition structure of the neural network and a loop structure included in the neural network operation.

### Claim 9 (depends on 8)

The method of claim 8, wherein the pruning of the inadequate mapping model comprises:
pruning the inadequate mapping model based on a partition structure of a neural network according to a utilization rate of the processing elements.

### Claim 10 (depends on 8)

The method of claim 8, wherein the pruning of the inadequate mapping model comprises:
pruning the inadequate mapping model based on a number of iterations of the loop structure.

### Claim 11

An apparatus for generating a code, the apparatus comprising:
a receiver configured to receive information on hardware configured to perform a neural network operation of a neural network; and
a processor configured to generate a target mapping model mapping the neural network operation on processing elements available to perform the neural network operation based on the information and a structure of the neural network and to generate a code to configure the hardware to perform the neural network operation based on the target mapping model.

### Claim 12 (depends on 11)

The apparatus of claim 11, wherein the receiver is further configured to receive any one or any combination of a number of the processing elements, a structure of the processing element, a memory bandwidth, a frequency, and a memory size.

### Claim 13 (depends on 11)

The apparatus of claim 11, wherein the processor is further configured to:
calculate a mapping parameter corresponding to an arbitrary mapping model based on the information and the structure; and
determine the target mapping model based on the mapping parameter.

### Claim 14 (depends on 13)

The apparatus of claim 13, wherein the processor is further configured to:
calculate an operation performance to be attained by the arbitrary mapping model based on a partition structure of the neural network;
calculate a memory access size for the arbitrary mapping model based on a loop structure included in the neural network operation; and
calculate the mapping parameter based on the operation performance and the memory access size.

### Claim 15 (depends on 14)

The apparatus of claim 14, wherein the processor is further configured to:
calculate a utilization rate of the processing elements based on the partition structure of the neural network; and
calculate the operation performance based on the utilization rate.

### Claim 16 (depends on 14)

The apparatus of claim 14, wherein the processor is further configured to:
calculate a number of data reload of the arbitrary mapping model based on the loop structure; and
calculate the memory access size based on the number of data reload and the partition structure.

### Claim 17 (depends on 13)

The apparatus of claim 13, wherein the processor is further configured to:
determine an arbitrary mapping model that maximizes the mapping parameter to be the target mapping model.

### Claim 18 (depends on 13)

The apparatus of claim 13, wherein the processor is further configured to:
prune an inadequate mapping model based on a partition structure of the neural network and a loop structure included in the neural network operation.

### Claim 19 (depends on 18)

The apparatus of claim 18, wherein the processor is further configured to:
prune the inadequate mapping model based on a partition structure of a neural network according to a utilization rate of the processing elements.

### Claim 20 (depends on 18)

The apparatus of claim 18, wherein the processor is further configured to:
prune the inadequate mapping model based on a number of iterations of the loop structure.
