# US 2019/0318225 A1 · Tuning of loop orders in blocked dense basic linear algebra subroutines

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

- Number: US 2019/0318225 A1
- Document ID: US20190318225A1
- Status: Published application
- Kind: A1
- Application number: 16/454,318
- Filed: 2019-06-27
- Published: 2019-10-17
- Earliest claimed: 2019-06-27
- Assignees: Intel Corporation
- Applicants: Intel Corporation
- Inventors: Alexander Heinecke; Evangelos Georganas; Justin Gottschlich
- Web page: https://patentgrep.com/patent/US20190318225A1

## CPC

- G06N 3/0418: {using chaos or fractal principles}
- G06F 8/4442: {Reducing the number of cache misses; Data prefetching (cache prefetching G06F12/0862)}
- G06F 8/445: {Exploiting fine grain parallelism, i.e. parallelism at instruction level (run-time instruction scheduling G06F9/3836)}
- G06F 9/30065: {Loop control instructions; iterative instructions, e.g. LOOP, REPEAT}
- G06F 9/45516: {Runtime code conversion or optimisation}
- 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/0455: Auto-encoder networks; Encoder-decoder networks
- G06N 3/0475: Generative networks
- G06N 3/08: Learning methods
- G06N 3/082: modifying the architecture, e.g. adding, deleting or silencing nodes or connections
- G06N 3/045: Combinations of networks
- G06N 3/047: Probabilistic or stochastic networks
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

An example includes a sequence generator to generate a plurality of sequence pairs, a first one of the sequence pairs including: (i) a first input sequence representing first accesses to first tensors in a first loop nest of a first computer program, and (ii) a first output sequence representing a first tuned loop nest corresponding to the first accesses to the first tensors in the first loop nest; a model trainer to train a recurrent neural network based on the sequence pairs as training data, the recurrent neural network to be trained to tune loop ordering of a second computer program based on a second input sequence representing second accesses to a second tensor in a second loop nest of the second computer program; and a memory interface to store, in memory, a trained model corresponding to the recurrent neural network.

## Claims

### Claim 1

An apparatus to tune loop ordering in computer programs, the apparatus comprising:
a sequence generator to generate a plurality of sequence pairs, a first one of the sequence pairs including: (i) a first input sequence representing first accesses to first tensors in a first loop nest of a first computer program, and (ii) a first output sequence representing a first tuned loop nest corresponding to the first accesses to the first tensors in the first loop nest;
a model trainer to train a recurrent neural network using the sequence pairs as training data, the recurrent neural network to be trained to tune loop ordering of a second computer program based on a second input sequence representing second accesses to second tensors in a second loop nest of the second computer program; and
a memory interface to store, in memory, a trained model corresponding to the recurrent neural network.

### Claim 2 (depends on 1)

The apparatus as defined in claim 1, further including:
a comparator to compare a target performance to a second performance of a second output sequence predicted by the trained model, the second output sequence representing a second tuned loop nest corresponding to the second accesses to the second tensors in the second loop nest; and
when the comparison indicates that the second performance satisfies the target performance, the model trainer is to re-train the trained model based on a second sequence pair including the second input sequence and the second output sequence.

### Claim 3 (depends on 2)

The apparatus as defined in claim 2, wherein when the second performance does not satisfy the target performance, the model trainer is to re-train the trained model based on a third sequence pair including the second input sequence and a third output sequence, the third output sequence based on a manual tuning of the second input sequence.

### Claim 4 (depends on 2)

The apparatus as defined in claim 2, wherein the target performance is based on a loop order tuning performed separate from the trained model.

### Claim 5 (depends on 1)

The apparatus as defined in claim 1, wherein the recurrent neural network is a long short-term memory network or a generative adversarial network.

### Claim 6 (depends on 1)

The apparatus as defined in claim 1, wherein the first input sequence includes a variable that encodes an affine transformation of a loop index of the first loop nest.

### Claim 7

A non-transitory computer readable storage medium comprising instructions that, when executed by a processor, cause the processor to at least:
generate a plurality of sequence pairs, a first one of the sequence pairs including: (i) a first input sequence representing first accesses to first tensors in a first loop nest of a first computer program, and (ii) a first output sequence representing a first tuned loop nest corresponding to the first accesses to the first tensors in the first loop nest;
train a recurrent neural network using the sequence pairs as training data, the recurrent neural network to be trained to tune loop ordering of a second computer program based on a second input sequence representing second accesses to second tensors in a second loop nest of the second computer program; and
store, in memory, a trained model corresponding to the recurrent neural network.

### Claim 8 (depends on 7)

