An activation class function expression generator and method for convolutional neural networks

Through the activation function expression generator for convolutional neural networks, the function configuration module, segmented function information generation module and function operation construction module are used to work together, and the problem of activation functions not being supported by hardware in the existing technology is solved, and the hardware-level acceleration and operation efficiency of the activation layer are improved.

CN119129677BActive Publication Date: 2025-04-15CLP KESHENTAI INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411604312.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-12
Publication Date
2025-04-15
Estimated Expiration
2044-11-12

AI Technical Summary

Technical Problem

The existing convolutional neural network acceleration chips have limited support for activation functions, which leads to the lack of hardware support in the activation functions in the new network model, which greatly reduces the operating efficiency.

Method used

It provides an activation function expression generator for convolutional neural networks, including function configuration module, segmented function information generation module and function operation construction module. Through the coordinated work of these modules, it realizes flexible configuration of activation layer activation functions and hardware-level acceleration.

Benefits of technology

It realizes hardware-level acceleration of the activation layer in various convolutional neural network network models, improves operation efficiency, and supports flexible configuration of multiple activation functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119129677B_ABST
    Figure CN119129677B_ABST
Patent Text Reader

Abstract

The present invention discloses an activation class function expression generator and method for convolutional neural networks, comprising: a function configuration module, which is used to generate piecewise function segments and piecewise value information, and send function construction configuration information and operand information to a function operation construction module; a piecewise function information generation module generates function segment information for a function input value according to information of the function configuration module, and outputs the information to the function operation construction module after combining it with the function input value; the function operation construction module can realize N modules in series to realize all operation steps required in the function expression, and at the same time, each function operation construction module has an enabling switch, and if the enabling switch is turned off, the module is shielded. The present invention can realize flexible configuration of activation functions of activation layers for convolutional neural networks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of digital integrated circuits, and in particular relates to an activation class function expression generator and method for convolutional neural networks. Background Art

[0002] Convolutional Neural Networks (CNN) have been widely used in the field of artificial intelligence in visual processing scenarios such as image detection and classification. Currently, there are many types of CNN-based network models, including Yolo, ResNet, MobileNet, and VGGNet.

[0003] The activation layer is a necessary part of the convolutional neural network model and is also one of the important means to distinguish the recognition rate of network models. The common activation layer functions in each network model are different. For example, Yolo uses ReLU and Sigmoid as common activation layer functions, ResNet uses PRelu and Celu as common activation layer functions, MobileNet uses HardSwish and HardSigmoid as common activation layer functions, and VGGNet uses Elu, LeakyRelu and PRelu as common activation layer functions. Therefore, different network models for convolutional neural networks use different activation functions on the activation layer, and the convolutional neural network acceleration chips on the market support limited types of activation functions. When new network models appear, their activation functions often cannot be supported at the hardware level. Manufacturers can only run the calculation tasks of the activation layer in the CPU, which greatly reduces the operating efficiency. Summary of the invention

[0004] The purpose of the present invention is to overcome the above-mentioned shortcomings of the prior art. The present invention provides an activation class function expression generator and method for convolutional neural networks, which can realize flexible configuration of activation functions of activation layers for convolutional neural networks, so as to realize hardware-level acceleration of activation layers in network models of various types of convolutional neural networks.

[0005] In order to solve the above technical problems, the present invention provides an activation class function expression generator for convolutional neural networks, comprising:

[0006] The function configuration module is used to obtain and store the segmentation function and segmentation value information sent by the host computer software, as well as the function construction configuration and operand information of each segment in the segmentation function; and the segmentation function and segmentation value information are sent to the input value function segment judgement in the segmentation function information generation module, and the function construction configuration and operand information of each segment in the segmentation function are sent to the function operation construction module;

[0007] The piecewise function information generation module determines the input value of the function according to the piecewise function segment and segment value information of the function configuration module, generates the function segment information, and combines the data with the input value of the function and outputs it to the function operation construction module;

[0008] A function operation construction module is connected in series with N function operation construction modules to realize all operation steps required in the function expression; each function operation construction module has an enable switch. If the enable switch is turned off, the function operation construction module is shielded, and data is directly forwarded from the input end of the function operation construction module to the output end;

[0009] Wherein, the function operation construction module includes:

[0010] The primary processing unit is used to receive the segment information and function input value sent by the segment information generator in the piecewise function information generation module, and query the function configuration module for the matching function construction configuration and operand information according to the segment information; wherein the function construction configuration information determines whether the primary processing unit uses a clipper, a comparator, or whether the primary processing unit is not enabled and directly skipped;

