Energy consumption management method and device, storage medium and electronic equipment

By determining the original weight values ​​of the network to be computed and its weight units in the neural network model, and adjusting them to the target accuracy based on the power reduction amount, the problem of high power consumption of neural network processors is solved, achieving effective reduction of power consumption and guarantee of computational accuracy.

CN115237237BActive Publication Date: 2025-12-19GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110438108.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-22
Publication Date
2025-12-19
Estimated Expiration
2041-04-22

AI Technical Summary

Technical Problem

Neural network processors consume a lot of energy when performing neural network operations, and how to reduce energy consumption has become an urgent problem to be solved.

Method used

By determining the original weight values ​​of the network to be computed and its weight units in the neural network model, the target weight value accuracy is determined based on the power reduction amount. The neural network processor then reduces the weight units from the original accuracy to the target accuracy to reduce energy consumption.

Benefits of technology

It effectively reduces the power consumption of neural network processors, meeting low power requirements while ensuring computational accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115237237B_ABST
    Figure CN115237237B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a method and device for energy consumption control of a neural network processor, a storage medium and an electronic device. In the embodiments, a to-be-operated network of a neural network model is determined, and original weight value precision of a weight unit of the to-be-operated network is determined. A target weight value precision of the weight unit is determined according to a power reduction amount and the original weight value precision of the weight unit. The weight unit is reduced from the original weight value precision to the target weight value precision by the neural network processor. The power of the neural network processor based on the low weight value precision for calculation is also reduced, thereby reducing energy consumption.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of electronic devices, in particular to an energy consumption management method and device, a storage medium and an electronic device. BACKGROUND

[0002] With the development of electronic devices such as mobile terminals, more and more scenarios on mobile terminals need to apply neural network models for operation. The operation of a neural network model can be performed by any processor capable of executing a neural network, such as a GPU (Graphics Processing Unit), a DSP (Digital Signal Process), an NPU (Neural-network Processing Unit), a CPU (central processing unit), etc. Since the neural network processor has many parameters and a large amount of computation, how to reduce energy consumption when performing neural network operation becomes a problem to be solved. SUMMARY

[0003] The embodiments of the present application provide an energy consumption management method and device, a storage medium and an electronic device, which can reduce the energy consumption of a neural network processor during operation.

[0004] In a first aspect, the embodiments of the present application provide an energy consumption management method of a neural network processor, comprising:

[0005] determining a to-be-operated network of a neural network model, and an original weight value precision of a weight unit of the to-be-operated network;

[0006] determining a target weight value precision of the weight unit according to a power reduction amount and the original weight value precision of the weight unit;

[0007] reducing the weight unit from the original weight value precision to the target weight value precision by the neural network processor.

[0008] In a second aspect, the embodiments of the present application also provide an energy consumption management device of a neural network processor, comprising:

[0009] a data acquisition module configured to determine a to-be-operated network of a neural network model, and an original weight value precision of a weight unit of the to-be-operated network;

[0010] a precision determination module configured to determine a target weight value precision of the weight unit according to a power reduction amount and the original weight value precision of the weight unit;

[0011] The precision adjustment module is configured to reduce the weight unit from the original weight value precision to the target weight value precision by the neural network processor.

[0012] In a third aspect, the embodiments of the present application further provide a computer readable storage medium having a computer program stored thereon, which, when executed on a computer, causes the computer to perform the energy consumption management and control method of the neural network processor according to any one of the embodiments of the present application.

[0013] In a fourth aspect, the embodiments of the present application further provide an electronic device including a processor and a memory, the memory having a computer program, and the processor is configured to execute the energy consumption management and control method of the neural network processor according to any one of the embodiments of the present application by invoking the computer program.

[0014] In a fifth aspect, the embodiments of the present application further provide an electronic device including:

[0015] The first processor is configured to determine a to-be-operated network of a neural network model and an original weight value precision of a weight unit of the to-be-operated network.

[0016] According to the power reduction amount and the original weight value precision of the weight unit, a target weight value precision of the weight unit is determined, and the target weight value precision is sent to the second processor.

[0017] The second processor is configured to reduce the weight unit from the original weight value precision to the target weight value precision.

[0018] The embodiments of the present application provide the technical solutions that the to-be-operated network of the neural network model and the original weight value precision of the weight unit of the to-be-operated network are determined, the target weight value precision of the weight unit is determined according to the power reduction amount and the original weight value precision of the weight unit, and then the weight unit is reduced from the original weight value precision to the target weight value precision by the neural network processor. Based on the solutions, when it is required to reduce the energy consumption of the neural network processor, the target weight value precision that can meet the low power requirement can be determined according to the power reduction amount, and the neural network processor performs calculation at the target weight value precision that is lower than the original weight value precision, so that the energy consumption can be reduced. BRIEF DESCRIPTION OF DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort.

[0020] Figure 1 A first flowchart of the energy consumption management method of the neural network processor provided in the embodiments of the present application.