The non-transitory computer readable storage medium as defined in claim 7, wherein the instructions are further to cause the processor to:
compare a target performance to a second performance of a second output sequence predicted by the trained model, the second output sequence representing a second tuned loop nest corresponding to the second accesses to the second tensors in the second loop nest; and
when the comparison indicates that the second performance satisfies the target performance, re-train the trained model based on a second sequence pair including the second input sequence and the second output sequence.

### Claim 9 (depends on 8)

The non-transitory computer readable storage medium as defined in claim 8, wherein when the second performance does not satisfy the target performance, the instructions are further to cause the processor to re-train the trained model based on a third sequence pair including the second input sequence and a third output sequence, the third output sequence based on a manual tuning of the second input sequence.

### Claim 10 (depends on 8)

The non-transitory computer readable storage medium as defined in claim 8, wherein the target performance is based on a loop order tuning performed separate from the trained model.

### Claim 11 (depends on 7)

The non-transitory computer readable storage medium as defined in claim 7, wherein the recurrent neural network is a long short-term memory network or a generative adversarial network.

### Claim 12 (depends on 7)

The non-transitory computer readable storage medium as defined in claim 7, wherein the first input sequence includes a variable that encodes an affine transformation of a loop index of the first loop nest.

### Claim 13

A method to tune loop ordering in computer programs, the method comprising:
generating a plurality of sequence pairs, a first one of the sequence pairs including: (i) a first input sequence representing first accesses to first tensors in a first loop nest of a first computer program, and (ii) a first output sequence representing a first tuned loop nest corresponding to the first accesses to the first tensors in the first loop nest;
training a recurrent neural network using the sequence pairs as training data, the recurrent neural network to be trained to tune loop ordering of a second computer program based on a second input sequence representing second accesses to second tensors in a second loop nest of the second computer program; and
storing, in memory, a trained model corresponding to the recurrent neural network.

### Claim 14 (depends on 13)

The method as defined in claim 13, further including:
comparing a target performance to a second performance of a second output sequence predicted by the trained model, the second output sequence representing a second tuned loop nest corresponding to the second accesses to the second tensors in the second loop nest; and
when the comparison indicates that the second performance satisfies the target performance, re-training the trained model based on a second sequence pair including the second input sequence and the second output sequence.

### Claim 15 (depends on 14)

The method as defined in claim 14, further including, when the second performance does not satisfy the target performance, re-training the trained model based on a third sequence pair including the second input sequence and a third output sequence, the third output sequence based on a manual tuning of the second input sequence.

### Claim 16 (depends on 14)

The method as defined in claim 14, wherein the target performance is based on a loop order tuning performed separate from the trained model.

### Claim 17 (depends on 13)

The method as defined in claim 13, wherein the recurrent neural network is a long short-term memory network or a generative adversarial network.

### Claim 18 (depends on 13)

The method as defined in claim 13, wherein the first input sequence includes a variable that encodes an affine transformation of a loop index of the first loop nest.

### Claim 19

An apparatus to tune loop ordering in computer programs, the apparatus comprising:
means for generating a plurality of sequence pairs, a first one of the sequence pairs including: (i) a first input sequence representing first accesses to first tensors in a first loop nest of a first computer program, and (ii) a first output sequence representing a first tuned loop nest corresponding to the first accesses to the first tensors in the first loop nest;
means for training a recurrent neural network using the sequence pairs as training data, the recurrent neural network to be trained to tune loop ordering of a second computer program based on a second input sequence representing second accesses to second tensors in a second loop nest of the second computer program; and
means for storing, in memory, a trained model corresponding to the recurrent neural network.

### Claim 20 (depends on 19)

The apparatus as defined in claim 19, further including:
means for comparing a target performance to a second performance of a second output sequence predicted by the trained model, the second output sequence representing a second tuned loop nest corresponding to the second accesses to the second tensors in the second loop nest; and
when the comparison indicates that the second performance satisfies the target performance, the means for training is to re-train the trained model based on a second sequence pair including the second input sequence and the second output sequence.

### Claim 21 (depends on 20)

The apparatus as defined in claim 20, wherein when the second performance does not satisfy the target performance, the means for training is to re-train the trained model based on a third sequence pair including the second input sequence and a third output sequence, the third output sequence based on a manual tuning of the second input sequence.

### Claim 22 (depends on 20)

The apparatus as defined in claim 20, wherein the target performance is based on a loop order tuning performed separate from the trained model.

### Claim 23 (depends on 19)

The apparatus as defined in claim 19, wherein the recurrent neural network is a long short-term memory network or a generative adversarial network.

### Claim 24 (depends on 19)

The apparatus as defined in claim 19, wherein the first input sequence includes a variable that encodes an affine transformation of a loop index of the first loop nest.
