# US 2024/0202522 A1 · Device and method for generating deep learning model graph and abstract syntax tree for integrated compiler

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

- Number: US 2024/0202522 A1
- Document ID: US20240202522A1
- Status: Published application
- Kind: A1
- Application number: 18/544,910
- Filed: 2023-12-19
- Published: 2024-06-20
- Earliest claimed: 2022-12-19
- Assignees: Electronics and Telecommunications Research Institute
- Applicants: Electronics and Telecommunications Research Institute
- Inventors: Hyunjeong KWON
- Web page: https://patentgrep.com/patent/US20240202522A1

## CPC

- G06F 8/433: {Dependency analysis; Data or control flow analysis}
- G06N 3/08: Learning methods
- G06F 8/427: {Parsing}
- 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

Provided are a device and method for generating a deep learning model graph and an abstract syntax tree (AST) for an integrated compiler. The method includes: generating, by a processor, a forward graph for inference of a deep learning model and a backward graph for training the deep learning model through a graph generator using the same library according to the same grammatical structure; and generating, by the processor, an AST for the forward graph and the backward graph using one parser.

## Claims

### Claim 1

A method of generating a deep learning model graph and an abstract syntax tree (AST) for an integrated compiler, the method comprising:
generating, by a processor, a forward graph for inference of a deep learning model and a backward graph for training the deep learning model through a graph generator using the same library according to the same grammatical structure; and
generating, by the processor, an AST for the forward graph and the backward graph using one parser.

### Claim 2 (depends on 1)

The method of claim 1, wherein the generating of the backward graph using the same library according to the same grammatical structure comprises extracting, by the processor, all trainable nodes among nodes in the deep learning model and edge information for connecting the nodes and then outputting the nodes and the edge information as input data for graph generation.

### Claim 3 (depends on 2)

The method of claim 2, further comprising, after the extracting of the all the trainable nodes and the edge information for connecting the nodes:
determining, by the processor, types of all the nodes from a first node; and
storing only node information or the node information and attribute information in a memory depending on a determined type of a node.

### Claim 4 (depends on 3)

The method of claim 3, wherein the storing of only the node information or the node information and the attribute information in the memory comprises:
determining, by the processor, a type of current node;
storing only node information in the memory when the current node is a leaf node; and
storing not only the node information but also attribute information in the memory when the current node is not a leaf node.

### Claim 5 (depends on 3)

The method of claim 3, further comprising, after the storing of only the node information or the node information and the attribute information in the memory, outputting, by the processor, the nodes stored in the memory and connection states between the nodes.

### Claim 6 (depends on 5)

The method of claim 5, further comprising, after the outputting of the nodes stored in the memory and the connection states between the nodes, outputting, by the processor, actual values of the attribute information of the nodes stored in the memory.

### Claim 7 (depends on 1)

The method of claim 1, wherein the generating of the AST for the forward graph and the backward graph comprises:
reading, by the processor, syntax representing a start portion of an input graph according to the grammatical structure to generate a FunctionAST;
reading syntax representing a graph name to generate a PrototypeAST; and
reading syntax representing an actual structure of the backward graph and information required for calculation to sequentially generate a list in an ExprAST which is a body portion of the FunctionAST.

### Claim 8 (depends on 7)

The method of claim 7, further comprising, after the generation of the PrototypeAST, extracting, by the processor, a name and a data type of an input node according to the grammatical structure and adding the extracted name and data type as information on the graph name to the PrototypeAST.

### Claim 9 (depends on 7)

The method of claim 7, wherein the sequential generation of the list in the ExprAST which is the body portion of the FunctionAST comprises sequentially generating, by the processor, the list in the ExprAST according to the grammatical structure on the basis of syntax starting with a specified keyword and information included in the syntax.

### Claim 10 (depends on 7)

The method of claim 7, wherein, according to information included in AST nodes, the list in the ExprAST includes at least nine AST nodes, which are a VarDeclAST representing a prototype of a function, a ReturnAST representing a return value of a function, a TorchOpAST representing an operator, a NumberAST representing a constant, a ListAST representing a variable array, a CallAST representing operator information, a VariableAST representing a variable, a LiteralAST representing a constant array, and a TensorAST representing attribute information.

### Claim 11

A device for generating a deep learning model graph and an abstract syntax tree (AST) for an integrated compiler, the device comprising:
a graph generator of a processor configured to generate a forward graph for inference of a deep learning model and a backward graph for training the deep learning model using the same library according to the same grammatical structure; and
a parser of the processor configured to generate an AST for the forward graph and the backward graph.

### Claim 12 (depends on 11)

The device of claim 11, wherein, to generate the backward graph using the same library according to the same grammatical structure, the processor extracts all trainable nodes among nodes in the deep learning model and edge information for connecting the nodes and then outputs the nodes and the edge information as input data for graph generation.

### Claim 13 (depends on 12)

The device of claim 12, wherein, after extracting the all the trainable nodes and the edge information for connecting the nodes, the processor determines types of all the nodes from a first node and stores only node information or the node information and attribute information in a memory depending on a determined type of a node.

### Claim 14 (depends on 13)

The device of claim 13, wherein the processor determines a type of current node, stores only node information in the memory when the current node is a leaf node, and stores not only the node information but also attribute information in the memory when the current node is not a leaf node.

### Claim 15 (depends on 13)

The device of claim 13, wherein, after storing only the node information or the node information and the attribute information in the memory, the processor outputs the nodes stored in the memory and connection states between the nodes.

### Claim 16 (depends on 15)

The device of claim 15, wherein, after outputting the nodes stored in the memory and the connection states between the nodes, the processor outputs actual values of the attribute information of the nodes stored in the memory.

### Claim 17 (depends on 11)

The device of claim 11, wherein, to generate the AST for the forward graph and the backward graph, the processor generates a FunctionAST by reading syntax representing a start portion of an input graph according to the grammatical structure, generates a PrototypeAST by reading syntax representing a graph name, and sequentially generates a list in an ExprAST which is a body portion of the FunctionAST by reading syntax representing an actual structure of the backward graph and information required for calculation.

### Claim 18 (depends on 17)

The device of claim 17, wherein, after generating the PrototypeAST, the processor extracts a name and a data type of an input node according to the grammatical structure and adds the extracted name and data type as information on the graph name to the PrototypeAST.

### Claim 19 (depends on 17)

The device of claim 17, wherein the processor sequentially generates the list in the ExprAST which is the body portion of the FunctionAST according to the grammatical structure on the basis of syntax starting with a specified keyword and information included in the syntax.

### Claim 20 (depends on 17)

The device of claim 17, wherein, according to information included in AST nodes, the list in the ExprAST includes at least nine AST nodes, which are a VarDeclAST representing a prototype of a function, a ReturnAST representing a return value of a function, a TorchOpAST representing an operator, a NumberAST representing a constant, a ListAST representing a variable array, a CallAST representing operator information, a VariableAST representing a variable, a LiteralAST representing a constant array, and a TensorAST representing attribute information.