[0021] Figure 2 A floating-point precision adjustment method in the energy consumption management method of the neural network processor provided in the present application.

[0022] Figure 3 A fixed-point precision adjustment method in the energy consumption management method of the neural network processor provided in the present application.

[0023] Figure 4 A structure diagram of the energy consumption management device of the neural network processor provided in the embodiments of the present application.

[0024] Figure 5 A structure diagram of the electronic device provided in the embodiments of the present application. DETAILED DESCRIPTION

[0025] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person skilled in the art without creative effort fall within the protection scope of the present application.

[0026] In this document, reference to“an embodiment” means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase“in an embodiment” in various places in the specification are not necessarily all referring to the same embodiment, nor are they necessarily mutually exclusive of one another. A person of ordinary skill in the art will understand that the embodiments described herein can be combined with one another.

[0027] The embodiments of the present application provide an energy consumption management method of a neural network processor. The execution subject of the energy consumption management method of the neural network processor can be an energy consumption management device of a neural network processor provided in the embodiments of the present application, or an electronic device integrated with the energy consumption management device of the neural network processor. The energy consumption management device of the neural network processor can be implemented in a hardware or software manner.

[0028] Please refer to Figure 1 , Figure 1 A first flowchart of the energy consumption management method of the neural network processor provided in the embodiments of the present application. The specific flow of the energy consumption management method of the neural network processor provided in the embodiments of the present application can be as follows:

[0029] 101, determine a network to be operated of the neural network model, and an original weight value precision of a weight unit of the network to be operated.

[0030] The neural network model in the embodiments of the present application can be any neural network model containing a convolution layer, where the convolution layer refers to a network layer requiring convolution operation.

[0031] The neural network processor is a processor that can be used to perform operation of the neural network model, such as GPU, DSP, NPU, CPU, etc. Hereinafter, the scheme is described by taking NPU as an example.

[0032] The embodiments of the present application can be applied to an electronic device provided with a neural network processor, wherein the electronic device can be provided with other processors in addition to the NPU, such as MCU (Microcontroller Unit), CPU, etc. The steps 101 and 102 of the embodiments of the present application can be executed by any processor in the electronic device, can be executed by other processors in addition to the NPU on the electronic device, such as MCU or CPU, etc., or can be executed by the NPU.

[0033] For example, in an embodiment, before determining the network to be operated of the neural network model, the method further comprises: when a power management event is detected, determining whether to trigger a low-power limit according to the power management event; when it is necessary to trigger the low-power limit, determining a power reduction amount according to the power management event, and performing the determination of the network to be operated of the neural network model; when it is not necessary to trigger the low-power limit, performing operation by the neural network processor with the original weight value precision of the weight unit in the neural network model.

[0034] In this embodiment, when the power management event is detected, it is determined whether the power management event triggers the low-power limit. For example, when the temperature of the electronic device is too high or the remaining power is reduced, the power management event is triggered, and the power management event triggers the low-power limit. When the power management event is triggered, the electronic device can determine the power amount to be reduced according to the current temperature value or the remaining power, which can be represented by a power value or a power reduction percentage. The electronic device determines the power reduction amount of the neural network processor according to the power management event, for example, determines that the neural network processor needs to reduce 25% of the power, i.e. needs to reduce 25% of the energy consumption, where the energy consumption refers to the power consumed by the neural network processor in operation.

[0035] In the embodiments of the present application, the parameters of each network layer in the neural network model, such as the weight values in the convolution kernel, can be fixed-point numbers or floating-point numbers, and both fixed-point numbers and floating-point numbers can be represented with different precisions. For example, according to the IEEE binary floating-point arithmetic standard, floating-point numbers can be divided into double precision (64 bits), single precision (32 bits) and half precision (16 bits). Fixed-point numbers include different precisions such as 64 bits, 32 bits, 16 bits and 8 bits, and different weight value precisions can be represented as different data ranges.

[0036] Taking floating-point numbers as an example, a floating-point number N can generally be represented as N = 2 E *M, where E is the exponent of the floating-point number, which is an integer, and M is the mantissa of the floating-point number, which represents the decimal part. The binary storage structure of floating-point data is divided into a sign bit + an exponent bit + a mantissa bit. Taking a 64-bit floating-point number as an example, the highest bit is the sign bit, the next 11 bits are the exponent bit, and the last 52 bits are the mantissa bit. The exponent bit of a 32-bit floating-point number has 8 bits, and the exponent bit of a 16-bit floating-point number has 5 bits. Based on this, the value range of the exponent bit of a 64-bit floating-point number is -1024~1023, the value range of the exponent bit of a 32-bit floating-point number is -128~127, and the value range of the exponent bit of a 16-bit floating-point number is -32~31.

[0037] For the NPU, different precisions of weight values use different circuits for operation, and the energy consumed is also different. As shown in the following table, the energy consumed for operation of data with different precisions.

[0038] Table 1 Energy consumption values of addition / multiplication operations of data with different precisions

