Acquisition method, system, device and computer readable storage medium
Patent Information
- Application Number
- CN202310619461.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-29
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2043-05-29
AI Technical Summary
[0003]但传统的列表算法无法获取计算图的最短执行时间和对应的计算单元数量,从而使得计算图布局缺少参考依据,进而不利于计算图的布局
[0005] The purpose of this invention is to provide a method, system, device, and computer-readable storage medium for obtaining the shortest execution time and corresponding number of computing units of a computation graph, providing a reference for the layout of the computation graph and facilitating the layout of the computation graph.
Smart Images

Figure CN116720464B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of circuit simulation technology, and in particular to a method, system, apparatus, and computer-readable storage medium for obtaining circuit simulation data. Background Technology
[0002] In circuit simulation, the allocation and scheduling of the current computation graph are generally calculated using a list scheduling algorithm.
[0003] However, traditional list algorithms cannot obtain the shortest execution time and the corresponding number of computation units of the computation graph, which makes the layout of the computation graph lack a reference and thus is not conducive to the layout of the computation graph.
[0004] Therefore, it is necessary to provide a novel acquisition method, system, apparatus, and computer-readable storage medium to solve the aforementioned problems existing in the prior art. Summary of the Invention
[0005] The purpose of this invention is to provide a method, system, device, and computer-readable storage medium for obtaining the shortest execution time and corresponding number of computing units of a computation graph, providing a reference for the layout of the computation graph and facilitating the layout of the computation graph.
[0006] To achieve the above objectives, the acquisition method of the present invention, used to acquire the number of computational units and the shortest execution time of a computation graph, includes the following steps:
[0007] S1: Increment i by 1, then obtain the execution cycle of the i-th iteration and the (i-1)-th iteration, where i is a natural number greater than or equal to 0;
[0008] S2: Calculate the cost function based on the execution cycle of the i-th iteration and the (i-1)-th iteration. If the cost function is less than 0, the execution cycle of the i-th iteration remains unchanged, and the number of stable iterations is set to 0. If the cost function is equal to 0, the execution cycle of the i-th iteration remains unchanged, and the number of stable iterations is incremented by 1. If the cost function is greater than 0, the execution cycle of the i-th iteration is replaced with the execution cycle of the (i-1)-th iteration, and the number of stable iterations is set to 0.
[0009] S3: Determine if the number of stable iterations is equal to the maximum value of the number of stable iterations. If the number of stable iterations is equal to the maximum value of the number of stable iterations, output the execution cycle of the i-th iteration calculation and the number of the q-th type of calculation unit used. If the number of stable iterations is not equal to the maximum value of the number of stable iterations, execute step S4.
[0010] S4: Based on the number of the j-th type of computing units, the number of the j-th type of computing units used, and the execution cycle calculation parameters of the i-th iteration, obtain the maximum value of the q-th parameter in the parameters, provided that the number of the j-th type of computing units has not reached the upper limit. Then obtain the number of the q-th type of computing units used corresponding to the q-th parameter, where j and q are both natural numbers greater than or equal to 0.
[0011] S5: Determine the difference between the number of the q-th type of computing units used and the upper limit of the number of the q-th type of computing units. If the number of the q-th type of computing units used is less than the upper limit of the number of the q-th type of computing units, increment the number of the q-th type of computing units used by 1, and then execute step S1. If the number of the q-th type of computing units used is greater than or equal to the upper limit of the number of the q-th type of computing units, then the number of the q-th type of computing units has reached the upper limit, and then execute step S4.
[0012] The beneficial effects of the acquisition method are as follows: obtaining the shortest execution cycle of the computation graph under limited computing power provides a reference for the layout of the computation graph, which is beneficial to the layout of the computation graph and can also be used as a time constraint for the design of the computation graph. The number of corresponding computation units obtained can be used as the upper limit for reducing the number of computation units in the computation graph, providing an effective optimization starting point for the optimization of the computation graph, and reducing unnecessary analysis and calculation.
[0013] Optionally, before performing step S1 for the first time, the following may also be included:
[0014] Initialize i to 0, initialize the execution cycle of the i-th iteration to the maximum value, initialize the stable number of iterations to 0, set the maximum value of the stable number of iterations to be greater than or equal to 50 and less than or equal to 100, initialize the number of the j-th type of computing unit to 1, set the j-th type of computing unit to have not reached its upper limit, and set the maximum value of the execution cycle of the i-th iteration to be greater than or equal to 10. 60 and less than or equal to 10 70 .
[0015] Optionally, calculating the cost function based on the execution cycle calculated in the i-th iteration and the execution cycle calculated in the (i-1)-th iteration includes:
[0016] The cost function is obtained by calculating the difference between the execution cycle calculated in the i-th iteration and the execution cycle calculated in the (i-1)-th iteration.
[0017] Optionally, the step of calculating the execution cycle parameters based on the number of the j-th type of computing units, the number of the j-th type of computing units used, and the execution cycle parameters for the i-th iteration includes:
[0018] Calculate the product of the number of the j-th type of computing units and the execution cycle of the i-th iteration, and then calculate the quotient of the number of the j-th type of computing units used and the product to obtain the parameters.
[0019] Optionally, obtaining the execution cycle of the i-th iteration calculation and the execution cycle of the (i-1)-th iteration calculation includes:
[0020] The execution cycle of the i-th iteration and the (i-1)-th iteration are obtained using a list algorithm.
[0021] This invention also provides a system for implementing the acquisition method. The system includes an execution cycle calculation unit, a cost function calculation unit, a stable number determination unit, a parameter calculation unit, and a usage quantity determination unit. The execution cycle calculation unit is used to increment i by 1, and then obtain the execution cycle of the i-th iteration calculation and the execution cycle of the (i-1)-th iteration calculation, where i is a natural number greater than or equal to 0. The cost function calculation unit is used to calculate the cost function based on the execution cycle of the i-th iteration calculation and the (i-1)-th iteration calculation. If the cost function is less than 0, the execution cycle of the i-th iteration calculation remains unchanged, and the stable number is set to 0. If the cost function is equal to 0, the execution cycle of the i-th iteration calculation remains unchanged, and the stable number is incremented by 1. If the cost function is greater than 0, the execution cycle of the i-th iteration calculation is replaced with the execution cycle of the (i-1)-th iteration calculation, and the stable number is set to 0. The stable number determination unit is used to determine whether the stable number is equal to the maximum value of the stable number. If the stable number is equal to the maximum value of the stable number, then output... If the execution cycle of the i-th iteration calculation and the number of the q-th type of calculation unit used determine that the stable number of calculations is not equal to the maximum value of the stable number of calculations, then the stable number of calculations determination unit is activated. The stable number of calculations determination unit is used to calculate parameters based on the number of the j-th type of calculation unit, the number of the j-th type of calculation unit used, and the execution cycle of the i-th iteration calculation. Under the premise that the number of the j-th type of calculation unit has not reached the upper limit, the maximum value of the parameters, the q-th parameter, is obtained. Then, the number of the q-th type of calculation unit used corresponding to the q-th parameter is obtained, where j and q are natural numbers greater than or equal to 0. The number of used units determination unit is used to determine the size of the number of the q-th type of calculation unit used compared to the upper limit of the number of the q-th type of calculation unit. If the number of the q-th type of calculation unit used is less than the upper limit of the number of the q-th type of calculation unit, the number of the q-th type of calculation unit used is incremented by 1, and then the execution cycle calculation unit is activated. If the number of the q-th type of calculation unit used is greater than or equal to the upper limit of the number of the q-th type of calculation unit, then the number of the q-th type of calculation unit has reached the upper limit, and then the parameter calculation unit is activated.
[0022] The present invention also provides an apparatus comprising:
[0023] processor;
[0024] Memory used to store processor-executable instructions;
[0025] The processor is configured to implement the acquisition method when executing instructions stored in the memory.
[0026] A computer-readable storage medium includes computer instructions that, when executed by a processor, implement the acquisition method. Attached Figure Description
[0027] Figure 1 This is a flowchart of the acquisition method in some embodiments of the present invention;
[0028] Figure 2 This is a structural block diagram of a system for implementing the acquisition method in some embodiments of the present invention. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions in the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without inventive effort are within the scope of protection of this invention. Unless otherwise defined, the technical or scientific terms used herein should have the ordinary meaning understood by those skilled in the art. The terms "comprising" and similar expressions used herein mean that the element or object preceding the word covers the element or object listed following the word and its equivalents, but do not exclude other elements or objects.
[0030] To address the problems existing in the prior art, embodiments of the present invention provide a method for obtaining [the technology / equipment]. (Refer to...) Figure 1 The acquisition method is used to obtain the number of computational units and the shortest execution time of the computation graph, and includes the following steps:
[0031] S1: Increment i by 1, then obtain the execution cycle of the i-th iteration and the (i-1)-th iteration, where i is a natural number greater than or equal to 0;
[0032] S2: Calculate the cost function based on the execution cycle of the i-th iteration and the (i-1)-th iteration. If the cost function is less than 0, the execution cycle of the i-th iteration remains unchanged, and the number of stable iterations is set to 0. If the cost function is equal to 0, the execution cycle of the i-th iteration remains unchanged, and the number of stable iterations is incremented by 1. If the cost function is greater than 0, the execution cycle of the i-th iteration is replaced with the execution cycle of the (i-1)-th iteration, and the number of stable iterations is set to 0.
[0033] S3: Determine if the number of stable iterations is equal to the maximum value of the number of stable iterations. If the number of stable iterations is equal to the maximum value of the number of stable iterations, output the execution cycle of the i-th iteration calculation and the number of the q-th type of calculation unit used. If the number of stable iterations is not equal to the maximum value of the number of stable iterations, execute step S4.
[0034] S4: Based on the number of the j-th type of computing units, the number of the j-th type of computing units used, and the execution cycle calculation parameters of the i-th iteration, obtain the maximum value of the q-th parameter in the parameters, provided that the number of the j-th type of computing units has not reached the upper limit. Then obtain the number of the q-th type of computing units used corresponding to the q-th parameter, where j and q are both natural numbers greater than or equal to 0.
[0035] S5: Determine the difference between the number of the q-th type of computing units used and the upper limit of the number of the q-th type of computing units. If the number of the q-th type of computing units used is less than the upper limit of the number of the q-th type of computing units, increment the number of the q-th type of computing units used by 1, and then execute step S1. If the number of the q-th type of computing units used is greater than or equal to the upper limit of the number of the q-th type of computing units, then the number of the q-th type of computing units has reached the upper limit, and then execute step S4.
[0036] In some embodiments, the process further includes the following steps before performing step S1 for the first time:
[0037] Initialize i to 0, initialize the execution cycle of the i-th iteration to the maximum value, initialize the stable number of iterations to 0, set the maximum value of the stable number of iterations to be greater than or equal to 50 and less than or equal to 100, initialize the number of the j-th type of computing unit to 1, set the j-th type of computing unit to have not reached its upper limit, and set the maximum value of the execution cycle of the i-th iteration to be greater than or equal to 10. 60 and less than or equal to 10 70 .
[0038] In some embodiments, calculating the cost function based on the execution cycle calculated in the i-th iteration and the execution cycle calculated in the (i-1)-th iteration includes: calculating the difference between the execution cycle calculated in the i-th iteration and the execution cycle calculated in the (i-1)-th iteration to obtain the cost function.
[0039] In some embodiments, calculating the parameter based on the number of j-th type computing units, the number of j-th type computing units used, and the execution cycle of the i-th iteration includes: calculating the product of the number of j-th type computing units and the execution cycle of the i-th iteration, and then calculating the quotient of the number of j-th type computing units used and the product to obtain the parameter. This can be expressed by the formula:
[0040]
[0041] , where reta[j] represents the parameter, used_resource[j] represents the number of times the j-th type of computing unit is used, resource[j] represents the number of the j-th type of computing unit, and cycle[i] represents the stable number of execution cycles of the i-th type of computing unit.
[0042] In some embodiments, obtaining the execution cycle of the i-th iteration calculation and the execution cycle of the (i-1)-th iteration calculation includes: obtaining the execution cycle of the i-th iteration calculation and the execution cycle of the (i-1)-th iteration calculation through a list algorithm.
[0043] Figure 2 This is a structural block diagram of a system for implementing the acquisition method in some embodiments of the present invention. (Refer to...) Figure 2The system 100 is used to implement the acquisition method. The system 100 includes an execution cycle calculation unit 101, a cost function calculation unit 102, a stability count judgment unit 103, a parameter calculation unit 104, and a usage count judgment unit 105. The execution cycle calculation unit 101 is used to increment i by 1, and then obtain the execution cycle of the i-th iteration calculation and the execution cycle of the (i-1)-th iteration calculation, where i is a natural number greater than or equal to 0. The cost function calculation unit 102 is used to calculate the execution cycle of the i-th iteration calculation and the execution cycle of the (i-1)-th iteration calculation based on the execution cycle of the i-th iteration calculation and the execution cycle of the (i-1)-th iteration calculation. The cost function is calculated periodically. If the cost function is less than 0, the execution period of the i-th iteration remains unchanged, and the stable number is set to 0. If the cost function is equal to 0, the execution period of the i-th iteration remains unchanged, and the stable number is incremented by 1. If the cost function is greater than 0, the execution period of the i-th iteration is replaced with the execution period of the (i-1)-th iteration, and the stable number is set to 0. The stable number judgment unit 103 is used to determine whether the stable number is equal to the maximum value of the stable number. If the stable number is equal to the maximum value of the stable number... If the number of stable calculations is not equal to the maximum value of the stable calculations, then the stable calculation unit 103 is activated. The stable calculation unit 103 is used to calculate parameters based on the number of the j-th type of calculation units, the number of the j-th type of calculation units used, and the execution cycle of the i-th iteration. Under the premise that the number of the j-th type of calculation units has not reached the upper limit, the maximum value of the parameters, the q-th parameter, is obtained. Then, the number of the q-th type of calculation units used corresponding to the q-th parameter is obtained, where j and q are natural numbers greater than or equal to 0. The number of used units is used to determine the size of the number of the q-th type of calculation units used compared with the upper limit of the number of the q-th type of calculation units. If the number of the q-th type of calculation units used is less than the upper limit of the number of the q-th type of calculation units, then the number of the q-th type of calculation units used is incremented by 1, and then the execution cycle calculation unit 101 is activated. If the number of the q-th type of calculation units used is greater than or equal to the upper limit of the number of the q-th type of calculation units, then the number of the q-th type of calculation units has reached the upper limit, and then the parameter calculation unit 104 is activated.
[0044] The present invention also provides an apparatus comprising:
[0045] processor;
[0046] Memory used to store processor-executable instructions;
[0047] The processor is configured to implement the acquisition method when executing instructions stored in the memory.
[0048] A computer-readable storage medium includes computer instructions that, when executed by a processor, implement the acquisition method.
[0049] Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or any combination thereof. More specific examples of computer-readable storage media include: electrical connections having one or more wires; portable computer disks; hard disks; random access memory (RAM); read-only memory (ROM); erasable programmable read-only memory (EPROM); flash memory; optical fiber; portable compact disk read-only memory (CD-ROM); optical storage devices; magnetic storage devices; or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device.
[0050] Program code contained on a computer-readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, or any suitable combination thereof.
[0051] Computer program code for performing the operations described herein may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server.
[0052] While embodiments of the present invention have been described in detail above, it will be apparent to those skilled in the art that various modifications and variations can be made to these embodiments. However, it should be understood that such modifications and variations fall within the scope and spirit of the invention as set forth in the claims. Furthermore, the invention described herein may have other embodiments and can be implemented or carried out in various ways.
Claims
1. A method for obtaining the number of computational units and the shortest execution time of a computation graph, characterized in that, Includes the following steps: S1: Increment i by 1, then obtain the execution cycle of the i-th iteration and the (i-1)-th iteration, where i is a natural number greater than or equal to 0; S2: Calculate the cost function based on the execution cycle of the i-th iteration and the (i-1)-th iteration. If the cost function is less than 0, the execution cycle of the i-th iteration remains unchanged, and the number of stable iterations is set to 0. If the cost function is equal to 0, the execution cycle of the i-th iteration remains unchanged, and the number of stable iterations is incremented by 1. If the cost function is greater than 0, the execution cycle of the i-th iteration is replaced with the execution cycle of the (i-1)-th iteration, and the number of stable iterations is set to 0. S3: Determine if the number of stable iterations is equal to the maximum value of the number of stable iterations. If the number of stable iterations is equal to the maximum value of the number of stable iterations, output the execution cycle of the i-th iteration calculation and the number of the q-th type of calculation unit used. If the number of stable iterations is not equal to the maximum value of the number of stable iterations, execute step S4. S4: Based on the number of the j-th type of computing units, the number of the j-th type of computing units used, and the execution cycle calculation parameters of the i-th iteration, obtain the maximum value of the q-th parameter in the parameters, provided that the number of the j-th type of computing units has not reached the upper limit. Then obtain the number of the q-th type of computing units used corresponding to the q-th parameter, where j and q are both natural numbers greater than or equal to 0. S5: Determine the difference between the number of the q-th type of computing units used and the upper limit of the number of the q-th type of computing units. If the number of the q-th type of computing units used is less than the upper limit of the number of the q-th type of computing units, increment the number of the q-th type of computing units used by 1, and then execute step S1. If the number of the q-th type of computing units used is greater than or equal to the upper limit of the number of the q-th type of computing units, then the number of the q-th type of computing units has reached the upper limit, and then execute step S4.
2. The acquisition method according to claim 1, characterized in that, Before the first execution of step S1, the following also applies: Initialize i to 0, initialize the execution cycle of the i-th iteration to the maximum value, initialize the stable number of iterations to 0, set the maximum value of the stable number of iterations to be greater than or equal to 50 and less than or equal to 100, initialize the number of the j-th type of computing unit to 1, set the j-th type of computing unit to have not reached its upper limit, and set the maximum value of the execution cycle of the i-th iteration to be greater than or equal to 10. 60 and less than or equal to 10 70 .
3. The acquisition method according to claim 1, characterized in that, The calculation of the cost function based on the execution cycle calculated in the i-th iteration and the execution cycle calculated in the (i-1)-th iteration includes: The cost function is obtained by calculating the difference between the execution cycle calculated in the i-th iteration and the execution cycle calculated in the (i-1)-th iteration.
4. The acquisition method according to claim 1, characterized in that, The calculation parameters based on the number of j-th type computing units, the number of j-th type computing units used, and the execution cycle of the i-th iteration include: Calculate the product of the number of the j-th type of computing units and the execution cycle of the i-th iteration, and then calculate the quotient of the number of the j-th type of computing units used and the product to obtain the parameters.
5. The acquisition method according to claim 1, characterized in that, The process of obtaining the execution cycle of the i-th iteration calculation and the execution cycle of the (i-1)-th iteration calculation includes: The execution cycle of the i-th iteration and the (i-1)-th iteration are obtained using a list algorithm.
6. A system for implementing the acquisition method as described in any one of claims 1 to 5, characterized in that, The system includes an execution cycle calculation unit, a cost function calculation unit, a stability count judgment unit, a parameter calculation unit, and a usage count judgment unit. The execution cycle calculation unit increments i by 1, then obtains the execution cycle of the i-th iteration and the execution cycle of the (i-1)-th iteration, where i is a natural number greater than or equal to 0. The cost function calculation unit calculates the cost function based on the execution cycle of the i-th iteration and the (i-1)-th iteration. If the cost function is less than 0, the execution cycle of the i-th iteration remains unchanged, and the stability count is set to 0. If the cost function is equal to 0, the execution cycle of the i-th iteration remains unchanged, and the stable count is incremented by 1. If the cost function is greater than 0, the execution cycle of the i-th iteration is replaced with the execution cycle of the (i-1)-th iteration, and the stable count is set to 0. The stable count judgment unit is used to determine whether the stable count is equal to the maximum value of the stable count. If the stable count is equal to the maximum value of the stable count, the execution cycle of the i-th iteration and the number of the q-th type of calculation unit used are output. If the stable count is not equal to the maximum value of the stable count, the stable count judgment unit is driven to work. The stability count determination unit is used to obtain the maximum value of the q-th parameter among the parameters, based on the number of j-th type computing units, the number of j-th type computing units used, and the execution cycle calculation parameters of the i-th iteration, provided that the number of j-th type computing units has not reached the upper limit. Then, it obtains the number of q-th type computing units used corresponding to the q-th parameter, where j and q are both natural numbers greater than or equal to 0. The number of used units determination unit is used to determine the size of the number of q-th type computing units used compared to the upper limit of the number of q-th type computing units. If the number of q-th type computing units used is less than the upper limit of the number of q-th type computing units, the number of q-th type computing units used is incremented by 1, and then the execution cycle calculation unit is driven to work. If the number of q-th type computing units used is greater than or equal to the upper limit of the number of q-th type computing units, the number of q-th type computing units has reached the upper limit, and then the parameter calculation unit is driven to work.
7. An apparatus, characterized in that, include: processor; Memory used to store processor-executable instructions; When the processor is configured to execute the instructions stored in the memory, it implements the acquisition method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, It includes computer instructions, which, when executed by a processor, implement the acquisition method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Computational graph optimization method and device
CN114756444A
Method, system, equipment and medium for optimizing layout format of computational graph
CN116628271A