[0011] The secondary processing unit is used to receive the rank information and processing results sent by the primary processing unit, and query the function configuration module for matching function construction configuration and operand information according to the rank information; wherein the function construction configuration information determines whether the secondary processing unit uses a multiplier or a divider, or whether the secondary processing unit is not enabled and is directly skipped;

[0012] The third-level processing unit is used to receive the rank information and processing results sent by the second-level processing unit, and query the function configuration module for matching function construction configuration and operand information according to the rank information; wherein the function construction configuration information determines whether the third-level processing unit uses an adder or a subtractor, or whether the third-level processing unit is not enabled and is directly skipped;

[0013] The fourth-level processing unit is used to receive the rank information and processing results sent by the third-level processing unit, and query the function configuration module for matching function construction configuration and operand information according to the rank information; wherein the function construction configuration information determines whether the fourth-level processing unit uses an inverse device, an absolute value device, or whether the fourth-level processing unit is not enabled and is directly skipped;

[0014] The LUT lookup table operator is used to receive the rank information and processing results sent by the four-level processing unit, and query the function construction configuration and operand information matching the rank information in the function configuration module; wherein the function construction configuration information determines whether the LUT lookup table operator is skipped and the table value of the LUT lookup table. The LUT lookup table operator is used to perform calculations of complex functions such as power functions, square roots or trigonometric functions.

[0015] Preferably, the piecewise function information generating module includes:

[0016] The input value function rank judger performs the segmented interval rank judgement of the piecewise function on the input value of the function. The input value function rank judger obtains the number of piecewise function ranks N and the interval segmentation value of the piecewise function from the piecewise function rank and segmentation value information of the function configuration module, and judges the rank interval where the function input value is located. If it is in the first segment interval of the function, the segment interval information 1 is generated and transmitted to the segment information generator; and so on, the maximum segment interval information is N;

[0017] The rank information generator appends the function interval rank information sent by the input value function rank judger to the front of the function input value, and forms new data and sends it to the function operation construction module connected to it through the output end of the piecewise function information generation module.

[0018] Preferably, the primary processing unit comprises:

[0019] The mode selector obtains the segment information of the function input value from the piecewise function information generation module, selects and obtains the function construction configuration and operand information matching the segment of the input value through the function configuration module, and then enables or disables the clipper and comparator. If both are disabled, the first-level processing unit is directly skipped;

[0020] The clipper, when enabled, obtains the clipper-specific operands A and B from the mode selector, and directly forwards the rank information and the input value to the secondary processing unit if the input value is between operand A and operand B, and outputs the rank information and operand A to the secondary processing unit if the input value is greater than operand A, and outputs the rank information and operand B to the secondary processing unit if the input value is greater than operand B;

[0021] The comparator, when enabled, obtains the comparator-specific operand from the mode selector. If the comparator is in the maximum mode, the operand and the input value take the maximum value of the two and output it to the secondary processing unit. If the comparator is in the minimum mode, the operand and the input value take the minimum value of the two and output it to the secondary processing unit.

[0022] Preferably, the clipper in the primary processing unit is used to implement the expression of the activation class function Clip:

[0023] ;

[0024] Among them, Y is the result output to the secondary processing unit after the clipper is processed, min is the clipper-specific operand A, max is the clipper-specific operand B, MAX is the maximum value function, and MIN is the minimum value function.

[0025] Preferably, the comparator in the primary processing unit is used to implement the expression of arithmetic logic function MAX or MIN, MAX is a comparator-specific operand that is compared with the function input value to obtain the maximum value and output it to the secondary processing unit, MIN is a comparator-specific operand that is compared with the function input value to obtain the minimum value and output it to the secondary processing unit, and the MAX and MIN function modes are selected in the comparator. When the function expression does not require the Clip, MAX or MIN function expression, the primary processing unit can forward the input value directly to the secondary processing unit, and the clipper and comparator in the primary processing unit are selected in two ways. When selected, the segment information will be attached to the header of the numerical result and sent to the secondary processing unit.

[0026] Preferably, the secondary processing unit comprises:

[0027] The mode selector, after obtaining the level information from the primary processing unit, selects and obtains the function construction configuration and operand information matching the input value level through the function configuration module, and then enables or disables the multiplier and divider. If both are disabled, the secondary processing unit is directly skipped;

[0028] The multiplier, when enabled, obtains a multiplier-specific operand from the mode selector, multiplies the operand by the first-level calculation value, and outputs the obtained multiplication result together with the segment information to the third-level processing unit;

[0029] The divider, when enabled, obtains a divider-specific operand from the mode selector, divides the operand by the input value, and outputs the division result together with the segment information to the three-level processing unit.