[0039]

[0040] As can be seen from the above table, for the same type of data, the lower the precision, the less energy is consumed, and the multiplication operation is particularly obvious. For example, the multiplication operation of a 32-bit floating-point number consumes 3.7 PJ of energy, while the multiplication operation of a 16-bit floating-point number only consumes 1.1 PJ of energy. The energy consumption of some precision data is not shown in Table 1, and it can be understood that the energy consumption of the addition operation or the multiplication operation of each precision data can be determined in advance and stored in the electronic device.

[0041] Based on this, the electronic device of the embodiments of the present application can establish an energy consumption model, which represents the mapping relationship between the preset precision adjustment information and the preset power reduction amount. The preset precision adjustment information includes the weight value precision before reduction and the weight value precision after reduction. As shown in Table 2, this table only takes the multiplication operation of floating-point numbers as an example.

[0042] Table 2 mapping relationship between preset precision adjustment information and preset power reduction amount

[0043]

[0044] It should be noted that the specific values of the power reduction percentage in Table 2, 25%, 50% and 30%, are only for illustration, and the specific reduction amount can be calculated according to the actual energy consumption in Table 1.

[0045] Among them, the triggering of the power management event can be at any time when the electronic device is running, when the power management event is triggered, the NPU can be performing the operation of the neural network model, at this time the part of the neural network model that has not been calculated can be regarded as the to-be-operated network, and the data of each weight unit of the part of the network is respectively corresponding to the target weight value precision. If the power management event is triggered, the neural network model has not started operation, then the entire network of the neural network model can be regarded as the to-be-operated network.

[0046] Among them, when the neural network model is operating, the weight value precision is generally set in units of weight units. The weight value precision of all weight values in a weight unit is the same, and the weight value precision is generally determined according to the range of the weight values in the weight unit. The existing neural network model generally stores the model parameters as 64bit or 32bit according to different precision requirements for model operation when operating. For example, a network layer can be a weight unit, if a neural network model contains 50 network layers, the neural network model contains 50 weight units; or a filter is a weight unit, when a network layer contains N filters, the network layer can be divided into N weight units. Or, in other embodiments, a weight unit can also be a filter or a convolution kernel.

[0047] Based on the above description, when it is necessary to reduce the energy consumption of the operation of the neural network model, the electronic device determines the to-be-operated network of the neural network model, and the original weight value precision of the weight unit of the to-be-operated network.

[0048] 102. According to the power reduction amount and the original weight value precision of the weight unit, the target weight value precision of the weight unit is determined.

[0049] Next, the target weight value precision of the weight unit can be determined according to the obtained power reduction amount and the original weight value precision of the weight unit. For example, in an embodiment, the target weight value precision of the weight unit is determined according to the power reduction amount and the original weight value precision of the weight unit, including: obtaining the lowest weight value precision and the original weight value precision of the weight unit of the to-be-operated network; and determining the target weight value precision of the weight unit according to the power reduction amount, the original weight value precision and the lowest weight value precision of the weight unit.

[0050] In this embodiment, before the target weight value precision of the weight unit is calculated, the to-be-detected network is analyzed to determine the lowest weight value precision of the weight unit. This process can also be implemented in the process of encoding the neural network model. Since the model parameters of the same neural network model are fixed and unchanged, the lowest weight value precision of the weight unit can be determined and stored in the encoding stage. The electronic device can directly obtain and use the lowest weight value precision in the energy consumption management stage. For example, in an embodiment, before the to-be-operated network of the neural network model is determined, the method further includes: obtaining the weight values of the weight unit of the neural network model; and determining the lowest weight value precision of the weight unit according to the weight values of the weight unit.

[0051] In this embodiment, each weight value in the weight unit is evaluated to determine the lowest weight value precision of the weight unit. Specifically, the lowest weight value precision of the weight unit is determined according to the weight values of the weight unit, including: for the weight unit, a weight value precision lower than the original weight value precision of the weight unit is taken as a to-be-evaluated weight value precision; when a weight value not lower than a preset proportion in the weight values of the weight unit is located in the representation range of the to-be-evaluated weight value precision, the to-be-evaluated weight value precision is taken as a candidate weight value precision; and the candidate weight value precision with the lowest precision is taken as the lowest weight value precision of the weight unit.

