# US 12,217,032 B2 · Code performance optimization based on an information-enhanced diffusion model

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

- Number: US 12,217,032 B2
- Document ID: US12217032B2
- Status: Granted
- Kind: B2
- Application number: 18/129,288
- Filed: 2023-03-31
- Published: 2024-10-03
- Granted: 2025-02-04
- Earliest claimed: 2023-03-31
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Zhong Fang Yuan; Tong Liu; Han Qiao Yu; Lin Feng; Xiang Yu Yang; Hai Bo Zou
- Web page: https://patentgrep.com/patent/US12217032B2

## CPC

- G06F 8/427: {Parsing}
- G06F 8/4441: {Reducing the execution time required by the program code}
- G06F 8/71: Version control (security arrangements therefor G06F21/57); Configuration management
- G06N 3/044: Recurrent networks, e.g. Hopfield networks
- G06N 3/045: Combinations of networks
- G06N 3/08: Learning methods
- G06N 5/01: Dynamic search techniques; Heuristics; Dynamic trees; Branch-and-bound
- G06N 20/00: Machine learning
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

A given segment of computer code is obtained and modified to produce one or more inefficient versions of the given segment of computer code in comparison to the given segment of computer code. A code parse tree is generated for the given segment of computer code and each inefficient version of the given segment of computer code. Model embeddings are generated based on the generated code parse trees and a diffusion model is trained based on the generated model embeddings.

## Claims

### Claim 1

A method comprising:
obtaining, using a hardware processor, a given segment of computer code;
modifying, using the hardware processor, the given segment of computer code to produce one or more inefficient versions of the given segment of computer code in comparison to the given segment of computer code;
generating, using the hardware processor, a code parse tree for the given segment of computer code and each inefficient version of the given segment of computer code;
generating, using the hardware processor, model embeddings based on the generated code parse trees; and
training, using the hardware processor, a diffusion model based on the generated model embeddings.

### Claim 2 (depends on 1)

The method of claim 1, further comprising ordering the given segment of computer code and the one or more inefficient versions of the given segment of computer code by run time and wherein the training the diffusion model is based on the ordered segments of computer code.

### Claim 3 (depends on 1)

The method of claim 1, further comprising performing inferencing using the trained diffusion model to generate a more efficient version of an input computer code segment.

### Claim 4 (depends on 3)

The method of claim 3, further comprising deploying the more efficient version of the input computer code segment.

### Claim 5 (depends on 4)

The method of claim 4, further comprising executing the deployed more efficient version of the input computer code segment.

### Claim 6 (depends on 1)

The method of claim 1, wherein the modifying the given segment of computer code comprises integrating one or more FOR loops into one or more of the given segment of computer code and the one or more inefficient versions of the given segment of computer code.

### Claim 7 (depends on 1)

The method of claim 1, wherein the modifying the given segment of computer code comprises one or more of integrating code that refrains from performing a timely release of memory occupied by variables, integrating code for variable circular references, integrating code variable names that violate a program specification, and integrating code that causes a memory leak into one or more of the given segment of computer code and the one or more inefficient versions of the given segment of computer code.

### Claim 8

A computer program product, comprising:
one or more tangible computer-readable storage media and program instructions stored on at least one of the one or more tangible computer-readable storage media, the program instructions executable by a processor, the program instructions comprising:
obtaining a given segment of computer code;
modifying the given segment of computer code to produce one or more inefficient versions of the given segment of computer code in comparison to the given segment of computer code;
generating a code parse tree for the given segment of computer code and each inefficient version of the given segment of computer code;
generating model embeddings based on the generated code parse trees; and
training a diffusion model based on the generated model embeddings.

### Claim 9 (depends on 8)

The computer program product of claim 8, further comprising ordering the given segment of computer code and the one or more inefficient versions of the given segment of computer code by run time and wherein the training the diffusion model is based on the ordered segments of computer code.

### Claim 10 (depends on 8)

The computer program product of claim 8, further comprising performing inferencing using the trained diffusion model to generate a more efficient version of an input computer code segment.

### Claim 11 (depends on 10)

The computer program product of claim 10, further comprising deploying the more efficient version of the input computer code segment.

### Claim 12 (depends on 11)

The computer program product of claim 11, further comprising executing the deployed more efficient version of the input computer code segment.

### Claim 13 (depends on 8)

The computer program product of claim 8, wherein the modifying the given segment of computer code comprises integrating one or more FOR loops into one or more of the given segments of computer code and the one or more inefficient versions of the given segment of computer code.

### Claim 14

A system comprising:
a memory; and
at least one processor, coupled to said memory, and operative to perform operations comprising:
obtaining a given segment of computer code;
modifying the given segment of computer code to produce one or more inefficient versions of the given segment of computer code in comparison to the given segment of computer code;
generating a code parse tree for the given segment of computer code and each inefficient version of the given segment of computer code;
generating model embeddings based on the generated code parse trees; and
training a diffusion model based on the generated model embeddings.

### Claim 15 (depends on 14)

The system of claim 14, further comprising ordering the given segment of computer code and the one or more inefficient versions of the given segment of computer code by run time and wherein the training the diffusion model is based on the ordered segments of computer code.

### Claim 16 (depends on 14)

The system of claim 14, further comprising performing inferencing using the trained diffusion model to generate a more efficient version of an input computer code segment.

### Claim 17 (depends on 16)

The system of claim 16, further comprising deploying the more efficient version of the input computer code segment.

### Claim 18 (depends on 17)

The system of claim 17, further comprising executing the deployed more efficient version of the input computer code segment.

### Claim 19 (depends on 14)

The system of claim 14, wherein the modifying the given segment of computer code comprises integrating one or more FOR loops into one or more of the given segments of computer code and the one or more inefficient versions of the given segment of computer code.

### Claim 20 (depends on 14)

The system of claim 14, wherein the modifying the given segment of computer code comprises one or more of integrating code that refrains from performing a timely release of memory occupied by variables, integrating code for variable circular references, integrating code variable names that violate a program specification, and integrating code that causes a memory leak into one or more of the given segment of computer code and the one or more inefficient versions of the given segment of computer code.