[0030] Preferably, the three-stage processing unit comprises:

[0031] The mode selector, after obtaining the level information from the secondary processing unit, selects and obtains the function construction configuration and operand information matching the input value level through the function configuration module, and then enables or disables the adder and subtractor. If both are disabled, the tertiary processing unit is directly skipped;

[0032] The adder, when enabled, obtains an adder-specific operand from the mode selector, adds the operand to the secondary calculation value, and outputs the addition result together with the segment information to the fourth-level processing unit;

[0033] The subtractor, when enabled, obtains a subtractor-specific operand from the mode selector, subtracts the operand from the input value, and outputs the subtraction result together with the segment information to the four-stage processing unit.

[0034] Preferably, the four-stage processing unit comprises:

[0035] The mode selector, after obtaining the level information of the function input value from the third-level processing unit, selects and obtains the function construction configuration and operand information matching the level of the input value through the function configuration module, and then enables or disables the reciprocator and the absolute valuer. If both are disabled, the fourth-level processing unit is directly skipped;

[0036] The reciprocal device, when enabled, performs reciprocal processing on the calculation result sent by the three-level processing unit and outputs it to the LUT lookup table operator together with the segment information;

[0037] The absolute value device, when enabled, performs absolute value processing on the calculation result sent by the three-level processing unit and outputs it to the LUT lookup table operator together with the segment information.

[0038] The present invention also provides a method for generating activation class function expressions for convolutional neural networks, which is used to achieve hardware-level acceleration of activation layers in network models of various convolutional neural networks. The activation class function expression generator for convolutional neural networks as described above is used, and the method comprises the following steps:

[0039] Step 1: According to the number of segments of the activated class function expression, the piecewise function segment information of the function expression and the segment value information of the function segment critical point are sent to the function configuration module through the host computer software, and then the function construction configuration and operand information are configured according to the function expression calculation steps of each segment;

[0040] Step 2: The piecewise function information generation module determines the input value of the function through the piecewise function segment and segment value information of the function configuration module, generates the function segment information, and combines the data with the input value of the function and outputs it to the function operation construction module;

[0041] Step three: The function operation construction module obtains the input value of the function and the function segment information corresponding to the input value by parsing the combined data sent by the piecewise function information generation module. The internal first-level processing unit, second-level processing unit, third-level processing unit, fourth-level processing unit and LUT lookup table operator query and obtain the function construction configuration and operand information matching the segment in the function configuration module according to the function segment information. The function operation construction module can realize the series connection of N function operation construction modules to realize all the operation steps required in the function expression.

[0042] The present invention also provides a computer device for storing and executing the host computer software in the activation class function expression generator for convolutional neural networks as described above, wherein the host computer software is used to send the construction information of the activation function to the function configuration module.

[0043] Compared with the prior art, the present invention has the following beneficial effects:

[0044] The present invention discloses an activation class function expression generator and generation method for convolutional neural network, comprising: a function configuration module, used for generating piecewise function segment and piecewise value information, and sending function construction configuration information and operand information to a function operation construction module; a piecewise function information generation module generates function segment information for the input value of the function according to the information of the function configuration module, and outputs it to the function operation construction module after combining with the input value of the function; the function operation construction module can realize N modules in series, realize all the operation steps required in the function expression, and at the same time, each function operation construction module has an enable switch, if the enable is closed, the module is shielded. The present invention can realize the flexible configuration of the activation function of the activation layer for convolutional neural network, and can realize the segmentation of 1 to 3 segments of function by supporting three-segment functions and cascading multiple function operation construction modules. At the same time, the expressions of each segment function can flexibly construct various function expressions under the cascade of the function operation construction module, so as to realize the hardware-level acceleration of the activation layer in the network model of various convolutional neural networks. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 Schematic diagram of the activation class function expression generator architecture for convolutional neural networks in the present invention.

[0046] Figure 2 This is a schematic diagram of the function operation construction module in the present invention.

[0047] Figure 3 Schematic diagram of the method for generating activation class function expressions for convolutional neural networks in the present invention. DETAILED DESCRIPTION

[0048] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The advantages and features of the present invention will become more apparent from the following description. It should be noted that the accompanying drawings are in very simplified form and in non-precise proportions, and are only used to conveniently and clearly assist in explaining the purpose of the embodiments of the present invention. Example 1

[0049] like Figure 1 As shown, the embodiment of the present invention provides an architecture of an activation class function expression generator for a convolutional neural network, including: a function configuration module, a piecewise function information generation module and a function operation construction module. The function configuration module has an input terminal and two output terminals A and B, the input terminal is connected to the upper computer software, the output terminal A is connected to the input terminal B of the piecewise function information generation module, and the output terminal B is connected to the input terminal B of the function operation construction module;