[0052] Suppose a weight unit is a convolution layer, the convolution layer has 4 filters, the depth of the filter in the channel direction is 10, and the size of the convolution kernel is 3*3. The weight unit has a total of 3*3*4*10=360 weight values. Suppose the original weight value precision of the weight unit is 64 bits, and the data type is floating point number. Both 32 bits and 16 bits are used as the weight value precision to be evaluated. For 32-bit floating point numbers, the value range of the exponent bit of the 32-bit floating point number is -128~127, and the value range of the exponent bit of the 64-bit floating point number is -1024~1023. Then, whether the current value of the exponent bit of each of the 360 weight values is within the range of -128~127 is determined. When the current value of the exponent bit of the weight value is within the range of -128~127, the precision of the weight value is converted from 64 bits to 32 bits. The value of the exponent bit does not change, but the precision of the mantissa part decreases. If no less than a preset proportion of the weight values are within the value range of the exponent bit of the 32-bit floating point number, 32 bits can be used as the candidate weight value precision. For 16-bit weight value precision, the same method can be used to determine whether it can be used as the candidate weight value precision. Suppose the preset proportion is 75%, and after the one-by-one determination, 86% of the 360 weight values are within the value range of the exponent bit of the 32-bit floating point number, and 80% of the weight values are within the value range of the exponent bit of the 16-bit floating point number. Therefore, both 32 bits and 16 bits are candidate weight value precisions, and the precision of 16 bits is lower. Therefore, 16 bits are used as the minimum weight value precision of the weight unit. The specific value of the preset proportion can be set according to the requirement of the operation precision. According to the above scheme, the minimum weight value precision of each weight unit in the neural network model can be obtained, and the minimum weight value precision is stored in association with the corresponding weight unit.

[0053] After obtaining the minimum weight value precision, for each weight unit, the target weight value precision of the weight unit is determined according to the power reduction amount, the original weight value precision, and the minimum weight value precision.

[0054] For example, in an embodiment, the target weight value precision of the weight unit is determined according to the power reduction amount, and the original weight value precision and the minimum weight value precision of the weight unit, which includes: determining the weight value precision to be adjusted of the weight unit from the mapping relationship between the preset precision adjustment information and the preset power reduction amount according to the power reduction amount and the original weight value precision of the weight unit; for the weight unit, if the weight value precision to be adjusted is greater than or equal to the corresponding minimum weight value precision, the weight value precision to be adjusted is used as the target weight value precision, and if the weight value precision to be adjusted is less than the corresponding minimum weight value precision, the minimum weight value precision is used as the target weight value precision.

[0055] In this embodiment, the most suitable weight value precision is determined from Table 2 according to the power reduction and the original weight value precision, as the weight value precision to be adjusted. For example, the original data is a 64-bit floating point number, and the power reduction is 23% (the closest preset power reduction is 25%). It can be determined that the weight value precision to be adjusted is 32 bits, because it can be seen from Table 2 that the energy consumed by the conversion of a 64-bit floating point number to a 32-bit floating point number will be reduced by 25%. In this way, the weight value precision to be adjusted of each weight unit can be determined.

[0056] After the target weight value precision of the weight unit is determined, the target weight value precision is compared with the minimum weight value precision of the weight unit. If the weight value precision to be adjusted is greater than or equal to the corresponding minimum weight value precision, the weight value precision to be adjusted is taken as the target weight value precision. Otherwise, if the weight value precision to be adjusted is less than the corresponding minimum weight value precision, if the weight value precision to be adjusted is still taken as the target weight value precision, a large number of weight values will be set to zero or the maximum or minimum value of the target weight value precision, which will cause the accuracy of the calculation result to decrease too much. Therefore, in this embodiment, if the weight value precision to be adjusted is less than the corresponding minimum weight value precision, the minimum weight value precision is taken as the target weight value precision.

[0057] In other embodiments, if the weight value precision to be adjusted is less than the corresponding minimum weight value precision, whether the weight value precision to be adjusted is taken as the target weight value precision can also be determined according to the power reduction. When the power reduction is large, in order to reduce more energy consumption, the calculation accuracy is sacrificed, and the weight value precision to be adjusted is taken as the target weight value precision. Otherwise, when the power reduction is small, while reducing the energy consumption, the calculation accuracy is ensured.

[0058] 103. Reduce, by the neural network processor, the weight unit from the original weight value precision to the target weight value precision.

[0059] After the target weight value precision of the weight unit is obtained, the weight unit is reduced from the original weight value precision to the target weight value precision by the neural network processor. For example, 101 and 102 are executed in the NPU, and the NPU reduces the precision of the weight value in the weight unit to the target weight value precision after obtaining the target weight value precision of the weight unit. For another example, 101 and 102 are executed in the CPU, and the CPU sends the calculated target weight value precision to the NPU. The NPU reduces the precision of the weight value in the weight unit to the target weight value precision, and distributes the weight unit with the adjusted weight value precision to the operation circuit corresponding to the target weight value precision for operation.

[0060] It can be understood that the precision of the input feature value of the weight unit also needs to be adjusted to the target weight value precision, and the feature values and weight values with the same precision are subjected to convolution operation.

[0061] In some embodiments, the weight value precision of the weight value located within the representation range of the target weight value precision is converted to the target weight value precision, the weight value located outside the representation range of the target weight value precision and less than the minimum value of the representation range is converted to the minimum value or zero, and the weight value located outside the representation range of the target weight value precision and greater than the maximum value of the representation range is converted to the maximum value or zero.

