A neural network chip optimization method, system, device and storage medium
By adjusting the parameters of the neural network chip to match the operation needs of specific neural network models, the problem of low compatibility between customized AI chips and models is solved, and efficient performance optimization and application adaptability are achieved.
Patent Information
- Application Number
- CN202010574428.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-22
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2040-06-22
AI Technical Summary
The compatibility between existing customized AI chips and neural network models is not high, resulting in the chip being unable to fully realize its potential and unable to effectively adapt to the needs of specific application scenarios.
By obtaining the preset neural network model, compiling it into an intermediate expression, determining the running time of the computing unit, and adjusting chip parameters according to the running time to optimize the performance of the neural network chip and making it highly consistent with the model of specific application scenarios. Spend.
It achieves a high degree of fit between neural network chips and neural network models, improves the performance and efficiency of chips, and ensures that it can fully realize its potential in specific application scenarios.
Smart Images

Figure CN111753973B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to neural network technology, and in particular to an optimization method, system, device and storage medium for a neural network chip. Background Art
[0002] With the rise of neural networks in recent years, AI (Artificial Intelligence) chips dedicated to neural networks have also shown a flourishing scene. The birth of each chip embodies the researchers' day and night efforts.
[0003] At present, artificial intelligence chips can be divided into training and reasoning according to functional categories, and the current development status is mainly training. However, as the application of neural networks continues to sink and land, the demand for reasoning chips is gradually increasing. Reasoning chip application scenarios include cloud and terminal scenarios. Cloud scenarios do not have strict requirements on chip power consumption and performance, but terminal scenarios require real-time response in areas such as autonomous driving and security, and low chip power consumption has given rise to customized reasoning chips based on scenarios.
[0004] However, how to deeply integrate the current AI customized chips with application scenarios is still a difficult problem. The current customized AI chip approach basically uses hardware to accelerate certain operators and adapt the application scenarios to the AI chips. But in fact, there is usually an application scenario first, and a neural network model is implemented based on this application scenario. Then this neural network model requires an AI chip that can achieve extreme performance. However, the current customized AI chips only perform hardware acceleration for a certain algorithm, which is separated from the actual application scenario, and the compatibility between the model and the customized AI chip is not high. Although it is better than the general-purpose chip, it cannot bring out the full potential of the chip. Summary of the invention
[0005] Embodiments of the present invention provide a method, system, device and storage medium for optimizing a neural network chip to optimize the neural network chip so that it has a high degree of compatibility with a neural network model for a certain application scenario.
[0006] To achieve this purpose, an embodiment of the present invention provides a method for optimizing a neural network chip, the method comprising:
[0007] Get the preset neural network model;
[0008] Compiling the neural network model into a first intermediate expression, wherein the first intermediate expression includes one or more first computing units;
[0009] Determine the total running time of the first intermediate expression on the neural network chip according to the running time of the one or more first computing units on the neural network chip;
[0010] The chip parameters of the neural network chip are adjusted according to the total running time to optimize the neural network chip.
[0011] Further, compiling the neural network model into a first intermediate expression includes:
[0012] Converting the neural network model into a second intermediate representation based on an instruction set architecture;
[0013] The second intermediate representation is converted into a first intermediate representation based on a data flow architecture.
[0014] Furthermore, converting the second intermediate expression into a first intermediate expression based on a data flow architecture includes:
[0015] parsing the second intermediate expression to obtain one or more second computing units;
[0016] Matching and mapping the one or more second computing units to one or more first computing units based on a preset data flow architecture;
[0017] A first intermediate expression based on a data flow architecture is obtained according to the one or more first computing units.
[0018] Further, compiling the neural network model into a first intermediate expression includes:
[0019] The first intermediate expression is optimized based on chip parameters of the neural network chip.
[0020] Further, the optimizing the first intermediate expression based on the chip parameters of the neural network chip includes:
[0021] Determining a calculation order of the neural network chip according to chip parameters of the neural network chip;
[0022] The one or more first computing units are classified and packaged according to the computing order.
[0023] Further, the adjusting the chip parameters of the neural network chip according to the total running time to optimize the neural network chip includes:
[0024] A chip running time formula is defined, wherein the input of the chip running time formula is the chip parameter of the neural network chip, and the output of the chip running time formula is the total running time;
[0025] The chip parameters of the neural network chip are adjusted multiple times according to the chip running time formula until the total running time reaches the fastest.
[0026] Further, the adjusting the chip parameters of the neural network chip according to the total running time to optimize the neural network chip includes:
[0027] The neural network model is adjusted according to the total running time.
[0028] On the one hand, an embodiment of the present invention further provides an optimization system for a neural network chip, the system comprising:
[0029] A model acquisition module is used to obtain a preset neural network model;
[0030] A model compiling module, configured to compile the neural network model into a first intermediate expression, wherein the first intermediate expression includes one or more first computing units;
[0031] A time determination module, configured to determine a total running time of the first intermediate expression on the neural network chip according to the running time of the one or more first computing units on the neural network chip;
[0032] A chip optimization module is used to adjust the chip parameters of the neural network chip according to the total running time to optimize the neural network chip.
[0033] On the other hand, an embodiment of the present invention further provides an optimization device for a neural network chip, the device comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement a method provided in any embodiment of the present invention.
[0034] On the other hand, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method provided in any embodiment of the present invention.
[0035] The embodiment of the present invention obtains a preset neural network model; compiles the neural network model into a first intermediate expression, wherein the first intermediate expression includes one or more first computing units; determines the total running time of the first intermediate expression on the neural network chip according to the running time of the one or more first computing units on the neural network chip; and adjusts the chip parameters of the neural network chip according to the total running time to optimize the neural network chip, thereby solving the problem that the neural network model is not highly compatible with the AI chip and the full potential of the chip cannot be brought into play, and achieves the effect of optimizing the neural network chip so that it has a high degree of compatibility with the neural network model for a certain application scenario. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1It is a flowchart of a method for optimizing a neural network chip provided in Embodiment 1 of the present invention;
[0037] Figure 2 It is a flow chart of a method for optimizing a neural network chip provided in the second embodiment of the present invention;
[0038] Figure 3 is a flow chart of step S230 in a method for optimizing a neural network chip provided in the second embodiment of the present invention;
[0039] Figure 4 is a flow chart of step S240 in a method for optimizing a neural network chip provided in Embodiment 2 of the present invention;
[0040] Figure 5 It is a structural schematic diagram of an optimization system for a neural network chip provided in Embodiment 3 of the present invention;
[0041] Figure 6 A schematic diagram of the structure of a neural network chip optimization device provided in Example 4 of the present invention. DETAILED DESCRIPTION
[0042] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only the parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0043] It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the steps as sequential processes, many of the steps therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of the steps can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0044] In addition, the terms "first", "second", etc. can be used in this article to describe various directions, actions, steps or elements, but these directions, actions, steps or elements are not limited by these terms. These terms are only used to distinguish a first direction, action, step or element from another direction, action, step or element. For example, without departing from the scope of the present application, the first module can be referred to as the second module, and similarly, the second module can be referred to as the first module. Both the first module and the second module are modules, but they are not the same module. The terms "first", "second", etc. cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" can expressly or implicitly include one or more of the features. In the description of the embodiment of the present invention, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0045] Embodiment 1
[0046] like Figure 1 As shown, the first embodiment of the present invention provides a method, system, device and storage medium for optimizing a neural network chip, the method comprising:
[0047] S110, obtaining a preset neural network model.
[0048] In this embodiment, in order to solve the problem that the neural network model and the AI chip are not compatible and cannot bring out the full potential of the chip, the parameters of the AI chip can be adjusted based on the neural network model when the AI chip is designed. Because the neural network model and the AI chip are both used for a specific application scenario, after the application scenario is determined, the first thing to be determined is the neural network model suitable for the application scenario. Therefore, the preset neural network model is first obtained. The preset neural network model can be a neural network model provided by the user for a certain application scenario. Specifically, it can be a model implemented based on TensorFlow (a symbolic mathematical system based on data flow programming), Caffe (Convolutional Architecture for Fast Feature Embedding, a convolutional neural network framework), or Pytorch (a deep learning framework based on Python).
[0049] S120. Compile the neural network model into a first intermediate expression, where the first intermediate expression includes one or more first computing units.
[0050] S130. Determine the total running time of the first intermediate expression in the neural network chip according to the running time of one or more first computing units in the neural network chip.
[0051] In this embodiment, after obtaining the neural network model, it is necessary to compile the neural network model into a first intermediate expression to facilitate the analysis of the neural network model. The first intermediate expression includes one or more first computing units. Then, an arbitrary fixed amount of data is selected as the data input of the first intermediate expression, and the first intermediate expression is run in the designed neural network chip to determine the running time of one or more first computing units in the neural network chip, that is, to calculate the computing time of the arbitrary fixed amount of data, and then determine the total running time of the first intermediate expression in the neural network chip according to the running time of one or more first computing units in the neural network chip.
[0052] Exemplarily, a group of data with a length of 10 is used as data input. If the running time of a first computing unit in the neural network chip is 1 ms, and if the running time of each first computing unit is the same, then it will take 10 ms to complete the calculation of this group of data, which is the total running time.
[0053] S140. Adjust the chip parameters of the neural network chip according to the total running time to optimize the neural network chip.
[0054] In this embodiment, after determining the total running time of the first intermediate expression in the neural network chip, the chip parameters of the neural network chip can be adjusted, and then the same data is taken to recalculate to obtain the total running time, and the above steps are repeated. Through multiple calculations and comparisons, the optimal chip parameters are determined to complete the optimization of the neural network chip.
[0055] The embodiment of the present invention obtains a preset neural network model; compiles the neural network model into a first intermediate expression, the first intermediate expression includes one or more first computing units; determines the total running time of the first intermediate expression in the neural network chip according to the running time of the one or more first computing units in the neural network chip; adjusts the chip parameters of the neural network chip according to the total running time to optimize the neural network chip, thereby solving the problem that the neural network model is not highly compatible with the AI chip and the full potential of the chip cannot be brought into play, and achieves the effect of optimizing the neural network chip so that it has a high degree of compatibility with the neural network model for a certain application scenario.
[0056] Embodiment 2
[0057] like Figure 2-Figure 4 As shown, the second embodiment of the present invention provides an optimization method for a neural network chip. The second embodiment of the present invention is further explained on the basis of the first embodiment of the present invention. Figure 2 As shown, the method includes:
[0058] S210: Obtain a preset neural network model.
[0059] S220. Convert the neural network model into a second intermediate expression based on the instruction set architecture.
[0060] S230. Convert the second intermediate expression into a first intermediate expression based on a data flow architecture, where the first intermediate expression includes one or more first computing units.
[0061] In this embodiment, after obtaining the neural network model, it is first necessary to convert the neural network model into a second intermediate expression based on the instruction set architecture. Currently, neural network models are obtained by training GPU / CPU chips based on instruction sets. The second intermediate expression includes one or more second computing units. In order to optimize the speed of calculation, the second intermediate expression is further converted into a first intermediate expression based on the data flow architecture. The first intermediate expression includes one or more first computing units. The difference between the first computing unit and the second computing unit is that the first computing unit has a coarser granularity, is more concise, and is suitable for classification and calculation of large amounts of data. This step can be directly implemented by the preset AI compiler.
[0062] S240. Optimize the first intermediate expression based on chip parameters of the neural network chip.
[0063] In this embodiment, after obtaining the first intermediate expression, the first intermediate expression can also be optimized based on the chip parameters of the neural network chip. Exemplarily, the computing nodes of the first intermediate expression are merged and sorted, and the software simulates the cache allocation. Specifically, the calculation method of the neural network chip is determined by the chip parameters of the neural network chip, so as to adaptively optimize the first intermediate expression.
[0064] S250. Determine the total running time of the first intermediate expression in the neural network chip according to the running time of one or more first computing units in the neural network chip.
[0065] S260. Define a chip running time formula, the input of the chip running time formula is the chip parameters of the neural network chip, and the output of the chip running time formula is the total running time.
[0066] S270. According to the chip running time formula, the chip parameters of the neural network chip are adjusted multiple times until the total running time reaches the fastest.
[0067] In this embodiment, a chip running time formula can be defined, and the chip parameters of the neural network chip are used as the input of the formula, and the total running time is used as the output of the formula. That is, an automated model is established to be suitable for multiple chip tests. The chip parameters of the neural network chip are adjusted multiple times according to the chip running time formula until the total running time reaches the fastest. Each test only requires inputting the adjusted parameters. After obtaining the total running time, a corresponding model report can also be generated for user analysis to facilitate the user to determine the next parameter adjustment.
[0068] For example, a default value is set for the parameters of the neural network model, the chip running time formula is run, and after obtaining the model report, the parameters of the specific neural network model and the neural network chip are analyzed to determine which parameter values affect the running performance, so that resources are not fully utilized. After multiple tests, a balance is finally reached. For example, if the neural network model is relatively small, and the amount of data that needs to be stored or calculated during the calculation process is not much, the optimization can be carried out by reducing the value of the internal cache size of the neural network chip and increasing the clock frequency of the neural network chip to read and write data.
[0069] S280, adjusting the neural network model according to the total running time.
[0070] In this embodiment, the neural network model can also be adjusted according to the total running time. It should be noted that the adjustment of the neural network model needs to ensure that it does not affect the accuracy of the neural network model, and fine-tuning is performed to achieve the optimal balance between the neural network model and the neural network chip, so that the neural network model is closer to the principles of the underlying neural network chip design.
[0071] Further, such as Figure 3 As shown, step S230 in the embodiment of the present invention specifically includes:
[0072] S231. Parse the second intermediate expression to obtain one or more second computing units.
[0073] S232. Match and map one or more second computing units to one or more first computing units based on a preset data flow architecture.
[0074] S233. Obtain a first intermediate expression based on a data flow architecture according to one or more first computing units.
[0075] In this embodiment, the second intermediate expression is first parsed to obtain one or more second calculation units. For example, take an operator of any neural network model, whose mathematical formula is y=x / sqrt(max(sum(x**2),epsilon)), then for the second intermediate expression, it will be expressed as x 1 =x**2;x1 =max(x 1 ,epsilon);x 1 =sqrt(x 1 ); y = x / x 1 , these four second computing units, but the preset data flow architecture will directly define this mathematical formula as L 1 The calculation unit is the first calculation unit and is directly expressed as y = L 1 (x, epsilon), whenever this mathematical formula structure appears later, we can still match it to L 1 The computing unit matches and maps one or more second computing units to one or more first computing units based on a preset data flow architecture, and as many first computing units are matched and mapped as there are mathematical formulas, and finally a first intermediate expression based on the data flow architecture is obtained according to the one or more first computing units.
[0076] Further, such as Figure 4 As shown, step S240 in the embodiment of the present invention specifically includes:
[0077] S241. Determine the calculation order of the neural network chip according to the chip parameters of the neural network chip.
[0078] S242. Classify and package one or more first computing units according to the computing order.
[0079] In this embodiment, the calculation of the neural network chip is performed according to the time when the data flows in. However, if the data flowing in within a period of time are all types of data calculated using the same computing unit, the calculation of the neural network chip will be blocked, greatly reducing the computing efficiency of the neural network chip. Therefore, the calculation order of the neural network chip is first determined according to the chip parameters of the neural network chip, and then one or more first computing units are classified and packaged according to this calculation order into a DataPath (data channel), so there is no need to classify the received intermediate expressions at the AI chip level. Specifically, the calculation order of the neural network chip is A computing unit-B computing unit-C computing unit, so all the computing units in the neural network model are classified accordingly, and then the classified A computing unit, B computing unit and C computing unit are packaged into a continuously calculated DataPath.
[0080] The embodiment of the present invention converts the second intermediate expression into a first intermediate expression based on a data flow architecture, wherein the first intermediate expression includes one or more first computing units; optimizes the first intermediate expression based on chip parameters of a neural network chip; and adjusts the neural network model according to the total running time, so that the neural network model, AI chip and running performance form a closed-loop positive feedback mechanism, thereby improving the customization capability of the AI chip, simulating the AI chip performance in the AI chip design stage and providing feedback to the AI chip design or AI chip resource parameters for optimization, thereby reducing R&D costs.
[0081] Embodiment 3
[0082] like Figure 5 As shown, the third embodiment of the present invention provides a neural network chip optimization system 100. The neural network chip optimization system 100 provided in the third embodiment of the present invention can execute the neural network chip optimization method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. The neural network chip optimization system 100 includes a model acquisition module 200, a model compilation module 300, a time determination module 400 and a chip optimization module 500.
[0083] Specifically, the model acquisition module 200 is used to acquire a preset neural network model; the model compilation module 300 is used to compile the neural network model into a first intermediate expression, which includes one or more first computing units; the time determination module 400 is used to determine the total running time of the first intermediate expression in the neural network chip according to the running time of one or more first computing units in the neural network chip; the chip optimization module 500 is used to adjust the chip parameters of the neural network chip according to the total running time to optimize the neural network chip.
[0084] In this embodiment, the model compilation module 300 is specifically used to convert the neural network model into a second intermediate expression based on the instruction set architecture; convert the second intermediate expression into a first intermediate expression based on the data flow architecture. The model compilation module 300 is also specifically used to parse the second intermediate expression to obtain one or more second computing units; match and map the one or more second computing units to one or more first computing units based on the preset data flow architecture; and obtain the first intermediate expression based on the data flow architecture according to the one or more first computing units.
[0085] Furthermore, the neural network chip optimization system 100 also includes a model optimization module 600, which is used to optimize the first intermediate expression based on the chip parameters of the neural network chip. The model optimization module 600 is also specifically used to determine the calculation order of the neural network chip according to the chip parameters of the neural network chip; and classify and package one or more first calculation units according to the calculation order.
[0086] In this embodiment, the chip optimization module 500 is specifically used to define a chip running time formula, the input of the chip running time formula is the chip parameters of the neural network chip, and the output of the chip running time formula is the total running time; the chip parameters of the neural network chip are adjusted multiple times according to the chip running time formula until the total running time reaches the fastest. The model optimization module 600 is also used to adjust the neural network model according to the total running time.
[0087] Embodiment 4
[0088] Figure 6 A schematic diagram of the structure of a neural network chip optimization computer device 12 provided in Example 4 of the present invention. Figure 6 A block diagram of an exemplary computer device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 6 The computer device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0089] like Figure 6 As shown, the computer device 12 is in the form of a general-purpose computing device. The components of the computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0090] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0091] The computer device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the computer device 12, including volatile and non-volatile media, removable and non-removable media.
[0092] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The computer device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 6 not shown, usually called a "hard drive"). Although Figure 6Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0093] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0094] The computer device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the computer device 12, and / or may communicate with any device that enables the computer device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the computer device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the computer device 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the computer device 12, including, but not limited to, microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0095] The processing unit 16 executes various functional applications and data processing by running the programs stored in the system memory 28, for example, implementing the method provided in the embodiment of the present invention:
[0096] Get the preset neural network model;
[0097] Compile the neural network model into a first intermediate expression, where the first intermediate expression includes one or more first computing units;
[0098] Determine the total running time of the first intermediate expression on the neural network chip according to the running time of one or more first computing units on the neural network chip;
[0099] The chip parameters of the neural network chip are adjusted according to the total running time to optimize the neural network chip.
[0100] Embodiment 5
[0101] Embodiment 5 of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method provided in all the embodiments of the present invention is implemented:
[0102] Get the preset neural network model;
[0103] Compile the neural network model into a first intermediate expression, where the first intermediate expression includes one or more first computing units;
[0104] Determine the total running time of the first intermediate expression on the neural network chip according to the running time of one or more first computing units on the neural network chip;
[0105] The chip parameters of the neural network chip are adjusted according to the total running time to optimize the neural network chip.
[0106] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0107] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0108] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0109] Computer program code for performing the operations of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0110] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A method for optimizing a neural network chip, characterized in that: include: Get the preset neural network model; Compiling the neural network model into a first intermediate expression, wherein the first intermediate expression includes one or more first computing units; Determine the total running time of the first intermediate expression on the neural network chip according to the running time of the one or more first computing units on the neural network chip; Adjusting chip parameters of the neural network chip according to the total running time to optimize the neural network chip and determine optimal chip parameters; Compiling the neural network model into a first intermediate expression includes: Converting the neural network model into a second intermediate representation based on an instruction set architecture; Convert the second intermediate expression into a first intermediate expression based on a data flow architecture; The converting the second intermediate expression into a first intermediate expression based on a data flow architecture comprises: parsing the second intermediate expression to obtain one or more second computing units; Matching and mapping the one or more second computing units to one or more first computing units based on a preset data flow architecture; A first intermediate expression based on a data flow architecture is obtained according to the one or more first computing units.
2. The method according to claim 1, characterized in that The step of compiling the neural network model into a first intermediate expression includes: The first intermediate expression is optimized based on chip parameters of the neural network chip.
3. The method according to claim 2, characterized in that The optimizing the first intermediate expression based on the chip parameters of the neural network chip includes: Determining a calculation order of the neural network chip according to chip parameters of the neural network chip; The one or more first computing units are classified and packaged according to the computing order.
4. The method according to claim 1, characterized in that The step of adjusting the chip parameters of the neural network chip according to the total running time to optimize the neural network chip includes: A chip running time formula is defined, wherein the input of the chip running time formula is the chip parameter of the neural network chip, and the output of the chip running time formula is the total running time; The chip parameters of the neural network chip are adjusted multiple times according to the chip running time formula until the total running time reaches the fastest.
5. The method according to claim 1, characterized in that The step of adjusting the chip parameters of the neural network chip according to the total running time to optimize the neural network chip includes: The neural network model is adjusted according to the total running time.
6. A neural network chip optimization system, characterized in that: include: A model acquisition module is used to obtain a preset neural network model; A model compiling module, configured to compile the neural network model into a first intermediate expression, wherein the first intermediate expression includes one or more first computing units; A time determination module, configured to determine a total running time of the first intermediate expression on the neural network chip according to the running time of the one or more first computing units on the neural network chip; A chip optimization module, used to adjust the chip parameters of the neural network chip according to the total running time to optimize the neural network chip and determine the optimal chip parameters; The model compilation module is specifically used to: convert the neural network model into a second intermediate expression based on an instruction set architecture; convert the second intermediate expression into a first intermediate expression based on a data flow architecture; The model compilation module is further specifically used to: parse the second intermediate expression to obtain one or more second computing units; match and map the one or more second computing units to one or more first computing units based on a preset data flow architecture; A first intermediate expression based on a data flow architecture is obtained according to the one or more first computing units.
7. An optimization device for a neural network chip, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
