# US 2022/0035614 A1 · Method and electronic device for deploying operator in deep learning framework

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

- Number: US 2022/0035614 A1
- Document ID: US20220035614A1
- Status: Published application
- Kind: A1
- Application number: 17/500,779
- Filed: 2021-10-13
- Published: 2022-02-03
- Earliest claimed: 2021-03-24
- Assignees: Beijing Baidu Netcom Science Technology Co., Ltd.
- Applicants: Beijing Baidu Netcom Science Technology Co., Ltd.
- Inventors: Liujie ZHANG; Xiang LAN; Huihuang ZHENG; Hongyu LIU; Wei ZHOU; Yanjun MA; Dianhai YU; Haifeng WANG
- Web page: https://patentgrep.com/patent/US20220035614A1

## CPC

- G06F 8/61: Installation
- G06F 8/36: Software reuse
- G06F 8/41: Compilation
- G06F 9/44521: {Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading}
- G06N 3/10: Interfaces, programming languages or software development kits, e.g. for simulating neural networks
- G06N 3/105: {Shells for specifying net layout}
- 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

The present disclosure discloses a method, an apparatus and an electronic device for deploying an operator in a deep learning framework and relates to the field of artificial intelligence technology such as deep learning. And the solution is: acquiring a source file of the operator; compiling the source file of the operator to form a dynamic link library of the operator; generating an interface file transferred from the dynamic link library of the operator; generating an installable library file according to the dynamic link library and the interface file; installing the installable library file to a target programming language library.

## Claims

### Claim 1

A deployment method for an operator in a deep learning framework, comprising:
acquiring a source file of the operator;
compiling the source file of the operator to form a dynamic link library of the operator;
generating an interface file transferred from the dynamic link library of the operator;
generating an installable library file according to the dynamic link library and the interface file; and
installing the installable library file to a target programming language library.

### Claim 2 (depends on 1)

The deployment method according to claim 1, wherein the compiling the source file of the operator to form the dynamic link library of the operator comprises:
performing header file expansion and macro replacement on the source file of the operator to generate a code to be compiled;
compiling the code to be compiled into an assembly code and converting the assembly code into a bytecode line by line to generate an object file; and
performing a linking operation on the object file to acquire a linked object file, and generating the dynamic link library according to the linked object file.

### Claim 3 (depends on 1)

The deployment method according to claim 1, wherein the generating the installable library file according to the dynamic link library and the interface file comprises:
packaging the dynamic link library and the interface file in accordance with a preset packaging strategy to generate the installable library file.

### Claim 4 (depends on 1)

The deployment method according to claim 1, wherein the installing the installable library file to the target programming language library comprises:
installing the installable library file to a target directory in the target programming language library.

### Claim 5 (depends on 1)

The deployment method according to claim 1, further comprising:
acquiring an import statement of a target operator, wherein the import statement carries information corresponding to a programming language library where an installable library file of the target operator is located;
parsing the import statement to determine a target subdirectory where the installable library file of the target operator is located; and
reading and importing the installable library file of the target operator from the target subdirectory.

### Claim 6 (depends on 1)

The deployment method according to claim 1, further comprising:
acquiring a function code to be injected corresponding to the dynamic link library;
injecting the function code to be injected into an entry file to generate a target calling function code of the dynamic link library; and
writing the target calling function code into the interface file.

### Claim 7 (depends on 6)

The deployment method according to claim 6, wherein the injecting the function code to be injected into the entry file to generate the target calling function code of the dynamic link library comprises:
acquiring a default calling function code of the dynamic link library from the entry file; and
replacing the default calling function code with the function code to be injected to generate the target calling function code of the dynamic link library.

### Claim 8

An electronic device, comprising:
a processor; and
a memory for storing a program corresponding to an executable program code,
wherein the processor is configured to read the executable program code stored in the memory, to perform actions of:
acquiring a source file of the operator;
compiling the source file of the operator to form a dynamic link library of the operator;
generating an interface file transferred from the dynamic link library of the operator;
generating an installable library file according to the dynamic link library and the interface file; and
installing the installable library file to a target programming language library.