[0062] The exponent part of some weight values in the weight unit may exceed the representation range of the exponent part of the target weight value precision, and the weight value can be forcibly set to the maximum value or the minimum value or zero of the exponent part of the target weight value precision according to the relationship between the weight value and the representation range. For example, the weight value located outside the representation range of the target weight value precision and less than the minimum value of the representation range is converted to the minimum value or zero, and the weight value located outside the representation range of the target weight value precision and greater than the maximum value of the representation range is converted to the maximum value or zero.

[0063] Please refer to Figure 2 , Figure 2 The floating point precision adjustment mode in the energy consumption management method of the neural network processor provided in the present application is shown in the schematic diagram. For the weight value precision conversion of the weight value located within the representation range of the target weight value precision to the target weight value precision, taking the conversion from 32-bit floating point to 16-bit floating point as an example, the specific conversion process is that the sign bit remains unchanged, the exponent bit retains the highest one and the lowest four bits, and the mantissa bit only retains the highest 10 bits. The conversion from 64-bit floating point to 32-bit floating point can be performed according to the same original.

[0064] Please refer to Figure 3 , Figure 3 The fixed point precision adjustment mode in the energy consumption management method of the neural network processor provided in the present application is shown in the schematic diagram. Taking the conversion from 16-bit fixed point to 8-bit fixed point as an example, the lowest 8 bits can be directly discarded.

[0065] In some embodiments, when the temperature of the electronic device is reduced or charging is performed without power limitation, a new power management event can be triggered, and the power management event does not trigger low power limitation, at this time the electronic device can send a prompt information to the neural network processor, and the neural network processor restores the weight value precision of the to-be-operated network to the original weight value precision according to the prompt information.

[0066] In practice, the execution sequence of the various steps described is not limited, and some steps can be performed in other sequences or at the same time, without conflict.

[0067] As can be seen from the above, the energy consumption control method of the neural network processor provided in the embodiments of the present application determines the to-be-operated network of the neural network model and the original weight value precision of the weight unit of the to-be-operated network, determines the target weight value precision of the weight unit according to the power reduction amount and the original weight value precision of the weight unit, then generates precision adjustment information according to the target weight value precision of the weight unit, and sends the precision adjustment information to the neural network processor, so that the neural network processor can reduce the weight value precision of each weight unit of the to-be-operated network according to the precision adjustment information. Based on this scheme, when it is necessary to reduce the energy consumption of the neural network processor, the target weight value precision that can meet the low power requirement can be determined according to the power reduction amount, and the neural network processor can perform calculation at the target weight value precision that is lower than the original weight value precision, so that the energy consumption can be reduced.

[0068] In an embodiment, an energy consumption control device of a neural network processor is also provided. Please refer to Figure 4 , Figure 4 The structural schematic diagram of the energy consumption control device 400 of the neural network processor provided in the embodiments of the present application is shown in FIG. 4. The energy consumption control device 400 of the neural network processor is applied to an electronic device, and the energy consumption control device 400 of the neural network processor includes a data acquisition module 401, a precision determination module 402, and a precision adjustment module 403, which are as follows:

[0069] The data acquisition module 401 is configured to determine a to-be-operated network of a neural network model and an original weight value precision of a weight unit of the to-be-operated network.

[0070] The precision determination module 402 is configured to determine a target weight value precision of the weight unit according to a power reduction amount and the original weight value precision of the weight unit.

[0071] The precision adjustment module 403 is configured to reduce the weight unit from the original weight value precision to the target weight value precision by the neural network processor.

[0072] In some embodiments, the energy consumption control device 400 of the neural network processor further includes:

[0073] The network operation module is configured to allocate the weight unit with the adjusted weight value precision to an operation circuit corresponding to the target weight value precision for operation by the neural network processor.

[0074] In some embodiments, the precision determining module 402 is further configured to obtain a lowest weight value precision and an original weight value precision of the weight unit of the to-be-operated network; and determine a target weight value precision of the weight unit according to the power reduction amount and the original weight value precision and the lowest weight value precision of the weight unit.

[0075] In some embodiments, the precision determining module 402 is further configured to determine a to-be-adjusted weight value precision of the weight unit from a mapping relationship between preset precision adjustment information and preset power reduction amounts according to the power reduction amount and the original weight value precision of the weight unit; and for the weight unit, if the to-be-adjusted weight value precision is greater than or equal to the corresponding lowest weight value precision, take the to-be-adjusted weight value precision as the target weight value precision, and if the to-be-adjusted weight value precision is less than the corresponding lowest weight value precision, take the lowest weight value precision as the target weight value precision.

[0076] In some embodiments, the energy consumption management device 400 of the neural network processor further comprises:

[0077] a power supply monitoring module configured to determine whether to trigger a low-power limit according to the power management event when detecting a power management event; and determine a power reduction amount according to the power management event when it is necessary to trigger a low-power limit;

[0078] an information sending module configured to perform operation with the original weight value precision of the weight unit in the neural network model by the neural network processor when it is not necessary to trigger a low-power limit.