[0050] The function configuration module obtains and stores the segmentation function segment and segmentation value information sent by the host computer software and the function construction configuration information and operand information of each segment in the segmentation function from the input end, and sends the segmentation function segment and segmentation value information to the input value function segment judger in the segmentation function information generation module through the output end A, and the function construction configuration and operand information of each segment in the segmentation function is sent to the function operation construction module through the output end B;

[0051] The piecewise function information generation module has two input terminals A and B and an output terminal, the input terminal A is used to receive the input value data of the function, the input terminal B is connected to the output terminal A of the function configuration module, and the output terminal is connected to the input terminal A of the function operation construction module; the piecewise function information generation module determines the input value of the function according to the piecewise function segment and piecewise value information of the function configuration module, generates the function segment information, and combines the data with the input value of the function and outputs it to the function operation construction module;

[0052] The function operation construction module has two input terminals A and B and an output terminal, the input terminal A is connected to the output terminal of the piecewise function information generation module or connected to the output terminal of the previous level function operation construction module, the input terminal B is connected to the output terminal B of the function configuration module, and the output terminal is connected to the next level function operation construction module or directly outputs the operation result; the function operation construction module can realize N modules in series according to the actual needs of the activation layer function to realize all the operation steps required in the function expression, and at the same time, each function operation construction module has an enable switch, if the enable is turned off, the module is shielded, and the data is directly forwarded from the input terminal A to the output terminal;

[0053] like Figure 2 As shown, it is a schematic diagram of a function operation construction module provided in an embodiment of the present invention, and the function operation construction module includes a level 1 processing unit, a level 2 processing unit, a level 3 processing unit, a level 4 processing unit and a LUT lookup table operator:

[0054] The level 1 processing unit is used to receive the segment information and function input value sent by the segment information generator in the piecewise function information generation module, and query the function construction configuration and operand information matching the segment information in the function configuration module, wherein the function construction configuration information determines whether the level 1 processing unit uses a clipper or a comparator or whether this unit is not enabled and is directly skipped.

[0055] The level 2 processing unit is used to receive the rank information and processing results sent by the level 1 processing unit, and query the function construction configuration and operand information matching the rank information in the function configuration module, wherein the function construction configuration information determines whether the level 2 processing unit uses a multiplier or a divider or whether this unit is not enabled and is directly skipped.

[0056] The level 3 processing unit is used to receive the rank information and processing results sent by the level 2 processing unit, and query the function construction configuration and operand information matching it in the function configuration module according to the rank information, wherein the function construction configuration information determines whether the level 3 processing unit uses an adder or a subtractor or whether this unit is not enabled and is directly skipped.

[0057] The 4th-level processing unit is used to receive the rank information and processing results sent by the 3rd-level processing unit, and query the function construction configuration and operand information matching it in the function configuration module according to the rank information, wherein the function construction configuration information determines whether the 4th-level processing unit uses an inverse or an absolute valuer or whether this unit is not enabled and is directly skipped.

[0058] The LUT lookup table operator is used to receive the rank information and processing results sent by the 4-level processing unit, and query the function construction configuration and operand information matching the rank information in the function configuration module. The function construction configuration information determines whether the LUT lookup table operator is skipped and the table value of the LUT lookup table. The LUT lookup table operator performs calculations of complex functions such as power functions or square roots.

[0059] like Figure 2 As shown, taking the two-segment function of HardSwish function as an example, the three function operation construction modules switch the corresponding function construction configuration information and operand information according to the segment information (the value is 2) generated by the piecewise function information generation module.