### Claim 9 (depends on 8)

The electronic device according to claim 8, wherein the compiling the source file of the operator to form the dynamic link library of the operator comprises:
performing header file expansion and macro replacement on the source file of the operator to generate a code to be compiled;
compiling the code to be compiled into an assembly code and converting the assembly code into a bytecode line by line to generate an object file; and
performing a linking operation on the object file to acquire a linked object file, and generating the dynamic link library according to the linked object file.

### Claim 10 (depends on 8)

The electronic device according to claim 8, wherein the generating the installable library file according to the dynamic link library and the interface file comprises:
packaging the dynamic link library and the interface file in accordance with a preset packaging strategy to generate the installable library file.

### Claim 11 (depends on 8)

The electronic device according to claim 8, wherein the installing the installable library file to the target programming language library comprises:
installing the installable library file to a target directory in the target programming language library.

### Claim 12 (depends on 8)

The electronic device according to claim 8, wherein the processor is further configured to read the executable program code stored in the memory, to perform actions of:
acquiring an import statement of a target operator, wherein the import statement carries information corresponding to a programming language library where an installable library file of the target operator is located;
parsing the import statement to determine a target subdirectory where the installable library file of the target operator is located; and
reading and importing the installable library file of the target operator from the target subdirectory.

### Claim 13 (depends on 8)

The electronic device according to claim 8, wherein the processor is further configured to read the executable program code stored in the memory, to perform actions of:
acquiring a function code to be injected corresponding to the dynamic link library;
injecting the function code to be injected into an entry file to generate a target calling function code of the dynamic link library; and
writing the target calling function code into the interface file.

### Claim 14 (depends on 13)

The electronic device according to claim 13, wherein the injecting the function code to be injected into the entry file to generate the target calling function code of the dynamic link library comprises:
acquiring a default calling function code of the dynamic link library from the entry file; and
replacing the default calling function code with the function code to be injected to generate the target calling function code of the dynamic link library.

### Claim 15

A non-transitory computer-readable storage medium, on which a computer program is stored, wherein the program is configured to perform a deployment method for an operator in a deep learning framework, the method comprising:
acquiring a source file of the operator;
compiling the source file of the operator to form a dynamic link library of the operator;
generating an interface file transferred from the dynamic link library of the operator;
generating an installable library file according to the dynamic link library and the interface file; and
installing the installable library file to a target programming language library.

### Claim 16 (depends on 15)

The non-transitory computer-readable storage medium according to claim 15, wherein the compiling the source file of the operator to form the dynamic link library of the operator comprises:
performing header file expansion and macro replacement on the source file of the operator to generate a code to be compiled;
compiling the code to be compiled into an assembly code and converting the assembly code into a bytecode line by line to generate an object file; and
performing a linking operation on the object file to acquire a linked object file, and generating the dynamic link library according to the linked object file.

### Claim 17 (depends on 15)

The non-transitory computer-readable storage medium according to claim 15, wherein the generating the installable library file according to the dynamic link library and the interface file comprises:
packaging the dynamic link library and the interface file in accordance with a preset packaging strategy to generate the installable library file.

### Claim 18 (depends on 15)

The non-transitory computer-readable storage medium according to claim 15, wherein the installing the installable library file to the target programming language library comprises:
installing the installable library file to a target directory in the target programming language library.

### Claim 19 (depends on 15)

The non-transitory computer-readable storage medium according to claim 15, wherein the method further comprises:
acquiring an import statement of a target operator, wherein the import statement carries information corresponding to a programming language library where an installable library file of the target operator is located;
parsing the import statement to determine a target subdirectory where the installable library file of the target operator is located; and
reading and importing the installable library file of the target operator from the target subdirectory.

### Claim 20 (depends on 15)

The non-transitory computer-readable storage medium according to claim 15, wherein the method further comprises:
acquiring an import statement of a target operator, wherein the import statement carries information corresponding to a programming language library where an installable library file of the target operator is located;
parsing the import statement to determine a target subdirectory where the installable library file of the target operator is located; and
reading and importing the installable library file of the target operator from the target subdirectory.