[0079] In some embodiments, the energy consumption management device 400 of the neural network processor further comprises:

[0080] a second precision determining module configured to obtain a weight value of the weight unit of the neural network model; and determine a lowest weight value precision of the weight unit according to the weight value of the weight unit.

[0081] In some embodiments, the second precision determining module is configured to take a weight value precision lower than the original weight value precision of the weight unit as a to-be-evaluated weight value precision; take the to-be-evaluated weight value precision as a candidate weight value precision when not less than a preset proportion of the weight values of the weight unit are located in a representation range of the to-be-evaluated weight value precision; and take the lowest candidate weight value precision as the lowest weight value precision of the weight unit.

[0082] It should be explained that the energy consumption management device of the neural network processor provided in the embodiments of the present application and the energy consumption management method of the neural network processor in the above embodiments belong to the same concept. Any method provided in the energy consumption management method of the neural network processor can be implemented by the energy consumption management device of the neural network processor, and the specific implementation process is detailed in the energy consumption management method of the neural network processor. Here, it will not be repeated.

[0083] As can be seen from the above, the energy consumption management device of the neural network processor provided in the embodiments of the present application determines the to-be-operated network of the neural network model and the original weight value precision of the weight unit of the to-be-operated network. The target weight value precision of the weight unit is determined according to the power reduction amount and the original weight value precision of the weight unit. Then, the weight unit is reduced from the original weight value precision to the target weight value precision by the neural network processor. Based on this scheme, when it is necessary to reduce the energy consumption of the neural network processor, the target weight value precision that can meet the low power requirement can be determined according to the power reduction amount. The neural network processor performs calculation at the target weight value precision lower than the original weight value precision, which can reduce energy consumption.

[0084] The embodiments of the present application also provide an electronic device. The electronic device can be a terminal, which can be a smart phone, a tablet computer, a notebook computer, a touch screen, a game console, a personal computer (PC, Personal Computer), a personal digital assistant (PDA), and the like. As shown in Figure 5 Figure 5 The electronic device provided in the embodiments of the present application is a structural schematic diagram. The electronic device 500 includes a processor 501 having one or more processing cores, a memory 502 having one or more computer readable storage media, and a computer program stored in the memory 502 and executable on the processor. The processor 501 is electrically connected to the memory 502. Those skilled in the art can understand that the structure of the electronic device shown in the figure does not constitute a limitation on the electronic device, and can include more or fewer components than shown in the figure, or combine certain components, or different component arrangements.

[0085] The processor 501 is the control center of the electronic device 500, and connects various parts of the entire electronic device 500 through various interfaces and lines. By running or loading the software program and / or module stored in the memory 502 and calling the data stored in the memory 502, the processor 501 performs various functions and processes data of the electronic device 500, thereby overall monitoring the electronic device 500.

[0086] ​In the embodiments of the present application, the processor 501 in the electronic device 500 loads the instructions corresponding to the processes of one or more application programs into the memory 502 and runs the application programs stored in the memory 502 by the processor 501 to realize various functions according to the following steps:

[0087] determining a to-be-operated network of the neural network model, and an original weight value precision of a weight unit of the to-be-operated network;

[0088] determining a target weight value precision of the weight unit according to the power reduction amount and the original weight value precision of the weight unit;

[0089] reducing the weight unit from the original weight value precision to the target weight value precision by the neural network processor.

[0090] The specific implementation of each operation can refer to the foregoing embodiments, which will not be described here again.

[0091] Optionally, as shown in Figure 5 The electronic device 500 further includes a touch display screen 503, a radio frequency circuit 504, an audio circuit 505, an input unit 506, and a power supply 507. The processor 501 is electrically connected with the touch display screen 503, the radio frequency circuit 504, the audio circuit 505, the input unit 506, and the power supply 507, respectively. Those skilled in the art can understand that the electronic device structure shown in Figure 5 The electronic device structure shown in the foregoing embodiments does not constitute a limitation on the electronic device, and can include more or fewer components than those shown, or combine certain components, or different arrangement of components.

[0092] The touch display screen 503 can be used to display a graphical user interface and receive operation instructions generated by user acting on the graphical user interface. The touch display screen 503 can include a display panel and a touch panel. The display panel can be used to display information input by the user or provided to the user and various graphical user interfaces of the electronic device, which can be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. The touch panel can be used to collect touch operations (such as user operations on or near the touch panel using a finger, a stylus or any suitable object or accessory) of the user thereon or therearound, and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel can include two parts of a touch detection device and a touch controller. The touch detection device detects the touch position of the user and detects signals generated by the touch operation, and transmits the signals to the touch controller; the touch controller receives the touch information from the touch detection device, and converts it into touch coordinates, and then sends it to the processor 501, and can also receive commands from the processor 501 and execute them. The touch panel can cover the display panel, and when the touch panel detects a touch operation thereon or therearound, it transmits to the processor 501 to determine the type of the touch event, and then the processor 501 provides corresponding visual output on the display panel according to the type of the touch event. In the embodiments of the present application, the touch panel and the display panel can be integrated into the touch display screen 503 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can realize the input and output functions as two independent components. That is, the touch display screen 503 can also realize the input function as part of the input unit 506.

[0093] The radio frequency circuit 504 can be used to transceive radio frequency signals to establish wireless communication with network devices or other electronic devices, and transceive signals between network devices or other electronic devices.

[0094] The audio circuit 505 can be used to provide an audio interface between the user and the electronic device through the speaker and the microphone. The audio circuit 505 can convert the received audio data into an electrical signal and transmit it to the speaker, which converts it into a sound signal output. On the other hand, the microphone collects sound signals and converts them into electrical signals, which are received by the audio circuit 505 and converted into audio data. After being processed by the processor 501, the audio data is transmitted to another electronic device through the radio frequency circuit 504, or output to the memory 502 for further processing. The audio circuit 505 can also include an earphone jack to provide communication between an external earphone and the electronic device.

[0095] The input unit 506 can be configured to receive inputted digital, character information or user feature information (e.g. fingerprint, iris, face information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0096] The power supply 507 is configured to supply power to various components of the electronic device 500. Optionally, the power supply 507 can be logically connected to the processor 501 through a power management system, so as to realize functions such as management of charging, discharging and energy consumption management through the power management system. The power supply 507 can also include one or more than one direct current or alternating current power supply, a recharging system, a power failure detection circuit, a power converter or inverter, a power state indicator, etc.

[0097] Although Figure 5 The electronic device 500 can further include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc. which are not shown in the embodiments, and details are not described herein.

[0098] In the above embodiments, the description of each embodiment is focused on different aspects, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0099] As can be seen from the above, the electronic device provided in the embodiments determines a to-be-operated network of a neural network model and an original weight value precision of a weight unit of the to-be-operated network, determines a target weight value precision of the weight unit according to a power reduction amount and the original weight value precision of the weight unit, and then reduces the weight unit from the original weight value precision to the target weight value precision through a neural network processor. Based on the scheme, when it is necessary to reduce the energy consumption of the neural network processor, the target weight value precision that can meet the low power requirement can be determined according to the power reduction amount, and the neural network processor performs calculation at the target weight value precision lower than the original weight value precision, so that the energy consumption can be reduced.

[0100] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by instructions controlling related hardware, which can be stored in a computer readable storage medium and loaded and executed by a processor.

[0101] The embodiments of the present application also provide an electronic device, comprising:

[0102] The first processor is configured to determine a to-be-operated network of a neural network model and an original weight value precision of a weight unit of the to-be-operated network.

[0103] determine a target weight value precision of the weight unit according to the power reduction amount and the original weight value precision of the weight unit, and send the target weight value precision to the second processor;

[0104] The second processor is configured to reduce the weight unit from the original weight value precision to the target weight value precision.

[0105] In some embodiments, the second processor is a neural network processor, and the first processor is another processor in the electronic device except the neural network processor.

[0106] To this end, an embodiment of the present application provides a computer readable storage medium, which stores a plurality of computer programs. The computer programs can be loaded by a processor to perform steps in any energy consumption management method of the neural network processor provided by the embodiments of the present application. For example, the computer programs can perform the following steps:

[0107] determine a to-be-operated network of the neural network model, and an original weight value precision of a weight unit of the to-be-operated network;

[0108] determine a target weight value precision of the weight unit according to the power reduction amount and the original weight value precision of the weight unit;

[0109] reduce the weight unit from the original weight value precision to the target weight value precision by the neural network processor.

[0110] The specific implementation of each operation can refer to the foregoing embodiments, which will not be described here.

[0111] The storage medium can include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0112] Since the computer programs stored in the storage medium can perform steps in any energy consumption management method of the neural network processor provided by the embodiments of the present application, the beneficial effects of any energy consumption management method of the neural network processor provided by the embodiments of the present application can be achieved. Details are described in the foregoing embodiments, which will not be described here.

[0113] The energy consumption management and control method, device, medium and electronic equipment of the neural network processor provided by the embodiments of the present application are described in detail above, and the principles and implementation modes of the present application are described in this paper. The above embodiment is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will be changed, and the above description should not be understood as a limitation of the present application.

Claims

1. A method for energy consumption control of a neural network processor, characterized in that, include: Determine the network to be computed in the neural network model, and the precision of the original weight values ​​of the weight units of the network to be computed; The target weight value accuracy of the weight unit is determined based on the power reduction and the original weight value accuracy of the weight unit, including: obtaining the minimum weight value accuracy and the original weight value accuracy of the weight unit; obtaining the weight values ​​of the weight units of the neural network model; taking weight value accuracy lower than the original weight value accuracy of the weight unit as the weight value accuracy to be evaluated; when a weight value of the weight unit is not less than a preset proportion and is within the representation range of the weight value accuracy to be evaluated, taking the weight value accuracy to be evaluated as a candidate weight value accuracy; taking the lowest candidate weight value accuracy as the minimum weight value accuracy of the weight unit; and determining the target weight value accuracy of the weight unit based on the power reduction and the original weight value accuracy and the minimum weight value accuracy of the weight unit. The neural network processor reduces the precision of the weight unit from the original weight value to the target weight value precision.

2. The energy consumption control method for a neural network processor as described in claim 1, characterized in that, After reducing the precision of the weight unit from the original weight value to the target weight value precision, the method further includes: The neural network processor assigns weight units with adjusted weight values ​​to the computation circuits corresponding to the target weight value precision for computation.

3. The energy consumption control method for a neural network processor as described in claim 1, characterized in that, Based on the power reduction, and the original weight value accuracy and the minimum weight value accuracy of the weight unit, the target weight value accuracy of the weight unit is determined, including: Based on the power reduction amount and the original weight value accuracy of the weight unit, the precision of the weight value to be adjusted of the weight unit is determined from the mapping relationship between the preset precision adjustment information and the preset power reduction amount. If the precision of the weight value to be adjusted is greater than or equal to the precision of the minimum weight value, then the precision of the weight value to be adjusted is taken as the target weight value precision; if the precision of the weight value to be adjusted is less than the precision of the minimum weight value, then the precision of the minimum weight value is taken as the target weight value precision.

4. The energy consumption control method for a neural network processor as described in claim 1, characterized in that, Before determining the network to be computed in the neural network model, the following steps are also included: When a power management event is detected, it is determined whether to trigger low power limiting based on the power management event. When a low power limit needs to be triggered, the power reduction amount is determined based on the power management event, and the network to be computed for determining the neural network model is executed. When there is no need to trigger the low power limit, the neural network processor performs calculations with the precision of the original weight values ​​of the weight units in the neural network model.

5. The energy consumption control method for a neural network processor as described in any one of claims 1 to 4, characterized in that, By using the neural network processor, reducing the precision of the weight unit from the original weight value to the target weight value precision includes: The neural network processor converts the weight values ​​within the representation range of the target weight value precision into the target weight value precision, converts weight values ​​outside the representation range of the target weight value precision and less than the minimum value of the representation range into the minimum value or zero, and converts weight values ​​outside the representation range of the target weight value precision and greater than the maximum value of the representation range into the maximum value or zero.

6. An energy consumption control device for a neural network processor, characterized in that, include: The data acquisition module is used to determine the network to be computed in the neural network model, and the precision of the original weight values ​​of the weight units of the network to be computed. An accuracy determination module is used to determine the target weight value accuracy of the weight unit based on the power reduction amount and the original weight value accuracy of the weight unit. This includes: obtaining the minimum weight value accuracy and the original weight value accuracy of the weight unit; obtaining the weight values ​​of the weight units in the neural network model; using weight value accuracy lower than the original weight value accuracy of the weight unit as the weight value accuracy to be evaluated; when a weight value of the weight unit has a weight value not less than a preset proportion within the representation range of the weight value accuracy to be evaluated, using the weight value accuracy to be evaluated as a candidate weight value accuracy; using the lowest candidate weight value accuracy as the minimum weight value accuracy of the weight unit; and determining the target weight value accuracy of the weight unit based on the power reduction amount, the original weight value accuracy, and the minimum weight value accuracy of the weight unit. The precision adjustment module is used to reduce the precision of the weight unit from the original weight value to the target weight value precision through the neural network processor.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is run on a computer, it causes the computer to perform the power consumption management method for a neural network processor as described in any one of claims 1 to 5.

8. An electronic device comprising a processor and a memory, the memory storing a computer program, characterized in that, The processor invokes the computer program to execute the energy consumption management method for the neural network processor as described in any one of claims 1 to 5.

9. An electronic device, characterized in that, include: A first processor is used to determine the network to be computed in the neural network model, and the precision of the original weight values ​​of the weight units of the network to be computed. Furthermore, based on the power reduction amount and the original weight value accuracy of the weight unit, the target weight value accuracy of the weight unit is determined, including: obtaining the minimum weight value accuracy and the original weight value accuracy of the weight unit; obtaining the weight value of the weight unit of the neural network model; taking the weight value accuracy lower than the original weight value accuracy of the weight unit as the weight value accuracy to be evaluated; when the weight values ​​of the weight unit are not less than a preset proportion within the representation range of the weight value accuracy to be evaluated, taking the weight value accuracy to be evaluated as the candidate weight value accuracy; taking the lowest candidate weight value accuracy as the minimum weight value accuracy of the weight unit; determining the target weight value accuracy of the weight unit based on the power reduction amount, the original weight value accuracy and the minimum weight value accuracy of the weight unit, and sending the target weight value accuracy to the second processor; The second processor is used to reduce the precision of the weight unit from the original weight value to the target weight value precision.

Citation Information

Patent Citations

  • Weight precision configuration method, weight precision configuration device, weight precision configuration equipment and storage medium

    CN111831358A