[0060] In the first function operation construction module: after receiving the function input value and segment information (value is 2) of input terminal A, the mode selector of the level 1 processing unit will load the level 1 processing unit function construction configuration and operand information of the first function operation construction module of the second segment function expression of the HardSwish function in the function configuration module (the level 1 operation unit is not enabled and has no operands). At this time, the level 1 processing unit directly forwards the received value to the level 2 processing unit; the mode selector of the level 2 processing unit receives the result and segment information (value is 2) of the level 1 processing unit. After that, the function construction configuration and operand information of the first function operation construction module of the second segment function expression of the HardSwish function in the function configuration module will be loaded (the second-level operation unit is not enabled and has no operands). At this time, the second-level processing unit will directly forward the received value to the third-level processing unit; after receiving the result and segment information (the value is 2) of the second-level processing unit, the mode selector of the third-level processing unit will load the third-level processing unit of the first function operation construction module of the second segment function expression of the HardSwish function in the function configuration module. The processing unit function construction configuration and operand information (adder enabled, subtractor disabled, adder dedicated operand is 3), at this time, the 3rd level processing unit will add 3 to the received value in the adder, and then attach the segment information to the header and send it to the 4th level processing unit; after receiving the result and segment information (value 2) of the 3rd level processing unit, the mode selector of the 4th level processing unit will load the 4th level processing unit function construction configuration and operand information of the first function operation construction module of the second segment function expression of the HardSwish function in the function configuration module (4th level operation unit Not enabled, no operand), at this time, the 4-level processing unit will forward the received value directly to the LUT lookup table operator; after receiving the result and segment information (the value is 2) of the 4-level processing unit, the LUT lookup table operator will load the LUT lookup table operator function construction configuration and operand information of the first function operation construction module of the second segment function expression of the HardSwish function in the function configuration module (the LUT lookup table operator is not enabled), and at this time, the LUT lookup table operator will output the received value directly to the second function operation construction module through the output end.

[0061] By analogy, each unit of the second function operation construction module will load the function construction configuration information and operand information of the second function operation construction module of the second function expression of the HardSwish function in the function configuration module; each unit of the third function operation construction module will load the function construction configuration information and operand information of the third function operation construction module of the second function expression of the HardSwish function in the function configuration module. Example 2

[0062] The embodiment of the present invention also provides an activation class function expression generation method for a convolutional neural network, which is used to achieve hardware-level acceleration of the activation layer in the network model of various convolutional neural networks. The activation class function expression generation method includes:

[0063] According to the number of segments of the activated class function expression, the piecewise function segment information of the function expression and the segment value information of the function segment critical point are sent to the function configuration module through the upper computer software, and then the function construction configuration information and operand information are configured according to the function expression calculation steps of each segment.

[0064] The piecewise function information generation module determines the input value of the function through the piecewise function segment and segment value information of the function configuration module, generates the function segment information, and outputs it to the function operation construction module after combining the data with the input value of the function.

[0065] The function operation construction module obtains the input value of the function and the function segment information corresponding to the input value by parsing the combined data sent by the piecewise function information generation module. The internal level 1, level 2, level 3, and level 4 processing units and the LUT lookup table operator query and obtain the function construction configuration information and operand information that match the segment in the function configuration module according to the function segment information. The function operation construction module can realize the series connection of N modules to realize all the operation steps required in the function expression.

[0066] The input value function rank judge of the piecewise function information generation module performs piecewise function interval rank judgment on the function input value, obtains the piecewise function rank number N and the piecewise value information from the function configuration module, and judges the rank interval where the function input value is located. If it is in the first rank interval of the function, it generates rank interval information 1 and transmits it to the rank information generator, and so on. The maximum rank interval is N.

[0067] The rank information generator of the piecewise function information generation module appends the function interval rank information sent by the input value function rank judger to the front of the function input value, and forms new data and sends it to the next-level function operation construction module through the piecewise function information generation module.

[0068] like Figure 3 As shown, taking the HardSwish function, which is a typical function expression in the activation function, as an example, the method for generating activation class function expressions for convolutional neural networks in the present invention is specifically described.

[0069] The function expressions of each segment of HardSwish function are as follows:

[0070]

[0071] The HardSwish function is a three-segment function. When the input value of the function is greater than 3, it is segment 1; when the input value is less than or equal to 3 or greater than or equal to -3, it is segment 2; and when the input value is less than -3, it is segment 3. Based on the above information of the HardSwish function, the upper computer software sets the segment function segment information of the function configuration module to 3, and the segment value information to 3 and -3.

[0072] According to the function expression of the HardSwish function, the host computer software sets three sets of function construction configuration information and operand information, corresponding to the 1st, 2nd and 3rd segment function expressions of the HardSwish function respectively:

[0073] The function expression of 1 segment is , according to the formula of 1-segment function, the 1-segment function construction configuration and operand information are:

[0074] (1) The first-level operation unit of the first function operation construction module is disabled, the second-level operation unit selects the multiplier, and allocates the multiplier-specific operand information to the multiplier, the operand value is 1, the third-level and fourth-level operation units are disabled, and the LUT lookup table operator is disabled;

[0075] (2) All internal units of the second function operation module are disabled;

[0076] (3) All internal units of the third function operation module are disabled.

[0077] The 2-segment function expression is , according to the formula of the two-segment function, the two-segment function construction configuration information is:

[0078] (1) The first-level operation unit of the first function operation construction module is disabled, the second-level operation unit is disabled, the third-level operation unit selects the adder, and the adder is assigned operand information dedicated to the adder, the operand value is 3, the fourth-level operation unit is disabled, and the LUT lookup table operator is disabled;

