Compiler optimization method, device and equipment based on tensor data calculation reasoning
By obtaining and optimizing the compiler's design structure information and parameter adjustment learning parameters, and using automatic parameter adjustment strategy to optimize the compiler, it is consistent with the specified input model, solving the inefficiency caused by mismatch between the compiler and the model in the existing technology The problem improves the efficiency of tensor data inference.
Patent Information
- Application Number
- CN202211000908.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-19
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2042-08-19
AI Technical Summary
The prior art cannot fit the compiler with the specified input model, resulting in inefficient in inference of tensor data.
By obtaining the design structure information of the compiler to be optimized, setting the target intermediate conversion layer and parameter adjustment learning parameters, determining the compiler object to be optimized, and optimizing it through the automatic parameter adjustment strategy until it matches the specified input model.
It effectively improves the efficiency of tensor data inference, so that the compiler can better match the input model, thereby improving computing performance.
Smart Images

Figure CN115423089B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep learning technology, and in particular to a compiler optimization method, device and equipment based on tensor data computational reasoning. Background Art
[0002] With the continuous development of artificial intelligence, deep learning technology has been widely used in various fields, and the application of deep learning is inseparable from the reasoning framework, such as TensorFlow, PyTorch and TNN frameworks, but different reasoning frameworks have different functions. For example, TensorFlow and PyTorch are platform-level frameworks that can be used for training and reasoning, while the TNN framework can only be used for reasoning. Regardless of the functional framework, some related acceleration devices are adapted behind it. In order to facilitate the reasoning of tensor data, the concept of compiler is introduced, that is, a series of operations are performed on the model developed by the developer through the compiler, but the compiler operates differently for different models. If the compiler is not optimized in time, the compiler will not match the specified input model, resulting in low efficiency of tensor data reasoning.
[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of the present invention is to provide a compiler optimization method, device and equipment based on tensor data computational reasoning, aiming to solve the technical problem that the prior art cannot obtain a compiler that matches the specified input model, resulting in low efficiency of tensor data reasoning.
[0005] To achieve the above object, the present invention provides a compiler optimization method based on tensor data calculation reasoning, and the compiler optimization method based on tensor data calculation reasoning comprises the following steps:
[0006] Acquire design structure information of the compiler to be optimized, and obtain a target intermediate conversion layer and target intermediate conversion layer execution operation according to the design structure information;
[0007] Setting target parameter adjustment learning parameters according to the target intermediate conversion layer;
[0008] Determine a compiler object to be optimized according to the target intermediate conversion layer execution operation;
[0009] The target automatic parameter tuning strategy is used to optimize the compiler object to be optimized according to the target parameter tuning learning parameters.
[0010] Optionally, the acquiring design structure information of the compiler to be optimized, and obtaining the target intermediate conversion layer and the target intermediate conversion layer execution operation according to the design structure information, includes:
[0011] Acquire design structure information of the compiler to be optimized, and obtain a corresponding hierarchical set according to the design structure information;
[0012] Selecting a target intermediate conversion layer from the set of layers according to the layer characteristics;
[0013] Acquire a process of generating a target self-decoding from a target unified format intermediate representation element according to the target intermediate conversion layer;
[0014] The target intermediate conversion layer execution operation is obtained according to the process of generating the target self-decoding from the target unified format intermediate representation element.
[0015] Optionally, the target parameter adjustment learning parameters include at least a parameter adjustment learning type, a target learning object, and a target parameter adjustment number;
[0016] The step of setting target parameter adjustment learning parameters according to the target intermediate conversion layer includes:
[0017] Obtain the data exchange times and data decomposition performance for generating target self-decoding;
[0018] Setting a parameter adjustment learning type and a target learning object according to the number of data exchanges and the data decomposition performance;
[0019] Obtaining a target range of parameter settings according to the target intermediate conversion layer, and obtaining a maximum value of the parameter settings and a minimum value of the parameter settings according to the target range;
[0020] The target parameter adjustment times are set according to the maximum value of the parameter setting and the minimum value of the parameter setting.
[0021] Optionally, determining the compiler object to be optimized according to the target intermediate conversion layer executing operation includes:
[0022] Obtaining an execution node of a target intermediate conversion layer according to the intermediate conversion layer execution operation;
[0023] Acquire data optimization strategies for each layer set in the target intermediate conversion layer;
[0024] Determine the target operation to be performed at each layer according to the execution node and the data optimization strategy of each layer;
[0025] The compiler object to be optimized is obtained according to the target operations to be executed by each layer.
[0026] Optionally, obtaining the compiler object to be optimized according to the target operations to be performed by each layer includes:
[0027] Obtaining a computational graph of a specified input model according to the target operations to be performed by each layer;
[0028] Obtain memory loading data for each operation according to the calculation graph of the specified input model;
[0029] Obtaining multi-layer operation interaction data according to the memory loading data;
[0030] The multi-layer operations of the multi-layer operation interaction data are taken as compiler objects to be optimized.
[0031] Optionally, obtaining the compiler object to be optimized according to the target operations to be performed by each layer includes:
[0032] Obtaining intermediate representation elements in a unified format to be processed according to target operations to be performed at each layer;
[0033] Constructing a target feature matrix according to the intermediate representation element in the unified format to be processed;
[0034] Obtaining matrix calculation duration and matrix calculation occupied resources according to the target feature matrix;
[0035] When the matrix calculation duration is greater than a preset duration threshold and / or the matrix calculation occupied resources are greater than a preset storage resource threshold, the matrix calculation duration and the matrix calculation occupied resources are taken as compiler objects to be optimized.
[0036] Optionally, the performing parameter optimization on the compiler object to be optimized according to the target parameter learning parameters by using a target automatic parameter optimization strategy includes:
[0037] Setting a corresponding initial optimization strategy according to the compiler object to be optimized;
[0038] Adjusting the initial optimization strategy according to the target parameter adjustment learning parameters;
[0039] Obtain parameter optimization range according to the adjusted initial optimization strategy;
[0040] The target automatic parameter adjustment strategy is used to adjust and optimize the parameters of the compiler object to be optimized within the parameter optimization range to obtain a compiler that matches the specified input model.
[0041] In addition, to achieve the above-mentioned purpose, the present invention also proposes a compiler optimization device based on tensor data calculation reasoning, and the compiler optimization device based on tensor data calculation reasoning includes:
[0042] An acquisition module, used for acquiring design structure information of the compiler to be optimized, and obtaining a target intermediate conversion layer and an execution operation of the target intermediate conversion layer according to the design structure information;
[0043] A setting module, used for setting target parameter adjustment learning parameters according to the target intermediate conversion layer;
[0044] A determination module, used to determine a compiler object to be optimized according to the target intermediate conversion layer execution operation;
[0045] The optimization module is used to optimize the parameters of the compiler object to be optimized according to the target parameter learning parameters through a target automatic parameter adjustment strategy.
[0046] In addition, to achieve the above-mentioned objectives, the present invention also proposes a compiler optimization device based on tensor data computational reasoning, the compiler optimization device based on tensor data computational reasoning comprising: a memory, a processor, and a compiler optimization program based on tensor data computational reasoning stored in the memory and executable on the processor, the compiler optimization program based on tensor data computational reasoning being configured to implement the compiler optimization method based on tensor data computational reasoning as described above.
[0047] In addition, to achieve the above-mentioned objectives, the present invention also proposes a storage medium, on which a compiler optimization program based on tensor data calculation reasoning is stored. When the compiler optimization program based on tensor data calculation reasoning is executed by a processor, the compiler optimization method based on tensor data calculation reasoning as described above is implemented.
[0048] The compiler optimization method based on tensor data computational reasoning proposed in the present invention obtains the design structure information of the compiler to be optimized, obtains the target intermediate conversion layer and the target intermediate conversion layer execution operation according to the design structure information; sets the target parameter learning parameters according to the target intermediate conversion layer; determines the compiler object to be optimized according to the target intermediate conversion layer execution operation; and optimizes the compiler object to be optimized according to the target parameter learning parameters through a target automatic parameter adjustment strategy; through the above-mentioned method, sets the target parameter learning parameters according to the target intermediate conversion layer of the compiler to be optimized, and determines the compiler object to be optimized according to the target intermediate conversion layer execution operation, and then optimizes the compiler object to be optimized from the perspective of the target parameter learning parameters through the target automatic parameter adjustment strategy, so that a compiler that matches the specified input model can be obtained, thereby effectively improving the efficiency of tensor data reasoning. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 It is a structural diagram of a compiler optimization device based on tensor data computational reasoning in a hardware operating environment involved in an embodiment of the present invention;
[0050] Figure 2 It is a flowchart of a first embodiment of a compiler optimization method based on tensor data calculation reasoning of the present invention;
[0051] Figure 3 It is a flow chart of a second embodiment of a compiler optimization method based on tensor data computational reasoning according to the present invention;
[0052] Figure 4 It is a functional module diagram of the first embodiment of the compiler optimization device based on tensor data calculation reasoning of the present invention.
[0053] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0054] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0055] Reference Figure 1 , Figure 1 A schematic diagram of the structure of a compiler optimization device based on tensor data computational reasoning in a hardware operating environment involved in an embodiment of the present invention.
[0056] like Figure 1 As shown, the compiler optimization device based on tensor data calculation reasoning may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable non-volatile memory (Non-VolatileMemory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0057] Those skilled in the art will understand that Figure 1 The structure shown in the does not constitute a limitation on the compiler optimization device based on tensor data computational reasoning, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0058] like Figure 1As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a compiler optimization program based on tensor data computational reasoning.
[0059] exist Figure 1 In the compiler optimization device based on tensor data computational reasoning shown, the network interface 1004 is mainly used for data communication with the network integration platform workstation; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the compiler optimization device based on tensor data computational reasoning of the present invention can be set in the compiler optimization device based on tensor data computational reasoning, and the compiler optimization device based on tensor data computational reasoning calls the compiler optimization program based on tensor data computational reasoning stored in the memory 1005 through the processor 1001, and executes the compiler optimization method based on tensor data computational reasoning provided by the embodiment of the present invention.
[0060] Based on the above hardware structure, an embodiment of the compiler optimization method based on tensor data computational reasoning of the present invention is proposed.
[0061] Reference Figure 2 , Figure 2 It is a flowchart diagram of the first embodiment of the compiler optimization method based on tensor data calculation reasoning of the present invention.
[0062] In a first embodiment, the compiler optimization method based on tensor data computational reasoning includes the following steps:
[0063] Step S10, obtaining design structure information of the compiler to be optimized, and obtaining a target intermediate conversion layer and a target intermediate conversion layer execution operation according to the design structure information.
[0064] It should be noted that the executor of this embodiment is a compiler optimization device based on tensor data computational reasoning, and may also be other devices that can achieve the same or similar functions, such as a controller for a tensor computation compiler, etc. This embodiment does not limit this. In this embodiment, a controller for a tensor computation compiler is used as an example for explanation.
[0065] It should be understood that the compiler to be optimized refers to a compiler for tensor data computational reasoning that needs to be optimized. By optimizing the compiler, the optimized compiler is more suitable for the input model. The design structure information refers to the structural information of the compiler to be optimized. The design structure information includes the front-end access layer, the target intermediate conversion layer and the terminal execution layer, and is applied to the field of deep learning reasoning. The target intermediate conversion layer execution operation refers to the execution operation of the target intermediate conversion layer to generate target self-decoding.
[0066] Further, step S10 includes: obtaining design structure information of the compiler to be optimized, and obtaining a corresponding hierarchical set according to the design structure information; selecting a target intermediate conversion layer from the hierarchical set according to hierarchical characteristics; obtaining a process for generating a target self-decoding from a target unified format intermediate representation element according to the target intermediate conversion layer; and obtaining a target intermediate conversion layer execution operation according to the process for generating a target self-decoding from a target unified format intermediate representation element.
[0067] It can be understood that the layered set refers to a set consisting of the various layers of the compiler to be optimized, for example, the front-end access layer is located at the first layer of the compiler to be optimized, the target intermediate conversion layer is located at the second layer of the compiler to be optimized, and the terminal execution layer is located at the third layer of the compiler to be optimized, and the layered characteristics refer to the processing characteristics of each layer, for example, the characteristic of the front-end access layer is a unified format, the characteristic of the target intermediate conversion layer is to generate target self-decoding, and the characteristic of the terminal execution layer is to generate a target device executable file.
[0068] It should be understood that after the target intermediate conversion layer is selected from the hierarchical set, the process of generating the target self-decoding from the target unified format intermediate representation element is obtained. Specifically, the front-end access layer transmits the target unified format intermediate representation element to the target intermediate conversion layer, and the target intermediate conversion layer is optimized according to the set data optimization strategy. After the optimization is completed, a tensor calculation model file will be generated, and then the target self-decoding will be generated according to the tensor calculation model file. At this time, a series of processes for generating target self-decoding will be used as the target intermediate conversion layer execution operation.
[0069] Step S20, setting target parameter adjustment learning parameters according to the target intermediate conversion layer.
[0070] It can be understood that the target parameter tuning learning parameters refer to the parameters for automatically tuning the optimization compiler object within the set range. The target parameter tuning learning parameters include the parameter tuning learning type, the target learning object, and the target parameter tuning number. The parameter tuning learning type refers to the problem type of the parameter tuning learning, the target learning object refers to the goal of the parameter tuning learning, and the target parameter tuning number refers to the number of times required to achieve the goal. The target parameter tuning number is not an infinite setting, but the maximum parameter tuning number within the target range set by the parameter.
[0071] Furthermore, the target parameter adjustment learning parameters include a parameter adjustment learning type, a target learning object, and a target parameter adjustment number. Step S20 includes: obtaining the number of data exchanges and data decomposition performance for generating a target self-decoding; setting the parameter adjustment learning type and the target learning object according to the number of data exchanges and the data decomposition performance; obtaining a target range of parameter settings according to the target intermediate conversion layer, and obtaining a maximum parameter setting value and a minimum parameter setting value according to the target range; setting the target parameter adjustment number according to the maximum parameter setting value and the minimum parameter setting value.
[0072] It should be understood that the number of data exchanges refers to the number of times the data of the target unified format intermediate representation element is exchanged between the video memory and the main memory when the target intermediate conversion layer is optimized, and the data decomposition performance refers to the performance of matrix decomposition when performing tensor calculations on the data of the target unified format intermediate representation element. Then, the parameter adjustment learning type and the target learning object are set according to the number of data exchanges and the data decomposition performance, and the target parameter adjustment number is set according to the maximum parameter setting value and the minimum parameter setting value of the target range.
[0073] Step S30, determining a compiler object to be optimized according to the target intermediate conversion layer execution operation.
[0074] It should be understood that the compiler object to be optimized refers to the object to be optimized within the compiler to be optimized, that is, the optimization of the compiler to be optimized is achieved by optimizing the compiler object to be optimized. Specifically, the compiler object to be optimized is determined according to the execution operation of the target intermediate conversion layer. The compiler object to be optimized includes but is not limited to multi-layer operations of multi-layer operation interaction data, matrix calculation duration, and matrix calculation occupied resources, etc.
[0075] Step S40, performing parameter optimization on the compiler object to be optimized according to the target parameter learning parameters through a target automatic parameter optimization strategy.
[0076] Further, step S40 includes: setting a corresponding initial optimization strategy according to the compiler object to be optimized; adjusting the initial optimization strategy according to the target parameter learning parameters; obtaining a parameter optimization range according to the adjusted initial optimization strategy; and optimizing the parameters of the compiler object to be optimized within the parameter optimization range through the target automatic parameter adjustment strategy to obtain a compiler that matches the specified input model.
[0077] It should be understood that the target automatic parameter tuning strategy refers to a strategy for optimizing the parameters of the compiler object to be optimized. After obtaining the target parameter tuning learning parameters, the initial optimization strategy is adjusted according to the target parameter tuning learning parameters, and then the parameter optimization range is obtained according to the adjusted initial optimization strategy, that is, within the parameter optimization range, a compiler suitable for the input model can be adjusted. For example, the parameter optimization range is [0,300]. After adjusting to 300 times, the compiler with the highest fit during the adjustment process is used as the compiler that fits the specified input model.
[0078] This embodiment obtains the design structure information of the compiler to be optimized, obtains the target intermediate conversion layer and the target intermediate conversion layer execution operation according to the design structure information; sets the target parameter learning parameters according to the target intermediate conversion layer; determines the compiler object to be optimized according to the target intermediate conversion layer execution operation; and optimizes the compiler object to be optimized according to the target parameter learning parameters through a target automatic parameter adjustment strategy; through the above-mentioned method, the target parameter learning parameters are set according to the target intermediate conversion layer of the compiler to be optimized, and the compiler object to be optimized is determined according to the target intermediate conversion layer execution operation, and then the compiler object to be optimized is optimized from the perspective of the target parameter learning parameters through the target automatic parameter adjustment strategy, so that a compiler that matches the specified input model can be obtained, thereby effectively improving the efficiency of tensor data reasoning.
[0079] In one embodiment, if Figure 3 Based on the first embodiment, a second embodiment of the compiler optimization method based on tensor data calculation reasoning of the present invention is proposed, and step S30 includes:
[0080] Step S301, obtaining an execution node of a target intermediate conversion layer according to an execution operation of the intermediate conversion layer.
[0081] It should be understood that the execution node refers to the node where each layer of the target intermediate conversion layer executes the target unified format intermediate representation element. There can be multiple execution nodes, that is, the same node can perform multiple operations.
[0082] Step S302: obtaining data optimization strategies for each layer set in the target intermediate conversion layer.
[0083] It can be understood that the data optimization strategy refers to a strategy for optimizing the target unified format intermediate representation elements at each layer of the target intermediate conversion layer. The data optimization strategy includes but is not limited to operator fusion optimization strategy, matrix decomposition optimization strategy and convolution operator optimization strategy.
[0084] Step S303: determining the target operation to be performed at each layer according to the execution node and the data optimization strategy of each layer.
[0085] It should be understood that after obtaining the execution node, the target operation to be performed at each layer of the execution node is obtained according to the data optimization strategy. For example, there are three execution nodes in the target intermediate conversion layer, namely the first execution node, the second execution node and the third execution node. The operator fusion optimization strategy and the matrix decomposition optimization strategy are set at the layer where the first execution node is located, the matrix decomposition optimization strategy is set at the layer where the second execution node is located, and the matrix decomposition optimization strategy and the convolution operator optimization strategy are set at the layer where the third execution node is located. Then, the corresponding target operation is obtained when each execution node is executed.
[0086] Step S304: obtaining a compiler object to be optimized according to the target operations to be performed by each layer.
[0087] It can be understood that after obtaining the target operations to be performed by each layer, the compiler objects to be optimized are determined according to the target operations to be performed by each layer. The compiler objects to be optimized include but are not limited to multi-layer operations of multi-layer operation interaction data, matrix calculation duration, and matrix calculation occupied resources, etc.
[0088] Further, step S304 includes: obtaining a computational graph of a specified input model according to target operations to be performed at each layer; obtaining memory loading data of each operation according to the computational graph of the specified input model; obtaining multi-layer operation interaction data according to the memory loading data; and using multi-layer operations of the multi-layer operation interaction data as compiler objects to be optimized.
[0089] It should be understood that the calculation graph refers to the calculation structure diagram of the file corresponding to the specified input model. In the calculation graph of the model, each operation needs to load data from the memory and then calculate the loaded data. After the calculation is completed, the calculation result is returned to the memory. The above operations will involve multiple layers. Multi-layer operations are bound to bring a large amount of data interaction, that is, multi-layer operation interaction data. Therefore, it is necessary to optimize the multi-layer operations of multi-layer operation interaction data at this time, that is, to take the multi-layer operations as the compiler object to be optimized. The specific optimization method is to use conv (convolution) + bias (bias) + relu (activation function) as three operators that are often used in succession, and then fuse the three operators, and then group the fused operators. For example, 5*5 is a group, and 3*3 and 4 1*1 fused operators are another group. The above optimization method can maximize the use of hardware bandwidth resources and maximize the data transmission speed. At this time, the optimized compiler is most suitable for the specified input model.
[0090] Furthermore, step S304 also includes: obtaining an intermediate representation element in a unified format to be processed according to the target operation to be performed at each layer; constructing a target feature matrix according to the intermediate representation element in a unified format to be processed; obtaining a matrix calculation duration and matrix calculation occupied resources according to the target feature matrix; when the matrix calculation duration is greater than a preset duration threshold and / or the matrix calculation occupied resources are greater than a preset storage resource threshold, taking the matrix calculation duration and the matrix calculation occupied resources as compiler objects to be optimized.
[0091] It can be understood that after obtaining the intermediate representation element in the unified format to be processed transmitted by the front-end access layer, the intermediate representation element in the unified format to be processed is first constructed into a target feature matrix, and matrix multiplication is a necessary operation for tensor calculation. For example, matrix 32 and matrix 32 are multiplied, and the complexity of the multiplication calculation is cubic. The higher the complexity, the more resources occupied by the matrix calculation and the longer the time. At this time, the matrix calculation time and the resources occupied by the matrix calculation are taken as optimization objects. Specifically, the 32*32 matrix is split into multiple small matrices with side lengths of 32, 16, 8, 4 and 2. The multiplication calculation of the large matrix is then converted into the multiplication calculation of the small matrix. The optimal decomposition method is determined by the target automatic parameter adjustment strategy. For example, the target automatic parameter adjustment strategy is used to determine that the hardware is optimized for 4*4 matrix multiplication, which will reduce the matrix calculation time and reduce the resources occupied by the matrix calculation. The 32*32 matrix will be split into 64 4*4 small matrices for calculation.
[0092] It should be understood that the compiler object to be optimized can also perform convolution operations for tensor calculations. For example, the convolution operation is specifically as follows: the input and output tensor sizes are both 32*32, the number of input channels is 3, the number of output channels is 16, and the convolution kernel is 3*3. The above parameters are used to calculate that a total of 32*32*3*3*3*3*16*32*32 multiplication and addition operations are required. Obviously, the calculation time of the above convolution operation is relatively high. At this time, the above convolution operation is adjusted through the target automatic parameter adjustment strategy to find the fastest tensor calculation convolution calculation method, specifically: the input and output tensors are split into different sizes of 32, 16, 8, 4 and 2, and the number of channels is split into different sizes of 16, 8, 4 and 2.
[0093] This embodiment obtains the execution node of the target intermediate conversion layer according to the execution operation of the intermediate conversion layer; obtains the data optimization strategy set at each layer of the target intermediate conversion layer; determines the target operation to be executed by each layer according to the execution node and the data optimization strategy of each layer; obtains the compiler object to be optimized according to the target operation to be executed by each layer; through the above method, the execution node of the target intermediate conversion layer is obtained according to the execution operation of the intermediate conversion layer, and then the target operation to be executed by each layer is obtained according to the execution node of the target intermediate conversion layer and the data optimization strategy set at each layer, and then the compiler object to be optimized is determined according to the target operation to be executed by each layer, thereby effectively improving the accuracy of determining the compiler object to be optimized.
[0094] In addition, an embodiment of the present invention also proposes a storage medium, on which a compiler optimization program based on tensor data computational reasoning is stored. When the compiler optimization program based on tensor data computational reasoning is executed by a processor, the steps of the compiler optimization method based on tensor data computational reasoning as described above are implemented.
[0095] Since the storage medium adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought by the technical solutions of the above embodiments, which will not be described one by one here.
[0096] In addition, refer to Figure 4 The embodiment of the present invention further provides a compiler optimization device based on tensor data calculation reasoning, and the compiler optimization device based on tensor data calculation reasoning includes:
[0097] The acquisition module 10 is used to acquire the design structure information of the compiler to be optimized, and obtain the target intermediate conversion layer and the target intermediate conversion layer execution operation according to the design structure information.
[0098] The setting module 20 is used to set the target parameter adjustment learning parameters according to the target intermediate conversion layer.
[0099] The determination module 30 is used to determine the compiler object to be optimized according to the target intermediate conversion layer execution operation.
[0100] The optimization module 40 is used to optimize the parameters of the compiler object to be optimized according to the target parameter learning parameters through a target automatic parameter adjustment strategy.
[0101] This embodiment obtains the design structure information of the compiler to be optimized, obtains the target intermediate conversion layer and the target intermediate conversion layer execution operation according to the design structure information; sets the target parameter learning parameters according to the target intermediate conversion layer; determines the compiler object to be optimized according to the target intermediate conversion layer execution operation; and optimizes the compiler object to be optimized according to the target parameter learning parameters through a target automatic parameter adjustment strategy; through the above-mentioned method, the target parameter learning parameters are set according to the target intermediate conversion layer of the compiler to be optimized, and the compiler object to be optimized is determined according to the target intermediate conversion layer execution operation, and then the compiler object to be optimized is optimized from the perspective of the target parameter learning parameters through the target automatic parameter adjustment strategy, so that a compiler that matches the specified input model can be obtained, thereby effectively improving the efficiency of tensor data reasoning.
[0102] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.
[0103] In addition, for technical details not described in detail in this embodiment, please refer to the compiler optimization method based on tensor data computational reasoning provided in any embodiment of the present invention, which will not be repeated here.
[0104] In one embodiment, the acquisition module 10 is also used to obtain the design structure information of the compiler to be optimized, and obtain a corresponding hierarchical set based on the design structure information; select a target intermediate conversion layer from the hierarchical set according to the hierarchical characteristics; obtain a process for generating a target self-decoding from a target unified format intermediate representation element according to the target intermediate conversion layer; and obtain a target intermediate conversion layer execution operation based on the process for generating a target self-decoding from a target unified format intermediate representation element.
[0105] In one embodiment, the setting module 20 is also used for the target parameter learning parameters to include at least a parameter learning type, a target learning object, and a target parameter adjustment number; obtaining the number of data exchanges and data decomposition performance for generating a target self-decoding; setting the parameter learning type and the target learning object according to the number of data exchanges and the data decomposition performance; obtaining a target range of parameter settings according to the target intermediate conversion layer, and obtaining a maximum parameter setting value and a minimum parameter setting value according to the target range; and setting a target parameter adjustment number according to the maximum parameter setting value and the minimum parameter setting value.
[0106] In one embodiment, the determination module 30 is also used to obtain an execution node of a target intermediate conversion layer according to an execution operation of the intermediate conversion layer; obtain a data optimization strategy set at each layer of the target intermediate conversion layer; determine a target operation to be executed at each layer according to the execution node and the data optimization strategy of each layer; and obtain a compiler object to be optimized according to the target operation to be executed at each layer.
[0107] In one embodiment, the determination module 30 is also used to obtain a calculation graph of a specified input model according to the target operations to be performed at each layer; obtain memory loading data of each operation according to the calculation graph of the specified input model; obtain multi-layer operation interaction data according to the memory loading data; and use multi-layer operations of the multi-layer operation interaction data as compiler objects to be optimized.
[0108] In one embodiment, the determination module 30 is also used to obtain a to-be-processed intermediate representation element in a unified format according to the target operations to be performed at each layer; construct a target feature matrix according to the to-be-processed intermediate representation element in a unified format; obtain a matrix calculation duration and matrix calculation occupied resources according to the target feature matrix; when the matrix calculation duration is greater than a preset duration threshold and / or the matrix calculation occupied resources are greater than a preset storage resource threshold, use the matrix calculation duration and the matrix calculation occupied resources as compiler objects to be optimized.
[0109] In one embodiment, the optimization module 40 is also used to set a corresponding initial optimization strategy according to the compiler object to be optimized; adjust the initial optimization strategy according to the target parameter learning parameters; obtain a parameter optimization range according to the adjusted initial optimization strategy; and optimize the parameters of the compiler object to be optimized within the parameter optimization range through the target automatic parameter adjustment strategy to obtain a compiler that matches the specified input model.
[0110] Other embodiments or implementation methods of the compiler optimization device based on tensor data computational reasoning described in the present invention can refer to the above-mentioned method embodiments, which will not be repeated here.
[0111] In addition, it should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0112] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0113] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, an integrated platform workstation, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0114] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A compiler optimization method based on tensor data computational reasoning, characterized in that: The compiler optimization method based on tensor data calculation reasoning includes the following steps: Acquire design structure information of the compiler to be optimized, and obtain a target intermediate conversion layer and target intermediate conversion layer execution operation according to the design structure information; Setting target parameter adjustment learning parameters according to the target intermediate conversion layer; Determine a compiler object to be optimized according to the target intermediate conversion layer execution operation; Performing parameter optimization on the compiler object to be optimized according to the target parameter learning parameters through a target automatic parameter tuning strategy; The target parameter adjustment learning parameters include at least a parameter adjustment learning type, a target learning object, and a target parameter adjustment number; The step of setting target parameter adjustment learning parameters according to the target intermediate conversion layer includes: Obtain the data exchange times and data decomposition performance for generating target self-decoding; Setting a parameter adjustment learning type and a target learning object according to the number of data exchanges and the data decomposition performance; Obtaining a target range of parameter settings according to the intermediate conversion layer, and obtaining a maximum value of the parameter settings and a minimum value of the parameter settings according to the target range; Setting a target parameter adjustment number according to the maximum value of the parameter setting and the minimum value of the parameter setting; The step of determining the compiler object to be optimized according to the target intermediate conversion layer executing the operation comprises: Obtaining an execution node of a target intermediate layer according to the intermediate conversion layer executing operation; Obtaining data optimization strategies for each layer set in the target middle layer; Determine the target operation to be performed at each layer according to the execution node and the data optimization strategy of each layer; Obtaining a compiler object to be optimized according to the target operations to be performed by each layer; The step of obtaining the compiler object to be optimized according to the target operations to be performed by each layer includes: Obtaining intermediate representation elements in a unified format to be processed according to the target operations to be performed at each layer; Constructing a target feature matrix according to the intermediate representation element in the unified format to be processed; Obtaining matrix calculation duration and matrix calculation occupied resources according to the target feature matrix; When the matrix calculation duration is greater than a preset duration threshold and / or the matrix calculation occupied resources are greater than a preset storage resource threshold, the matrix calculation duration and the matrix calculation occupied resources are taken as compiler objects to be optimized.
2. The compiler optimization method based on tensor data computational reasoning according to claim 1, characterized in that: The step of obtaining design structure information of the compiler to be optimized, and obtaining a target intermediate conversion layer and an operation performed by the target intermediate conversion layer according to the design structure information, includes: Acquire design structure information of the compiler to be optimized, and obtain a corresponding hierarchical set according to the design structure information; Selecting a target intermediate conversion layer from the set of layers according to the layer characteristics; Acquire a process of generating a target self-decoding from a target unified format intermediate representation element according to the target intermediate conversion layer; The target intermediate conversion layer execution operation is obtained according to the process of generating the target self-decoding from the target unified format intermediate representation element.
3. The compiler optimization method based on tensor data computational reasoning according to claim 1, characterized in that: The step of obtaining the compiler object to be optimized according to the target operations to be performed by each layer includes: Obtaining a computational graph of a specified input model according to the target operations to be performed by each layer; Obtain memory loading data for each operation according to the calculation graph of the specified input model; Obtaining multi-layer operation interaction data according to the memory loading data; The multi-layer operations of the multi-layer operation interaction data are taken as compiler objects to be optimized.
4. The compiler optimization method based on tensor data computational reasoning according to any one of claims 1 to 3, characterized in that: After the target automatic parameter adjustment strategy is used to adjust the parameters of the compiler object to be optimized according to the target parameter adjustment learning parameters, the method further includes: Setting a corresponding initial optimization strategy according to the compiler object to be optimized; Adjusting the initial optimization strategy according to the target parameter adjustment learning parameters; Obtain parameter optimization range according to the adjusted initial optimization strategy; The target automatic parameter adjustment strategy is used to adjust and optimize the parameters of the compiler object to be optimized within the parameter optimization range to obtain a compiler that matches the specified input model.
5. A compiler optimization device based on tensor data computational reasoning, characterized in that: The compiler optimization device based on tensor data calculation reasoning includes: An acquisition module, used for acquiring design structure information of the compiler to be optimized, and obtaining a target intermediate conversion layer and an execution operation of the target intermediate conversion layer according to the design structure information; A setting module, used for setting target parameter adjustment learning parameters according to the target intermediate conversion layer; A determination module, used to determine a compiler object to be optimized according to the target intermediate conversion layer execution operation; An optimization module, used for optimizing the parameters of the compiler object to be optimized according to the target parameter adjustment learning parameters through a target automatic parameter adjustment strategy; The target parameter adjustment learning parameters at least include a parameter adjustment learning type, a target learning object, and a target parameter adjustment number; the setting module is also used to obtain the number of data exchanges and data decomposition performance for generating a target self-decoding; set the parameter adjustment learning type and the target learning object according to the number of data exchanges and the data decomposition performance; obtain a target range of parameter settings according to the intermediate conversion layer, and obtain a maximum value of parameter settings and a minimum value of parameter settings according to the target range; set the target parameter adjustment number according to the maximum value of parameter settings and the minimum value of parameter settings; The determination module is further used to obtain an execution node of a target intermediate layer according to an execution operation of the intermediate conversion layer; obtain a data optimization strategy set at each layer of the target intermediate layer; determine a target operation to be executed at each layer according to the execution node and the data optimization strategy of each layer; and obtain a compiler object to be optimized according to the target operation to be executed at each layer; The determination module is also used to obtain the intermediate representation element in the unified format to be processed according to the target operation to be performed by each layer; construct a target feature matrix according to the intermediate representation element in the unified format to be processed; obtain the matrix calculation duration and the matrix calculation occupied resources according to the target feature matrix; when the matrix calculation duration is greater than a preset duration threshold and / or the matrix calculation occupied resources are greater than a preset storage resource threshold, use the matrix calculation duration and the matrix calculation occupied resources as compiler objects to be optimized.
6. A compiler optimization device based on tensor data computational reasoning, characterized in that: The compiler optimization device based on tensor data computational reasoning comprises: a memory, a processor, and a compiler optimization program based on tensor data computational reasoning stored in the memory and executable on the processor, wherein the compiler optimization program based on tensor data computational reasoning is configured to implement a compiler optimization method based on tensor data computational reasoning as described in any one of claims 1 to 4.
7. A storage medium, characterized in that: The storage medium stores a compiler optimization program based on tensor data computational reasoning, and when the compiler optimization program based on tensor data computational reasoning is executed by a processor, the compiler optimization method based on tensor data computational reasoning as described in any one of claims 1 to 4 is implemented.
