CN111191766B - Data processing method, device, processor and computer readable storage medium - Google Patents

Data processing method, device, processor and computer readable storage medium Download PDF

Info

Publication number
CN111191766B
CN111191766B CN202010001416.0A CN202010001416A CN111191766B CN 111191766 B CN111191766 B CN 111191766B CN 202010001416 A CN202010001416 A CN 202010001416A CN 111191766 B CN111191766 B CN 111191766B
Authority
CN
China
Prior art keywords
fitting
data
input data
interval
specific
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010001416.0A
Other languages
Chinese (zh)
Other versions
CN111191766A (en
Inventor
杨龚轶凡
郑瀚寻
闯小明
曾昭睿
周远航
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhonghao Xinying Hangzhou Technology Co ltd
Original Assignee
Zhonghao Xinying Hangzhou Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhonghao Xinying Hangzhou Technology Co ltd filed Critical Zhonghao Xinying Hangzhou Technology Co ltd
Priority to CN202010001416.0A priority Critical patent/CN111191766B/en
Publication of CN111191766A publication Critical patent/CN111191766A/en
Application granted granted Critical
Publication of CN111191766B publication Critical patent/CN111191766B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks

Abstract

The invention discloses a data processing method, a data processing device, a processor and a computer readable storage medium. The invention adopts the matching of the reverse shift unit and the fitting operation circuit to rapidly and efficiently process data so as to meet the requirement of the neural network on the nonlinearity, thereby improving the approximation capability of the neural network on complex functions. Compared with the prior art that only the fitting operation circuit is adopted to carry out the whole-interval fitting operation to fit the function value of the specific function, the invention not only can reduce the hardware resource cost by reducing the use of the fitting parameters, but also can accelerate the processing speed of the data processing device for the data by reducing the time of the fitting operation circuit for matching the fitting parameters.

Description

Data processing method, device, processor and computer readable storage medium
Technical Field
The present invention relates to the field of neural networks, and in particular, to a data processing method, apparatus, processor, and computer readable storage medium.
Background
In the deep learning application scenario of the neural network, we express the complex relationship between input and output by using the neural network. In mathematical language, complex functions are implemented using artificial neural networks. The neural network is composed of multiple layers of neurons, each neuron is provided with an activation function, the neurons can receive multiple inputs simultaneously and unify the inputs, then the multiple inputs are processed by the activation functions and output, a certain mapping relation exists between the inputs and the outputs, if the activation function in each neuron is a linear function, the mapping relation between the inputs and the outputs is linear, the neural network only combines the multiple inputs linearly and outputs the multiple inputs, namely the neural network lacks nonlinearity, and the approximation capability of complex functions is very limited.
In order to make the expression capability of the neural network for complex functions more powerful, a nonlinear activation function needs to be introduced for constructing the neural network. The nonlinear function is introduced for the neural network, corresponding to the function value to be fitted to the nonlinear function. Generally speaking, the function value of the nonlinear function fitted in the prior art is generally calculated by a general-purpose processor, which is low in efficiency. Even if a special fitting circuit is adopted, the required fitting interval is huge, the involved fitting parameters are numerous, the memory resource expense is high, the circuit area is large, and meanwhile, the data processing speed is difficult to meet the requirement of a neural network.
Disclosure of Invention
Aiming at the problems, in order to meet the requirement of the neural network on the nonlinearity, a whole set of solving measures for improving the data processing capacity of the neural network is provided on the basis of combining a special circuit with a scheme of only configuring a fitting operation circuit of a specific fitting interval to replace a scheme of configuring a fitting operation circuit of a whole interval, and the expenditure of hardware resources is obviously reduced.
To achieve the above object, according to a first aspect of the present invention, there is provided a data processing method applied to a neural network. Providing a fitting operation circuit, wherein the fitting operation circuit is used for calling fitting parameters to perform fitting operation on data; providing at least one specific fitting interval in the specific function definition domain, wherein the specific fitting interval corresponds to at least one group of fitting parameters; input data x is provided, the input data x being a normalized floating point number, the input data x comprising significant digits, exponents, and symbols. The data processing method provided by the invention comprises the following steps:
step S10, acquiring input data x, and judging whether the input data x is positioned in a specific fitting interval or not based on effective numbers, indexes and symbols of the input data x;
if the input data x is positioned in the specific fitting interval, a fitting operation circuit is used for calling fitting parameters to perform fitting operation on the input data x to obtain a fitting operation result, and a final operation result is obtained based on the fitting operation result;
if the input data x is located outside the specific fitting interval, skipping the step of directly calling the fitting operation circuit to process the input data x, and directly executing the step S20;
step S20, shifting the input data x to obtain shifted data x'; the shift processing includes obtaining an index t of shift data x' with t being an integer, and then calculating a difference between the index of input data x and the index t; shifting the effective number of the input data x based on the difference value to obtain the effective number of the shift data x';
step S30, acquiring fitting part x based on shift data x 1 Non-fitting portion x 2 Fitting part x 1 Non-fitting part x 2 The sum of (2) is equal to the shift data x'; wherein the fitting part x 1 The significant number of (2) is equal to the fractional part of the significant number of the shift data x' plus the integer r, fitting part x 1 Is located within a specific fit interval; non-fitting portion x 2 The significant number of (2) is equal to the integer part of the significant number of the shift data x' minus the integer r;
step S40, calling fitting parameters to the fitting part x by using a fitting operation circuit 1 Fitting operation is carried out to obtain a first operation result f (x 1 );
Step S50 based on non-fitting portion x 2 For the first operation result f (x 1 ) And performing reverse shift processing to obtain a final operation result.
The invention decomposes the input data x into fitting parts x 1 Non-fitting portion x 2 And the fitting part x is fitted by a fitting operation circuit 1 Fitting operation is carried out to obtain a first operation result f (x 1 ) Then based on non-fitting part x 2 For the first operation result f (x 1 ) And performing reverse shift processing to restore the function fitting value of the specific function. Compared with the closest specific implementation scheme of fitting by using a fitting operation circuit covering a whole section in the prior art, the fitting operation circuit only provided with a very small specific fitting section is matched by using the reverse shift unit to replace the fitting operation circuit provided with the whole section fitting section with high power consumption and multiple components, so that the number of fitting parameters is greatly reduced, and the cost of hardware resources, particularly memory resources, is reduced. At the same time, compared with the prior artThe fitting operation circuit provided by the invention is only configured with the very small specific fitting interval, so that the time for selecting and matching the fitting parameters when the fitting operation circuit calls the fitting parameters can be shortened, the processing speed of data is improved as a whole, the data processing method is particularly applied to a neural network, and particularly when the neural network approaches the function value of a specific function, the requirement of the neural network on nonlinearity is met, so that the approximation capability of the neural network on the complex function is further improved.
Preferably, the specific function includes an exponential function having a base equal to 2 k K is an integer not equal to zero. Binary is the most widely used and common case in computer program processing when a particular function is base 2 k And when the exponential function of (2) is performed, the reverse shift processing is simple to operate and easy to implement, and has strong applicability and popularization significance.
Preferably, the specific fitting interval includes [ -2 [ t+n ,2 t+m ]N and m are positive integers. In a preferred embodiment, the integer r is generally 1. Therefore, the fitting part x 1 The fitting part x is known from the construction mode of (a) 1 The significant number of (2) is smaller than that of (2), fitting part x 1 The index of (2) is equal to t, fitting part x 1 The sign of (c) includes both positive and negative cases. Therefore, the fitting part x under the premise of keeping n and m both positive integers in the binary neural network processing system preferred by the invention 1 Must lie within a specific fit interval [ -2 [ t+n ,2 t+m ]Thereby not requiring the fitting part x 1 The fitting operation can be performed by performing additional processing, so that the processing speed of the method for data is further improved, and only a specific fitting interval < -2 > is required to be stored t+n ,2 t+m ]And corresponding fitting parameters reduce the cost of storage resources.
More preferably, the specific fitting interval includes a first fitting interval and a second fitting interval, and the first fitting interval includes [ -2 t+n ,-2 t-p ]The second fit interval includes [2 t-q ,2 t+m ]P and q are both non-negative integers. From the fitting part x 1 The fitting part x is known from the construction mode of (a) 1 Significant numbers of (2) are greater than 1, fitting portion x 1 The index of (2) is equal to t, fitting part x 1 The sign of (c) includes both positive and negative cases. Therefore, on the premise that p and q are both non-negative integers, the fitting portion x 1 Must lie within the first fitting interval [ -2 ] t +n ,-2 t-p ]Or a second fitting interval [ 2] t-q ,2 t+m ]Thereby reducing the number of fitting parameters even further to reduce the overhead of memory resources.
More preferably, m and n are equal to 1, and p and q are equal to 0. At the assurance fitting part x 1 On the premise of being positioned in a specific fitting interval, the specific fitting interval is fixed at the most convenient [ -2 ] of use t+1 ,2 t+1 ]Or [ -2 t+1 ,-2 t ]U[2 t ,2 t+1 ]Thereby reducing the number of fitting parameters to a locally optimal situation to reduce the overhead of storage resources.
To achieve the above object, according to a second aspect of the present invention, there is provided a data processing apparatus. Providing at least one specific fitting interval corresponding to the specific function, wherein the specific fitting interval corresponds to at least one group of fitting parameters; and provides input data x, which is a normalized floating point number, the input data x including significant digits, exponents, and symbols. The data processing device provided by the invention comprises:
the judging unit is used for judging whether the input data x is positioned in a specific fitting interval or not according to the effective numbers, indexes and symbols of the input data x;
the shifting unit is connected with the judging unit and is used for acquiring input data x outside the specific fitting interval and carrying out shifting treatment on the input data x to obtain shifted data x';
the splitting unit is connected with the shifting unit and is used for acquiring shifting data x 'and splitting the shifting data x' into fitting parts x 1 Non-fitting portion x 2 Fitting part x 1 Non-fitting part x 2 The sum of (2) is equal to the shift data x';
fittingThe fitting operation circuit is used for receiving input data x positioned in a specific fitting interval and calling fitting parameters to carry out fitting operation on the input data x to obtain a fitting operation result; the fitting operation circuit is also used for receiving a fitting part x 1 And call fitting parameters to fitting part x 1 Fitting operation is carried out to obtain a first operation result f (x 1 );
The inverse shift unit is respectively connected with the fitting operation circuit and the splitting unit and is used for obtaining a first operation result f (x 1 ) Non-fitting portion x 2 And based on non-fitting part x 2 For the first operation result f (x 1 ) And performing reverse shift processing to obtain a final operation result.
The invention decomposes the input data x into fitting parts x 1 Non-fitting portion x 2 And the fitting part x is fitted by a fitting operation circuit 1 Fitting operation is carried out to obtain a first operation result f (x 1 ) Then based on non-fitting part x 2 For the first operation result f (x 1 ) And performing reverse shift processing to restore the function fitting value of the specific function. Therefore, through the processing procedure, the fitting operation circuit provided with the extremely small specific fitting interval is matched with the reverse shift unit to replace the fitting operation circuit provided with the extremely large fitting interval, so that the number of fitting parameters is reduced, and the cost of storage resources is reduced.
Preferably, the data processing apparatus further comprises a multiplexer, the multiplexer comprising an output and at least two inputs. The input end of the multiplexer is connected with the judging unit, the other input end of the multiplexer is connected with the splitting unit, and the output end of the multiplexer is connected with the fitting operation circuit. The multiplexer is used for obtaining the fitting part x 1 And/or input data x located in a specific fitting interval is selected and sent to the fitting operation circuit. By arranging the multiplexer, when the fitting operation circuit performs the fitting operation of the pipelining, the fitting operation circuit can be prevented from receiving a plurality of data simultaneously to cause operation errors, and the stability of the device is improved.
In view of the above-mentioned problems, according to a third aspect of the present invention, there is provided a computer-readable storage medium having stored thereon program code which, when executed by a processor, implements the steps of the data processing method in the first aspect described above.
In view of the above-mentioned problems, according to a fourth aspect of the present invention, there is provided a processor including the data processing apparatus in the above-mentioned second aspect.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a data processing method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a data processing apparatus according to an embodiment of the present invention;
FIG. 3 is a table of fitting parameters provided by an embodiment of the present invention;
FIG. 4 is another table of fitting parameters provided by an embodiment of the present invention;
FIG. 5 is another table of fitting parameters provided by an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The terms first, second and the like in the description and in the claims and in the drawings are used for distinguishing between different objects and not for describing a particular sequential order. The term "at least one" means one or more, and the term "plurality" means two or more, unless specifically defined otherwise. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. It will be understood that when an element is referred to as being "coupled" to "or" connected "to another element or elements, it can be directly or indirectly connected to the other element or elements.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the invention. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
Fig. 1 is a schematic flow chart of a data processing method according to an embodiment of the invention. Specifically, the method comprises the following steps.
And S1, acquiring input data x. The input data x is a normalized floating point number, including significant digits, exponents, and signs. In a preferred embodiment of the present invention, the input data x may be an IEEE-754 floating point number.
And S2, judging whether the input data x is positioned in a specific fitting interval or not according to the effective numbers, indexes and symbols of the input data x. If the input data x is located in the specific fitting interval, executing step S3; if the input data x is outside the specific fitting interval, step S4 is performed.
And step S3, using a fitting operation circuit to call fitting parameters corresponding to the specific fitting interval to perform fitting operation on the input data x so as to obtain a fitting operation result.
And S4, performing shift processing on the input data x to obtain shift data x'. The shifting process includes obtaining an exponent t of the shifted data x ', where t is an integer, calculating a difference between the exponent t and the exponent t of the input data x, and shifting a significant number of the input data x based on the difference to obtain a significant number of the shifted data x'. Specifically, the exponent t of the shift data x' may be subtracted from the exponent of the input data x to obtain a difference value, and if the difference value is greater than zero, the effective number of the input data x is shifted to the left, where the number of the shifted bits is equal to the difference value; if the difference is smaller than zero, the significant digit of the input data x is shifted to the right, and the number of bits shifted to the right is equal to the difference. The index t of the shift data x' can be subtracted from the index of the input data x to obtain a difference value, if the difference value is smaller than zero, the effective number of the input data x is shifted left, and the number of the left shift is equal to the difference value; if the difference is greater than zero, the significant digit of the input data x is shifted to the right by a number of digits equal to the difference.
Step S5, splitting the shift data x' to obtain a fitting part x 1 Non-fitting portion x 2 Fitting part x 1 Non-fitting part x 2 The sum of (2) is equal to the shift data x'. Wherein the fitting part x 1 The significant number of (2) is equal to the fractional part of the significant number of the shift data x' plus the integer r, fitting part x 1 Is located within a specific fit interval; non-fitting portion x 2 The significant number of (2) is equal to the integer part of the significant number of the shift data x' minus the integer r. In a preferred embodiment of the invention r is equal to 1.
Step S6, calling fitting parameters to the fitting part x by using a fitting operation circuit 1 Fitting operation is carried out to obtain a first operation result f (x 1 )。
Step S7, based on the non-fitting part x 2 For the first operation result f (x 1 ) And performing reverse shift processing to obtain a final operation result. Specifically, if the specific function to be fitted is an exponential function, the base of the exponential function is 2 k K is an integer not equal to zero.The reverse shift process includes: when kx 2 When the first operation result f (x 1 ) Corresponding binary number is shifted left by kx 2 Bits are used as the final operation result; when kx 2 And when the value is less than zero, the first operation result f (x 1 ) Corresponding binary number right shift |kx 2 The i bit is the final operation result. It should be noted that due to the non-fitting portion x 2 The significant number of (2) is equal to the integer part of the significant number of the shifted data x' minus the integer r, and therefore the non-fitting part x 2 The significant numbers of (a) are integers, the non-fitting portion x 2 The exponent of (2) is equal to the exponent t of the shift data x', t is an integer, and t is typically set to a non-negative integer, so that the non-fitting portion x 2 Typically an integer.
And step S8, outputting the numerical value of the fitting operation result in the step S3 as a final operation result and/or outputting the final operation result in the step S7.
The prior art tends to configure a larger interval as the fit interval, e.g., for function 2 in an IEEE-754 single precision floating point number system x Fitting is performed, and the maximum value which can be represented by the IEEE-754 single-precision floating point number is 2 127 The fit interval is therefore often configured as [ -127,127]In order to ensure the accuracy of the fitting, the fitting interval is generally divided into a plurality of sub-intervals. If a subinterval is divided every 0.1, the fit interval is [ -127,127]It will be possible to divide into 2540 subintervals, so 2540 sets of fitting parameters are theoretically required to achieve a fit of the function, which is extremely large for storage resource usage. In the present invention, however, the function 2 x Fitting operation is carried out by only setting the fitting interval to be [ -2,2]In the same way for [ -2,2]The total of 40 sub-intervals can be known by dividing, so that only 40 sets of fitting parameters are needed to finish
Figure BDA0002353636870000061
At [ -2,2]Is then based on the non-fitting part x by the inverse shift unit 2 For->
Figure BDA0002353636870000062
Where the reverse shift is performedAnd the input data x is reduced to be within the range of-127, 127]Is a function fit of the values.
From a memory resource perspective, memory resource overhead of about 2500 sets of fitting parameters is saved. In a system having a high requirement for fitting accuracy, the subinterval division interval is generally set to 0.1 or less; when 0.1 is taken as a common minimum subinterval standard, the invention saves at least two orders of magnitude intervals compared with the prior art, so the invention is quite considerable for saving storage resources. If the fitting parameters are not stored by using the storage resources, but are solidified in the circuit, compared with 2500 sets of fitting parameters needing to be solidified in the prior art, the invention can greatly reduce the area and the power consumption of the circuit.
In addition, in order to invoke the corresponding fitting parameters to perform the fitting operation, it is necessary to determine which sub-interval the input data x is located in, so that log is theoretically required in the prior art 2 2540 gates (gates) are used for judging subintervals, and the invention only needs log 2 40 gates. Therefore, the circuit area of the invention is significantly smaller than the prior art. Meanwhile, in the fitting operation of the pipelining, the invention uses less gates to judge, and the circuit delay (namely the fitting part x 1 The time to match the corresponding fitting parameters) is significantly lower than in the prior art.
In some embodiments of the present invention, the specific fit interval may be set to [ -2 t+n ,2 t+m ]M and n are positive integers. In other embodiments of the invention, a plurality of specific fit intervals may also be provided, e.g., the specific fit interval may be set to [ -2 [ t+n ,-2 t-p ]U[2 t-q ,2 t+m ]P and q are both non-negative integers. In a preferred embodiment of the invention, m and n are generally taken to be 1, and p and q are taken to be 0. In some embodiments of the present invention, the particular fit interval may also be configured as an open interval or a half-open half-closed interval.
For example, when the exponent t of the shift data x' is equal to 0, the specific fit interval may be set to [ -2,2], (-2, 2), etc. The specific fit interval may also be set to [ -2, -1] U [1,2], (-2, -1) U (1, 2), (-2, -1] U [1, 2), etc., and will not be described in detail herein. In a preferred embodiment of the invention, the specific fit interval comprises a plurality of sub-intervals, each corresponding to a set of fit parameters.
Fig. 2 is a schematic diagram of a data processing apparatus 200 according to an embodiment of the invention. The data processing apparatus 200 includes a judging unit 210, a shifting unit 220, a splitting unit 230, a multiplexer 240, a fitting operation circuit 250, and a reverse shifting unit 260.
The judging unit 210 is connected with the shifting unit 220; the shift unit 220 is connected to the split unit 230; one input end of the multiplexer 240 is connected with the judging unit 210, the other input end of the multiplexer 240 is connected with the splitting unit 230, and the output end of the multiplexer 240 is connected with the fitting operation circuit 250; the inverse shift unit 260 is connected to the splitting unit 230 and the fitting operation circuit 250, respectively.
The determining unit 210 is configured to receive the input data x, and determine whether the input data x is located in a specific fitting interval according to significant digits, exponents, and signs of the input data x. If the input data x is within the specific fitting interval, the judging unit 210 sends the input data x to the multiplexer 240; if the input data x is outside the specific fitting interval, the determining unit 210 sends the input data x to the shifting unit 220.
The shift unit 220 is configured to perform shift processing on the input data x to obtain shift data x ', and send the shift data x' to the splitting unit 230.
The splitting unit 230 is used for splitting the shift data x' into fitting parts x 1 Non-fitting portion x 2 Fitting part x 1 Non-fitting part x 2 The sum of (2) is equal to the shift data x'. Fitting part x 1 Sent to the multiplexer 240 and the non-fitting part x 2 The reverse shift unit 260 is transmitted.
The multiplexer 240 is used for receiving the input data x and/or the fitting part x within a specific fitting interval 1 The selection is sent to the fitting circuit 250. Selected to transfer data from multiple data channels to a unique common channelLogic circuits implementing the data selection function can be considered as simple permutations of multiplexers (multiplexers). For example, a data selector, a multiplexer may be used instead of the multiplexer described above.
The fitting operation circuit 250 is configured to receive input data x located in a specific fitting interval, perform fitting operation, and obtain a fitting operation result; the fitting operation circuit 250 is also used for receiving the fitting part x 1 Fitting operation is carried out to obtain a first operation result f (x 1 )。
The inverse shift unit 260 is configured to receive the first operation result f (x 1 ) Non-fitting portion x 2 And based on non-fitting part x 2 For the first operation result f (x 1 ) And performing reverse shift processing to obtain a final operation result.
For ease of understanding, the process of data processing is described below with data processing apparatus 200 in connection with specific functions and input data.
In one embodiment of the invention, it is preferable to provide a function for fitting of 2 x Preferably, the specific fitting interval is preset to be [ -2,2]The specific fit interval is divided into a plurality of sub-intervals, each sub-interval corresponding to a set of fit parameters. Please refer to fig. 3, which illustrates the partial fitting parameters provided in this embodiment.
An IEEE-754 floating-point number 8.5 is provided as input data, with a significant number of 1.0001, an exponent of 3, and a sign of positive, which may be expressed as 1.0001 x 2 3 (in binary).
The judging unit 210 receives the input data 8.5, judges that it is not located in the specific fitting interval [ -2,2], and sends it to the shifting unit 220.
The shift unit 220 receives the input data and performs shift processing to obtain shift data. Specifically, the index of the shift data may be set to 0. Firstly, subtracting the index of the shift data from the index of the input data to obtain a difference value of 3, and then shifting the effective number of the input data left by 3 bits to obtain the effective number of the shift data. Thus, the shift data can be expressed as 1000.1×2 0 (in binary).
The splitting unit 230 acquires the shift data and splits it into candidatesA fitting portion and a non-fitting portion. Specifically, the decimal part of the effective number of the shift data plus 1 is taken as the effective number of the fitting portion, and thus, the fitting portion can be expressed as 1.1×2 0 (expressed in binary, equivalent to 1.5 in decimal); the integer part of the significant number of the shift data is subtracted by 1 as the significant number of the non-fitting portion, and thus the non-fitting portion can be represented as 111×2 0 (expressed in binary, corresponding to 7 decimal).
The fitting operation circuit 250 obtains the fitting part through the multiplexer 240 and judges the subinterval [1.5, 2] of the specific fitting interval]And (3) calling the fitting parameter a, the fitting parameter b and the fitting parameter c to carry out fitting operation on the fitting parameter a, the fitting parameter b and the fitting parameter c, so as to obtain a first operation result. Wherein the fitting parameter a is 0.8, the fitting parameter b is-0.6, the fitting parameter c is 1.8, and the formula for performing binomial fitting operation is ax 2 +bx+c, and thus the first operation result is 2.7 (expressed in decimal). It should be appreciated that to ensure the accuracy of the fitting operation, the fitting parameters may be iterated or debugged a number of times. The fitting parameters shown in this embodiment are given for illustrative purposes only to illustrate the fitting operation procedure, and are not to be construed as fitting parameters in the optimal situation when the present invention is actually used.
The inverse shift unit 260 acquires the non-fitting portion and the first operation result. Wherein the non-fitting part is equal to 7, function 2 x The base number of (2) 1 Therefore, the inverse shift unit 260 shifts the binary number corresponding to the first operation result by 7 bits (corresponding to multiplication by 2 in value 7 ) The final result is equal to 345.6.
In another embodiment of the present invention, the specific function provided for fitting is 4 x A specific fitting interval is set to (-2, -1) U (1, 2), which is divided into a plurality of sub-intervals, each corresponding to a set of fitting parameters. Please refer to fig. 4, which illustrates the partial fitting parameters provided in this embodiment.
An IEEE-754 floating-point number-4.75 is provided as input data, with a significant number 1.0011, an exponent of 2, a sign of negative, and can be expressed as-1.0011 x 2 2 (in two)Binary representation).
The judging unit 210 receives the input data, judges that it is not located in the specific fitting interval (-2, -1) U (1, 2), and thus, sends it to the shifting unit 220.
The shift unit 220 receives input data and performs shift processing thereon. Specifically, the index of the shift data may be set to 0. Firstly, subtracting the index of the shift data from the index of the input data to obtain a difference value of 2, and then shifting the effective number of the input data by 2 bits to the left to obtain the effective number of the shift data. Thus, the shift data can be represented as-100.11 x 2 0 (in binary).
The splitting unit 230 receives the shift data and splits it into a fitted part and a non-fitted part. Specifically, the decimal part of the significant figure of the shift data is added to 1 as the fitting portion, so the fitting portion can be expressed as-1.11×2 0 (expressed in binary, -1.75 corresponding to decimal), the integer part of the significant number of the shifted data is subtracted by 1 as a non-fitting part, so the non-fitting part can be expressed as-11 x 2 0 (in binary representation, corresponding to decimal-3).
The fitting operation circuit 250 obtains the fitting part through the multiplexer 240, determines that the fitting part is located in a subinterval (-2, -1.5) of the specific fitting interval, and invokes the corresponding fitting parameter a, fitting parameter b and fitting parameter c to perform fitting operation on the fitting parameter a, fitting parameter b and fitting parameter c to obtain a first operation result. Wherein the fitting parameter a is 0.0049, the fitting parameter b is 0.25, the fitting parameter c is 0.64, and the formula for performing binomial fitting operation is ax 2 +bx+c, thus, the first operation result is 0.21750625 (expressed in decimal). It should be appreciated that to ensure the accuracy of the fitting operation, the fitting parameters may be iterated or debugged a number of times. The fitting parameters shown in this embodiment are given for illustrative purposes only to illustrate the fitting operation procedure, and are not to be construed as fitting parameters in the optimal situation when the present invention is actually used.
The inverse shift unit 260 acquires the non-fitting section and the first operation result. Wherein the non-fitting part is equal to-3, function 4 x The base number of (2) 2 . Thus, the first transportationThe binary number corresponding to the result is shifted to the right by 6 bits, resulting in a final result equal to 0.00339853515625 (expressed in decimal scale).
In another embodiment of the present invention, the specific function provided for fitting is
Figure BDA0002353636870000101
Setting the specific fitting interval as (-2, 2)]. The specific fitting interval is divided into a plurality of subintervals, each subinterval corresponding to a set of fitting parameters. Please refer to fig. 5, which illustrates the partial fitting parameters provided in this embodiment.
An IEEE-754 floating-point number-4.75 is provided as input data, with a significant number 1.0011, an exponent of 2, a sign of negative, and can be expressed as-1.0011 x 2 2 (in binary).
The judging unit 210 receives the input data, judges that it is not located in the specific fitting interval (-2, 2), and thus, sends it to the shifting unit 220.
The shift unit 220 receives input data and performs shift processing thereon. Specifically, the index of the shift data may be set to 0. Firstly, subtracting the index of the shift data from the index of the input data to obtain a difference value of 2, and then shifting the effective number of the input data by 2 bits to the left to obtain the effective number of the shift data. Thus, the shift data can be represented as-100.11 x 2 0 (in binary).
The splitting unit 230 receives the shift data and splits it into a fitted part and a non-fitted part. Specifically, the decimal part of the significant figure of the shift data is added to 1 as the fitting portion, so the fitting portion can be expressed as-1.11×2 0 (expressed in binary, -1.75 corresponding to decimal); the integer part of the significant number of the shift data is subtracted by 1 as a non-fitting part, so the non-fitting part can be expressed as-11 x 2 0 (expressed in binary, corresponding to-3 in decimal).
The fitting operation circuit 250 obtains the fitting part through the multiplexer 240, judges that the fitting part is positioned in a subinterval (-2, -1.5) of the specific fitting interval, and calls the corresponding fitting parameter a, the fitting parameter b and the fitting parameter c to perform fitting operation to obtain a first operationAs a result. Wherein the fitting parameter a is 1, the fitting parameter b is 1, the fitting parameter c is 2.05, and the formula for performing binomial fitting operation is ax 2 +bx+c, thus, the first operation result is 3.3625 (expressed in decimal). It should be appreciated that to ensure the accuracy of the fitting operation, the fitting parameters may be iterated or debugged a number of times. The fitting parameters shown in this embodiment are given for illustrative purposes only to illustrate the fitting operation procedure, and are not to be construed as fitting parameters in the optimal situation when the present invention is actually used.
The inverse shift unit 260 acquires the non-fitting section and the first operation result. Wherein the non-fitting part is equal to-3, the function
Figure BDA0002353636870000111
The base number of (2) -1 . Therefore, the binary number corresponding to the first operation result is shifted left by 3 bits, resulting in a final operation result equal to 26.9 (expressed in decimal).
It is obvious that the index of the shift data is not limited to 0 shown above, but can be adjusted according to the actual implementation. Similarly, the selection of the specific fitting interval is not limited to the above-described case, but may be determined according to the index of the shift data, and the manner of determining the specific fitting interval is described in detail above and will not be repeated here. The function of fitting is also not limited to 2 as shown in the above embodiment x 、4 x Or (b)
Figure BDA0002353636870000112
In other embodiments, the function to be fitted may be an exponential function with a base of 2 k K is an integer other than zero.
The above-described fitting parameters and the division of sub-intervals shown in the fitting parameter table are merely exemplary data and are not to be construed as a specific limitation of the invention to fitting parameters or individual fitting sub-intervals. The fitting parameters or the ranges of the subintervals can be adjusted according to the requirements for fitting accuracy.
Fig. 6 is a schematic structural diagram of a data processing apparatus 600 according to an embodiment of the present invention. The data processing device 600 as shown in fig. 6 includes one or more processors 610, a communication interface 620, and a memory 630. The processor 610, the communication interface 620, and the memory 630 may be connected by a bus, or may communicate by other means such as wireless transmission. The embodiment of the present invention is exemplified as being connected by bus 640. The memory 630 is used for program codes, and the processor 610 is provided with the data processing device disclosed in the foregoing embodiment, and is used for executing the program codes stored in the memory 630, and when the program codes are executed by the processor 610, the steps of the data processing method disclosed in the foregoing embodiment are implemented.
It should be appreciated that in embodiments of the present invention, the processor 610 may be a central processing unit (Central Processing Unit, CPU), which may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSPs), application specific integrated circuits (Application Specific Integrated Circuit, ASICs), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The communication interface 620 may be a wired interface (e.g., an ethernet interface) or a wireless interface (e.g., a cellular network interface or using a wireless local area network interface) for communicating with other modules or apparatus devices. For example, the communication interface 620 in the embodiment of the present application may be specifically configured to receive input data input by a user; or to receive data from an external device, etc.
The Memory 630 may include Volatile Memory (Volatile Memory), such as random access Memory (Random Access Memory, RAM); the Memory may also include a Non-Volatile Memory (Non-Volatile Memory), such as a Read-Only Memory (ROM), a Flash Memory (Flash Memory), a Hard Disk (HDD), or a Solid State Drive (SSD); the memory may also comprise a combination of the above types of memories.
It should be noted that fig. 6 is only one possible implementation of the embodiment of the present invention, and in practical applications, the data processing apparatus may further include more or fewer components, which is not limited herein. For details not shown or described in the embodiments of the present invention, reference may be made to the related descriptions in the foregoing method embodiments, which are not repeated here.
Those of ordinary skill in the art will appreciate that the elements and steps of a process described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the elements and steps of a process have been described above generally in terms of functionality for clarity of understanding the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working procedures of the terminal device and unit described above may refer to the corresponding procedures in the foregoing method embodiments, which are not repeated herein.
In several embodiments provided in the present application, it should be understood that the disclosed terminal device and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. In addition, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices, or elements, or may be an electrical, mechanical, or other form of connection.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment of the present invention.
In addition, each functional unit in each embodiment of the present invention may be integrated in one data processing apparatus, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention is essentially or a part contributing to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.