[0079] (2) The first-level operation unit of the second function operation construction module is disabled, the second-level operation unit selects the divider, and allocates the divider-specific operand information, the operand value is 6, the third-level operation unit is disabled, the fourth-level operation unit is disabled, and the LUT lookup table operator is disabled;

[0080] (3) The first-level operation unit of the third function operation construction module is not enabled, the second-level operation unit selects the multiplier, and allocates the multiplier-specific operand information to the divider. The operand value is the function input value itself. The third-level operation unit is not enabled, the fourth-level operation unit is not enabled, and the LUT lookup table operator is not enabled.

[0081] The 3-segment function expression is , according to the formula of the three-segment function, the three-segment function construction configuration information is:

[0082] (1) The first-level operation unit of the first function operation construction module is disabled, the second-level operation unit selects the multiplier, and allocates the multiplier-specific operand information to the multiplier, the operand value is 0, the third-level and fourth-level operation units are disabled, and the LUT lookup table operator is disabled;

[0083] (2) All internal units of the second function operation module are disabled;

[0084] (3) All internal units of the third function operation module are disabled.

[0085] like Figure 3 As shown, the input value function rank judger of the piecewise function information generation module judges the function input value according to the piecewise function rank and piecewise value information (piecewise function rank information: 3, piecewise value information: 3 and -3) of the function configuration module:

[0086] (1) If the input value is in segment 1 of the HardSwish function, the segment information generator adds segment information 1 to the header of the function input value and outputs it to the function operation construction module through the output terminal;

[0087] (2) If the input value is in segment 2 of the HardSwish function, the segment information generator adds segment information 2 to the header of the function input value and outputs it to the function operation construction module through the output terminal;

[0088] (3) If the input value is in segment 3 of the HardSwish function, the segment information generator will add segment information 3 to the header of the function input value and output it to the function operation construction module through the output terminal.

[0089] like Figure 3 As shown in the figure, based on the activation function HardSwish, a method for generating activation class function expressions for convolutional neural networks is described by taking the operation flow with an input value of 2 as an example:

[0090] When the function input value is 2:

[0091] The input value function rank judger of the piecewise function information generation module judges that 2 is less than or equal to 3, and 2 is greater than or equal to -3, thereby generating a rank judgment result (value 2) and sending it to the rank information generator. The rank information generator adds the rank information (value 2) to the front of the function input value 2, combines them together and sends them to the first function operation construction module;

[0092] The mode selector of the first function operation construction module obtains the function construction configuration and operand information of the function configuration module from the input terminal B according to the segment information (value 2) received by the input terminal A, and loads the configuration information of the first-level processing unit (disabled, no operand), the second-level processing unit (disabled, no operand), the third-level processing unit (select adder enabled, adder dedicated operand 3), the fourth-level processing unit (disabled, no operand) and the LUT lookup table operator (disabled) for the first function operation construction module. It can be obtained that after the input value of the function passes through the first function operation construction module, the calculated output value output from the output terminal is 5, and the segment information is 2;

[0093] The mode selector of the second function operation construction module obtains the function construction configuration and operand information of the function configuration module from the input terminal B according to the segment information (value 2) received by the input terminal A, and loads the configuration information of the first-level processing unit (disabled, no operand), the second-level processing unit (divider enabled, divider dedicated operand 6), the third-level processing unit (disabled, no operand), the fourth-level processing unit (disabled, no operand) and the LUT lookup table operator (disabled) for the second function operation construction module. It can be obtained that after the input value of the function passes through the first function operation construction module, the calculated output value output from the output terminal is 0.8333, and the segment information is 2;

[0094] The mode selector of the third function operation construction module obtains the function construction configuration and operand information of the function configuration module from the input terminal B according to the segment information (value 2) received at the input terminal A, and loads the 1st level processing unit (disabled, no operand), 2nd level processing unit (multiplier enabled, the multiplier dedicated operand is the function input value 2), 3rd level processing unit (disabled, no operand), 4th level processing unit (disabled, no operand) and LUT lookup table operator configuration information (disabled) for the third function operation construction module. It can be obtained that after the input value of the function passes through the first function operation construction module, the calculation result of the HardSwish function when the input value is 2 is output from the output terminal, which is 1.6666, and the segmentation information is 2. Example 3

[0095] The embodiment of the present invention further provides a computer device for storing and executing host computer software, wherein the host computer software is used to send construction information of an activation function to a function configuration module.

[0096] The above description is only a description of the preferred embodiments of the present invention, and is not intended to limit the scope of the present invention. Any changes or modifications made by a person skilled in the art in the field of the present invention based on the above disclosure shall fall within the scope of protection of the claims.

Claims

1. An activation class function expression generator for convolutional neural networks, characterized in that: include: The function configuration module is used to obtain and store the segmentation function and segmentation value information sent by the host computer software, as well as the function construction configuration and operand information of each segment in the segmentation function; and the segmentation function and segmentation value information are sent to the input value function segment judgement in the segmentation function information generation module, and the function construction configuration and operand information of each segment in the segmentation function are sent to the function operation construction module; The piecewise function information generation module determines the input value of the function according to the piecewise function segment and segment value information of the function configuration module, generates the function segment information, and combines the data with the input value of the function and outputs it to the function operation construction module; A function operation construction module is connected in series with N function operation construction modules to realize all operation steps required in the function expression; each function operation construction module has an enable switch. If the enable switch is turned off, the function operation construction module is shielded, and data is directly forwarded from the input end of the function operation construction module to the output end; Wherein, the function operation construction module includes: The primary processing unit is used to receive the segment information and function input value sent by the segment information generator in the piecewise function information generation module, and query the function configuration module for the matching function construction configuration and operand information according to the segment information; wherein the function construction configuration information determines whether the primary processing unit uses a clipper, a comparator, or whether the primary processing unit is not enabled and directly skipped; The secondary processing unit is used to receive the rank information and processing results sent by the primary processing unit, and query the function configuration module for matching function construction configuration and operand information according to the rank information; wherein the function construction configuration information determines whether the secondary processing unit uses a multiplier or a divider, or whether the secondary processing unit is not enabled and is directly skipped; The third-level processing unit is used to receive the rank information and processing results sent by the second-level processing unit, and query the function configuration module for matching function construction configuration and operand information according to the rank information; wherein the function construction configuration information determines whether the third-level processing unit uses an adder or a subtractor, or whether the third-level processing unit is not enabled and is directly skipped; The fourth-level processing unit is used to receive the rank information and processing results sent by the third-level processing unit, and query the function configuration module for matching function construction configuration and operand information according to the rank information; wherein the function construction configuration information determines whether the fourth-level processing unit uses an inverse device, an absolute value device, or whether the fourth-level processing unit is not enabled and is directly skipped; The LUT lookup table operator is used to receive the rank information and processing results sent by the four-level processing unit, and query the function construction configuration and operand information matching the rank information in the function configuration module; wherein the function construction configuration information determines whether the LUT lookup table operator is skipped and the table value of the LUT lookup table. The LUT lookup table operator is used to perform calculations of complex functions such as power functions, square roots or trigonometric functions.

2. An activation class function expression generator for a convolutional neural network as claimed in claim 1, characterized in that: The piecewise function information generating module comprises: The input value function rank judger performs the segmented interval rank judgement of the piecewise function on the input value of the function. The input value function rank judger obtains the number of piecewise function ranks N and the interval segmentation value of the piecewise function from the piecewise function rank and segmentation value information of the function configuration module, and judges the rank interval where the function input value is located. If it is in the first segment interval of the function, the segment interval information 1 is generated and transmitted to the segment information generator; and so on, the maximum segment interval information is N; The rank information generator appends the function interval rank information sent by the input value function rank judger to the front of the function input value, and forms new data and sends it to the function operation construction module connected to it through the output end of the piecewise function information generation module.

3. An activation class function expression generator for a convolutional neural network as claimed in claim 1, characterized in that: The primary processing unit comprises: The mode selector obtains the segment information of the function input value from the piecewise function information generation module, selects and obtains the function construction configuration and operand information matching the segment of the input value through the function configuration module, and then enables or disables the clipper and comparator. If both are disabled, the first-level processing unit is directly skipped; The clipper, when enabled, obtains the clipper-specific operands A and B from the mode selector, and directly forwards the rank information and the input value to the secondary processing unit if the input value is between operand A and operand B, and outputs the rank information and operand A to the secondary processing unit if the input value is greater than operand A, and outputs the rank information and operand B to the secondary processing unit if the input value is greater than operand B; The comparator, when enabled, obtains the comparator-specific operand from the mode selector. If the comparator is in the maximum mode, the operand and the input value take the maximum value of the two and output it to the secondary processing unit. If the comparator is in the minimum mode, the operand and the input value take the minimum value of the two and output it to the secondary processing unit.

4. An activation class function expression generator for a convolutional neural network as claimed in claim 3, characterized in that: The clipper in the primary processing unit is used to implement the expression of the activation class function Clip: ; Among them, Y is the result output to the secondary processing unit after the clipper is processed, min is the clipper-specific operand A, max is the clipper-specific operand B, MAX is the maximum value function, and MIN is the minimum value function.

5. An activation class function expression generator for a convolutional neural network as claimed in claim 3, characterized in that: The comparator in the primary processing unit is used to implement the expression of arithmetic logic function MAX or MIN. MAX is a special operand of the comparator, which is compared with the function input value to obtain the maximum value and output it to the secondary processing unit. MIN is a special operand of the comparator, which is compared with the function input value to obtain the minimum value and output it to the secondary processing unit. The MAX and MIN function modes are selected in the comparator. When the function expression does not need Clip, MAX or MIN function expression, the primary processing unit can forward the input value directly to the secondary processing unit. The clipper and comparator in the primary processing unit are selected in two ways. When selected, the segment information will be attached to the header of the numerical result and sent to the secondary processing unit.

6. An activation class function expression generator for a convolutional neural network as claimed in claim 1, characterized in that: The secondary processing unit comprises: The mode selector, after obtaining the level information from the primary processing unit, selects and obtains the function construction configuration and operand information matching the input value level through the function configuration module, and then enables or disables the multiplier and divider. If both are disabled, the secondary processing unit is directly skipped; The multiplier, when enabled, obtains a multiplier-specific operand from the mode selector, multiplies the operand by the first-level calculation value, and outputs the obtained multiplication result together with the segment information to the third-level processing unit; The divider, when enabled, obtains a divider-specific operand from the mode selector, divides the operand by the input value, and outputs the division result together with the segment information to the three-level processing unit.

7. An activation class function expression generator for a convolutional neural network as claimed in claim 1, characterized in that: The three-stage processing unit comprises: The mode selector, after obtaining the level information from the secondary processing unit, selects and obtains the function construction configuration and operand information matching the input value level through the function configuration module, and then enables or disables the adder and subtractor. If both are disabled, the tertiary processing unit is directly skipped; The adder, when enabled, obtains an adder-specific operand from the mode selector, adds the operand to the secondary calculation value, and outputs the addition result together with the segment information to the fourth-level processing unit; The subtractor, when enabled, obtains a subtractor-specific operand from the mode selector, subtracts the operand from the input value, and outputs the subtraction result together with the segment information to the four-stage processing unit.

8. An activation class function expression generator for a convolutional neural network as claimed in claim 1, characterized in that: The four-stage processing unit comprises: The mode selector, after obtaining the level information of the function input value from the third-level processing unit, selects and obtains the function construction configuration and operand information matching the level of the input value through the function configuration module, and then enables or disables the reciprocator and the absolute valuer. If both are disabled, the fourth-level processing unit is directly skipped; The reciprocal device, when enabled, performs reciprocal processing on the calculation result sent by the three-level processing unit and outputs it to the LUT lookup table operator together with the segment information; The absolute value device, when enabled, performs absolute value processing on the calculation result sent by the three-level processing unit and outputs it to the LUT lookup table operator together with the segment information.

9. A method for generating activation class function expressions for convolutional neural networks, used to achieve hardware-level acceleration of activation layers in network models of various types of convolutional neural networks, using an activation class function expression generator for convolutional neural networks as described in any one of claims 1 to 8, characterized in that: The steps include: Step 1: According to the number of segments of the activated class function expression, the piecewise function segment information of the function expression and the segment value information of the function segment critical point are sent to the function configuration module through the host computer software, and then the function construction configuration and operand information are configured according to the function expression calculation steps of each segment; Step 2: The piecewise function information generation module determines the input value of the function through the piecewise function segment and segment value information of the function configuration module, generates the function segment information, and combines the data with the input value of the function and outputs it to the function operation construction module; Step three: The function operation construction module obtains the input value of the function and the function segment information corresponding to the input value by parsing the combined data sent by the piecewise function information generation module. The internal first-level processing unit, second-level processing unit, third-level processing unit, fourth-level processing unit and LUT lookup table operator query and obtain the function construction configuration and operand information matching the segment in the function configuration module according to the function segment information. The function operation construction module can realize the series connection of N function operation construction modules to realize all the operation steps required in the function expression.

10. A computer device, characterized in that: Used to store and execute the host computer software in the activation class function expression generator for convolutional neural networks as described in any one of claims 1 to 8, wherein the host computer software is used to send the construction information of the activation function to the function configuration module.

Citation Information

Patent Citations

  • Neural network-oriented general nonlinear activation function calculation device and method

    CN110688088A

  • Configurable convolutional neural network processor circuit

    CN111507465A