Claims (9)

1. The data processing method is applied to a neural network, and a fitting operation circuit is provided and is used for calling fitting parameters to perform fitting operation on data; providing at least one specific fit interval within a specific function definition domain, the specific fit interval corresponding to at least one set of fit parameters; providing input data x, wherein the input data x is a standardized floating point number, and the input data x comprises significant digits, exponents and signs; the fitting operation circuit is characterized in that the fitting operation circuit only processes data in the specific fitting interval;
the data processing method comprises the following steps:
step S10, acquiring the input data x, and judging whether the input data x is positioned in the specific fitting interval or not based on the effective number, the index and the sign of the input data x;
if the input data x is located in the specific fitting interval, the fitting operation circuit is used for calling the fitting parameters to perform fitting operation on the input data x to obtain a fitting operation result, and a final operation result is obtained based on the fitting operation result;
if the input data x is located outside the specific fitting interval, skipping the step of directly calling the fitting operation circuit to process the input data x, and directly executing the step S20;
step S20, performing shift processing on the input data x to obtain shift data x'; the shift processing includes obtaining an exponent t of the shift data x', where t is an integer, and then calculating a difference between the exponent of the input data x and the exponent t; shifting the effective number of the input data x based on the difference value to obtain the effective number of the shift data x';
step S30, acquiring fitting part x based on the shift data x 1 Non-fitting portion x 2 The fitting part x 1 To the non-fitting part x 2 Is equal to the shifted data x'; wherein the fitting part x 1 The significant number of (2) is equal to the fractional part of the significant number of the shift data x' plus an integer r, the fitting part x 1 Is located within the specific fitting interval; the non-fitting part x 2 An integer having a significant number equal to the significant number of the shift data xPartial subtraction of integer r;
step S40, calling the fitting parameters to the fitting part x by using the fitting operation circuit 1 Fitting operation is carried out to obtain a first operation result f (x 1 );
Step S50, based on the non-fitting part x 2 For the first operation result f (x 1 ) And performing reverse shift processing to obtain a final operation result.
2. The data processing method according to claim 1, wherein the specific function includes an exponential function, a base of the exponential function being equal to 2 k K is an integer not equal to zero.
3. The data processing method according to claim 1, wherein the specific fitting interval includes [ -2 [ t+n ,2 t +m ]N and m are positive integers.
4. A data processing method according to claim 3, wherein the specific fit interval comprises a first fit interval and a second fit interval, the first fit interval comprising [ -2 [ t+n ,-2 t-p ]The second fitting interval includes [ 2] t-q ,2 t+m ]P and q are both non-negative integers.
5. The data processing method according to claim 4, wherein m and n are equal to 1, and p and q are equal to 0.
6. A data processing apparatus providing at least one specific fit interval within a specific function definition domain, the specific fit interval corresponding to at least one set of fit parameters; providing input data x, said input data x being a normalized floating point number, said input data x comprising significant digits, exponents, and signs, said data processing apparatus comprising:
the judging unit is used for judging whether the input data x is positioned in the specific fitting interval according to the effective numbers, indexes and symbols of the input data x;
the shifting unit is connected with the judging unit and is used for acquiring the input data x outside the specific fitting interval and carrying out shifting processing on the input data x to obtain shifted data x';
the splitting unit is connected with the shifting unit and is used for acquiring the shifting data x 'and splitting the shifting data x' into fitting parts x 1 Non-fitting portion x 2 The fitting part x 1 To the non-fitting part x 2 Is equal to the shifted data x';
the fitting operation circuit is used for receiving input data x positioned in the specific fitting interval and calling the fitting parameters to perform fitting operation on the input data x to obtain a fitting operation result; the fitting operation circuit is also used for receiving the fitting part x 1 And call the fitting parameters to the fitting part x 1 Fitting operation is carried out to obtain a first operation result f (x 1 );
The reverse shift unit is respectively connected with the fitting operation circuit and the splitting unit, and is used for acquiring the first operation result f (x 1 ) The non-fitting part x 2 And based on the non-fitting part x 2 For the first operation result f (x 1 ) And performing reverse shift processing to obtain a final operation result.
7. The data processing apparatus according to claim 6, further comprising a multiplexer, the multiplexer including an output terminal and at least two input terminals, the input terminal of the multiplexer being connected to the judging unit, the other input terminal of the multiplexer being connected to the splitting unit, the output terminal of the multiplexer being connected to the fitting operation circuit; the multiplexer is used for obtaining the fitting part x 1 And/or input data x located in the specific fitting interval and selectively sent to the computerFitting operation circuit.
8. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a program code which, when executed by a processor, implements the steps of the data processing method according to any one of claims 1 to 5.
9. A processor, characterized in that it comprises a data processing device according to claim 6 or 7.
CN202010001416.0A 2020-01-02 2020-01-02 Data processing method, device, processor and computer readable storage medium Active CN111191766B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010001416.0A CN111191766B (en) 2020-01-02 2020-01-02 Data processing method, device, processor and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010001416.0A CN111191766B (en) 2020-01-02 2020-01-02 Data processing method, device, processor and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN111191766A CN111191766A (en) 2020-05-22
CN111191766B true CN111191766B (en) 2023-05-16

Family

ID=70709745

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010001416.0A Active CN111191766B (en) 2020-01-02 2020-01-02 Data processing method, device, processor and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN111191766B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107247992A (en) * 2014-12-30 2017-10-13 合肥工业大学 A kind of sigmoid Function Fitting hardware circuits based on row maze approximate algorithm
CN108154224A (en) * 2018-01-17 2018-06-12 北京中星微电子有限公司 For the method, apparatus and non-transitory computer-readable medium of data processing
CN109241869A (en) * 2018-08-16 2019-01-18 邯郸职业技术学院 The recognition methods of answering card score, device and terminal device
CN109657788A (en) * 2018-12-18 2019-04-19 北京中科寒武纪科技有限公司 Data processing method, device and Related product

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7546328B2 (en) * 2004-08-31 2009-06-09 Wisconsin Alumni Research Foundation Decimal floating-point adder

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107247992A (en) * 2014-12-30 2017-10-13 合肥工业大学 A kind of sigmoid Function Fitting hardware circuits based on row maze approximate algorithm
CN108154224A (en) * 2018-01-17 2018-06-12 北京中星微电子有限公司 For the method, apparatus and non-transitory computer-readable medium of data processing
CN109241869A (en) * 2018-08-16 2019-01-18 邯郸职业技术学院 The recognition methods of answering card score, device and terminal device
CN109657788A (en) * 2018-12-18 2019-04-19 北京中科寒武纪科技有限公司 Data processing method, device and Related product

Also Published As

Publication number Publication date
CN111191766A (en) 2020-05-22

Similar Documents

Publication Publication Date Title
US20210349692A1 (en) Multiplier and multiplication method
US4616330A (en) Pipelined multiply-accumulate unit
CN109871871B (en) Image identification method and device based on optical neural network structure and electronic equipment
CN109543815B (en) Neural network acceleration method and device
CN110796247B (en) Data processing method, device, processor and computer readable storage medium
CN106708468B (en) Division operation device
Kumar et al. New algorithm for signed integer comparison in $\{2^{n+ k}, 2^{n}-1, 2^{n}+ 1, 2^{n\pm 1}-1\} $ and its efficient hardware implementation
CN111191779B (en) Data processing method, device, processor and computer readable storage medium
CN111191766B (en) Data processing method, device, processor and computer readable storage medium
KR20170138143A (en) Method and apparatus for fused multiply-add
JPH09325955A (en) Square root arithmetic circuit for sum of squares
Tay et al. New algorithm for signed integer comparison in four-moduli superset {2 n, 2 n− 1, 2 n+ 1, 2 n+ 1− 1}
CN103955585A (en) FIR (finite impulse response) filter structure for low-power fault-tolerant circuit
CN113672196B (en) Double multiplication calculating device and method based on single digital signal processing unit
Teja Design of radix-8 booth multiplier using koggestone adder for high speed Arithmetic applications
del Campo et al. A multi-cycle fixed point square root module for FPGAs
CN115483934A (en) Data conversion method and device for multi-party security calculation
CN113988279A (en) Output current reading method and system of storage array supporting negative value excitation
CN111384975B (en) Optimization method, device and decoder of multi-system LDPC decoding algorithm
CN111384971B (en) Method, device and decoder for processing data in finite field
US20210064340A1 (en) Arithmetic circuit
JP2021501406A (en) Methods, devices, and systems for task processing
GB2530883A (en) Implementing a square root operation in a computer system
Bhusare et al. Fixed-width multiplier with simple compensation bias
CN116127523B (en) Data processing method and device in privacy calculation and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
TA01 Transfer of patent application right

Effective date of registration: 20210209

Address after: 311201 No. 602-11, complex building, 1099 Qingxi 2nd Road, Hezhuang street, Qiantang New District, Hangzhou City, Zhejiang Province

Applicant after: Zhonghao Xinying (Hangzhou) Technology Co.,Ltd.

Address before: 518057 5-15, block B, building 10, science and technology ecological park, Yuehai street, Nanshan District, Shenzhen City, Guangdong Province

Applicant before: Shenzhen Xinying Technology Co.,Ltd.

TA01 Transfer of patent application right
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant