CN107590105B - Computing device and method towards nonlinear function - Google Patents

Computing device and method towards nonlinear function Download PDF

Info

Publication number
CN107590105B
CN107590105B CN201710777378.6A CN201710777378A CN107590105B CN 107590105 B CN107590105 B CN 107590105B CN 201710777378 A CN201710777378 A CN 201710777378A CN 107590105 B CN107590105 B CN 107590105B
Authority
CN
China
Prior art keywords
function
parameter
unit
input value
look
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
CN201710777378.6A
Other languages
Chinese (zh)
Other versions
CN107590105A (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.)
Zhongke Times (Shenzhen) Computer System Co.,Ltd.
Original Assignee
Institute of Computing Technology of CAS
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 Institute of Computing Technology of CAS filed Critical Institute of Computing Technology of CAS
Priority to CN201710777378.6A priority Critical patent/CN107590105B/en
Publication of CN107590105A publication Critical patent/CN107590105A/en
Application granted granted Critical
Publication of CN107590105B publication Critical patent/CN107590105B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Complex Calculations (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

The present invention relates to a kind of computing devices towards nonlinear function, including searching unit, for determining function and corresponding linear function parameter according to the function and function variable input value;And computing unit, for being calculated using the input value and the corresponding linear function parameter.

Description

Computing device and method towards nonlinear function
Technical field
The present invention relates to calculating field, in particular to a kind of computing device and method towards nonlinear function.
Background technique
Nonlinear function is one kind of functional form, is directed to the meter for nonlinear function in many technical fields It calculates.It is a series of multiple that the calculating of nonlinear function generally comprises multiplying, division arithmetic, exponent arithmetic and trigonometric function operation etc. Miscellaneous operation calculates relatively complicated, it usually needs corresponding operation is completed using components such as arithmetic logic unit, correspondingly, operation Complex circuit designs degree is higher.
The universal arithmetic logic unit used in the prior art, such as the ALU in CPU, count nonlinear function That there are resource utilizations is low for calculation, executes a series of problems, such as speed is slow, circuit hardware expense is big, is unable to satisfy many low-power consumption and answers Use scene.Especially in certain special algorithms, part nonlinear function occurs with upper frequency, for example, depositing in neural network It is each layer of sigmoid function, the speed of arithmetic speed and the number of operation energy consumption directly restrict entire nerve The computational efficiency of network.
Therefore, it is necessary to the device and methods that one kind can simplify the quick calculating nonlinear function of circuit design.
Summary of the invention
The present invention provides a kind of computing device and method towards nonlinear function, including searching unit, for according to institute It states function and function variable input value determines function and corresponding linear function parameter;And
Computing unit, for being calculated using the input value and the corresponding linear function parameter;
Wherein, the linear function parameter includes multiplication factor and addition parameter.
Preferably, the computing unit includes multiplying for executing multiplying to the input value and the multiplication factor Musical instruments used in a Buddhist or Taoist mass.
Preferably, the multiplier is the multiplier based on Booth encoding.
Preferably, the multiplier based on Booth encoding includes
Booth encoding unit, for carrying out Booth encoding to input value and multiplier parameters;
Partial product computing unit, for calculating section product;And
Compression unit for the partial product to be added, and obtains the output valve of the multiplier.
Preferably, the Booth encoding unit uses the Booth encoding mode of base four.
Preferably, the computing unit further include for the multiplier output valve and the domestic discipline parameter execute plus The adder of method operation.
Preferably, the function section is divided according to the regularity of distribution of function argument.
Preferably, the searching unit includes:
Matching unit, for the input value of nonlinear function to be matched to corresponding function section;
Look-up table unit, for determining corresponding linear function parameter according to the function section.
According to another aspect of the present invention, a kind of calculation method of nonlinear function is also provided, comprising the following steps:
The multiplication factor and addition of the corresponding linear function in the function section are calculated using the endpoint in the function section Parameter simultaneously saves as look-up table;
The corresponding function section of input value for searching the nonlinear function using the look-up table and the line The multiplication factor and addition parameter of property function;
Utilize the input value of the nonlinear function and the multiplication factor and addition parameter of the corresponding linear function It is calculated.
Preferably, Booth encoding is executed to the multiplication factor and the input value and generates partial product;
Add operation will be executed with the addition parameter after partial product summation and obtain calculated result.
Compared with the existing technology, the present invention achieves following advantageous effects: provided by the invention towards non-linear letter The computer capacity of nonlinear function is divided into several areas using the calculation method of piecewise approximation by several computing devices and method Between, by nonlinear function it is approximately that linear function carries out calculating functional value in section, improves calculating speed;Using being based on The multiplier of Booth encoding realizes multiplication and add operation, further improves operation efficiency, opens to save circuit area Pin and energy loss, the application scenarios especially suitable for low-power consumption high energy efficiency.
Detailed description of the invention
Fig. 1 is the nonlinear function computing device structure schematic diagram of present pre-ferred embodiments.
Fig. 2 is the structural schematic diagram of the computing unit of present pre-ferred embodiments.
Fig. 3 is the structural schematic diagram of the look-up table unit of present pre-ferred embodiments.
Fig. 4 is the method flow diagram that nonlinear function calculating is carried out using computing device shown in FIG. 1.
Specific embodiment
In order to which the purpose of the present invention, technical solution and advantage is more clearly understood, below in conjunction with attached drawing, to according to this The computing device and method further description towards nonlinear function provided in the embodiment of invention.
Linearity and non-linearity is usually used in distinctive function y=f (x) to the dependence of independent variable x.A linear function i.e. letter Number, in a coordinate system, the image of linear function is represented by straight line, describe amount and amount between in proportion, be in line Relationship, delegate rules and smooth movement on room and time;And nonlinear function, in a coordinate system, image indicates It is not straight line, describes not to scale (NTS) between amount and amount, the relationship not formed straight line, represent non-directional movement and mutation.Though It is so more fast and convenient for the methods of analytical calculation of linear function, but in practice, the substantial amount that we encounter with Relationship between amount is all nonlinear function, therefore in order to simplify the calculating for nonlinear function, we usually require to use Linear function represents nonlinear function.
Approximation method (approximate method) is a kind of The mathematic calculation of computing object.Inventor it has been investigated that, in order to quickly calculate more complicated application, such as low-power consumption Function can be divided into several sections using the method for piecewise linearity by the application scenarios of high energy efficiency, and line is used in each section The approximate mode of property calculates functional value, using approximation theory, approaches actual nonlinear function as far as possible.This method both may be used The calculating of the complicated functions such as power operation in complicated function, division arithmetic and trigonometric function operation is saved, circuit area can also be saved and opened Pin and energy loss.
In order to be linear function by nonlinear function piecewise approximation, it is necessary first to divide the computer capacity of nonlinear function For several sections, the section completed will be divided and stored into matching unit, while will be in each section using the endpoint value in each section Function curve be approximately represented as the straight line between the point value of connecting pin;It is as a reference point with interval endpoint value, in computation interval The corresponding linear function parameter value in each function section of acquisition is made look-up table and stored to lookup by the parameter value of linear function In table unit.
Assuming that the expression formula of linear function is y=ax+b, wherein a is slope, and b is y intercept.Function interval endpoint Expression formula is (x0, y0) and (x1, y1), then corresponding linear function parameter value a and b can be calculated.
For example, calculating function f (x)=x3Functional value in section [- 2,2].
Firstly, the computer capacity [- 2,2] of function is divided into several function sections.For example, function further can be drawn It is divided into four sections:
[- 2, -1), [- 1,0), [0,1), [1,2]
According to function f (x)=x3, then it can get the endpoint value in each section:
(- 2, -8, (- 1, -1), (0,0), (1,1), (2,8)
Secondly, calculating separately the function parameter value in corresponding function section using five endpoint values of above-mentioned acquisition and being made Look-up table, as shown in table 1.
The corresponding linear function Parameter lookup step in 1 different functions section of table
Section Parameter a Parameter b
[-2,-1) -7 6
[-1,0) 1 0
[0,1) 1 0
[1,2] -7 -6
In one embodiment of the invention, it is empty that the regularity of distribution of independent variable, look-up table can be considered in interval division method Between the factors such as size (such as memory capacity of look-up table) and calculating resolution (such as material calculation), for different function classes Type can use different interval division strategies according to its feature.For example, according to the degree of rarefication of function argument data, by this The computer capacity of function is divided into several sections, and calculates the endpoint value in each section.For example, can be in data-intensive part increase area Between division consistency, in Sparse part, the appropriate division interval for increasing section.
Assuming that in an application scenarios, nonlinear function f (x)=x2Independent variable computer capacity be:
- 23, -12, -5, -2, -1, -0.98, -0.97, -0.94, -0.90 ... ... -0.78, -0.71, -0.69, - 0.66 ... -0.08, -0.03, -0.02, -0.01,0.01,0.03,0.04,0.05 ... 0.64,0.67,0.71,0.74, 0.77,0.81 ... 0.91,0.94,0.95,0.98,1,5,7,18,34
By statistical analysis it is found that the computer capacity of above-mentioned independent variable distribution density in section [- 1,1] is larger, therefore, At partition function section, it can suitably increase the division density in section [- 1,1], it is linear in respective function section to improve It is fitted accuracy.
Fig. 1 is the computing device structure schematic diagram towards nonlinear function of present pre-ferred embodiments, which includes Matching unit, look-up table unit and computing unit.
Wherein, matching unit is used for receiver function variable input, and function variable input value is matched to corresponding letter Matching is obtained function section and exported to look-up table unit, while function variable input value is transmitted out computing unit by number interval. For example, function f (x)=x3Input value be 0.5, the input value can be matched to corresponding function section using matching unit is [0,1), meanwhile, matching unit exports input value 0.5 to computing unit, by function section [0,1) output is to look-up table unit.
Look-up table (such as table as composed by the section of nonlinear function and corresponding parameter is stored in look-up table unit 1), can be used for the parameter of the corresponding approximation linear function of function range lookup according to input, and by corresponding parameter export to Computing unit.For example, look-up table unit based on the received function section [0,1), search corresponding table 1 can be obtained function f (x)= x3Function section [0,1) in corresponding linear function parameter value be a=1, b=0, meanwhile, look-up table unit is by parameter value a =1, b=0 are exported to computing unit.
In one embodiment of the invention, the Parameter lookup step of multiple functions can be stored in look-up table unit, therefore, When the function section exported using matching unit carries out lookup relevant parameter, it is first determined the ginseng corresponding to the function to be calculated Number look-up table, then determines corresponding linear function parameter according to corresponding function section.
In one embodiment of the invention, the corresponding parameter in different functions section of multiple functions can be stored in one In look-up table, it is that label is added in the function section of same functions, is used to search.
In one embodiment of the invention, above-mentioned matching unit and look-up table unit can be merged into searching unit, it will The function section for dividing completion is fabricated to look-up table with corresponding function parameter and is stored in searching unit, utilizes function and function Variable input, it is after finding corresponding section and its corresponding function parameter value using searching unit, the function variable is defeated Enter value and corresponding function parameter value is exported to computing unit and calculated.Computing unit is according to from the received function of matching unit Variable input, and the calculating from the received linear function parameter completion linear function of look-up table unit.
Fig. 2 is the structural schematic diagram of the computing unit of present pre-ferred embodiments, as shown in Fig. 2, calculating list of the invention Member is made of multiplication unit and addition unit.Wherein, multiplication unit is used to receive the parameter a provided from above-mentioned look-up table unit The function variable input value x provided with above-mentioned matching unit, and parameter a and function variable input value x as multiplier and is multiplied Number carries out multiplication operation, obtains product p;Addition unit is used to receive the output result p from multiplication unit and comes from look-up table The parameter b that unit provides, and numerical value p is added with numerical value a, to obtain calculated result.
For example, computing unit is 0.5 from the received input value of matching unit, it is a=from the received parameter of look-up table unit 1, b=0, according to approximation linear function expression formula y=ax+b, input value 0.5 and parameter a=1 are subjected to multiplying first, obtained Carry out add operation to product p=0.5, then by product and parameter b=0, obtain the section [0,1) in nonlinear function f (x) =x3Input value 0.5 corresponding to approximation linear function value 0.5.
In one embodiment of the invention, computing unit uses the multiplier based on Booth encoding and realizes computing unit Multiplication operation, to solve the problems, such as that partial product excessively results in the need in multiplier adder increases.
Fig. 3 is the multiplier based on Booth encoding of one embodiment of the invention and the structural schematic diagram of adder, such as Fig. 3 Shown, which includes multiplier and adder, and wherein multiplier includes booth encoder unit, partial product calculating list Member, compression unit.
Booth encoding unit is used to carry out Booth encoding to the parameter of input.Assuming that the input value that computing unit receives is X, linear function parameter are respectively multiplication factor a and addition parameter b, then Booth encoding unit can by parameter a and input value x into Value after row Booth encoding is exported to partial product computing unit;
Partial product computing unit is used to receive the input value x and multiplication factor a of the output of Booth encoding unit, and generates part Calculated result is exported to compression unit after product.Such as the Booth encoding mode of base 4 can be used, partial product computing unit will connect Encoded for every three one group after the lowest order zero padding of the input value x (i.e. multiplier) after Booth encoding received, every two with Its low one group of composition is encoded, and an overlapping is had between every group, and specific Booth encoding indicates as shown in table 1:
Table 1: the Booth encoding table of base 4
Parameter 2 Parameter 1 Parameter 0 Partial product
0 0 0 0
0 0 1 X
0 1 0 X
0 1 1 2x
1 0 0 -2x
1 0 1 -x
1 1 0 -x
1 1 1 0
Wherein, parameter 2 and parameter 1 indicate two of current multiplicand, and parameter 0 indicates low two high positions.
Compression unit exports result to adder for being added partial product.For example, when computing unit is received defeated Enter to be worth bit wide be 8 when, Booth encoding unit to input value carry out Booth encoding when can be divided into four groups, in partial product computing unit When being calculated, every group can generate a partial product, and therefore, compression unit can choose 4-2 compressor and ask partial product With.
The calculated result and addition parameter b that adder is used to obtain from the compression unit of multiplier carry out add operation.
Fig. 4 is the method flow diagram that nonlinear function calculating is carried out using computing device shown in FIG. 1, as shown in figure 4, root According to one embodiment of the present of invention, provide a kind of nonlinear function calculation method, this method specifically includes the following steps:
S10, the computer capacity of nonlinear function is divided into several function sections;
S20, it calculates linear function parameter value corresponding to different sections and makes look-up table, look-up table is stored to lookup In table unit;
S30, nonlinear function variable input is matched to corresponding function section using matching unit, utilizes look-up table Unit searches linear function parameter value corresponding to respective function section;
S40, it is carried out using computing unit according to the input value of nonlinear function and the parameter value of corresponding linear function It calculates, such as Booth encoding is executed to the multiplication factor and the input value and generates partial product;The partial product is summed Add operation is executed with the addition parameter later and obtains calculated result.
In one embodiment of the invention, the S30 and S40 that can repeat the above steps is all until obtaining nonlinear function Linear function value corresponding to function section.
Although in the above-described embodiments, using having carried out for the Booth encoding mode of base four for example, ability Domain one of ordinary skill appreciates that, other various ways also can be used in Booth encoding herein, for example, the Booth encoding of base 16 Deng to realize binary multiplying.
Compared with the existing technology, in embodiments of the present invention provided by computing device towards nonlinear function and side The computer capacity of function, using the method for piecewise linearity, is divided into several sections, each using the thought of approximate calculation by method Functional value is calculated in section by the way of linear approximation, eliminates the power operation, division arithmetic and triangle letter of nonlinear function The complicated functions such as number operation calculate, and save circuit area overhead and energy loss.
Although the present invention has been described by means of preferred embodiments, the present invention is not limited to described here Embodiment, without departing from the present invention further include made various changes and variation.

Claims (8)

1. a kind of computing device towards nonlinear function, including
Searching unit corresponds to several sections and linear function parameter that different nonlinear functions are divided for storing, and For determining corresponding linear function parameter according to the nonlinear function and function variable input value;And
Computing unit, for being calculated using the input value and the corresponding linear function parameter;
Wherein, the linear function parameter includes multiplication factor and addition parameter;The searching unit includes for will be non-linear The input value of function is matched to the matching unit in corresponding function section, and corresponding for being determined according to the function section The look-up table unit of the linear function parameter;And
The function section is according to the regularity of distribution of function argument or the space size of look-up table or calculating resolution At least one of divide.
2. computing device according to claim 1, which is characterized in that the computing unit includes for the input value The multiplier of multiplying is executed with the multiplication factor.
3. computing device according to claim 2, which is characterized in that the multiplier is the multiplication based on Booth encoding Device.
4. computing device according to claim 3, which is characterized in that the multiplier based on Booth encoding includes
Booth encoding unit, for carrying out Booth encoding to input value and multiplier parameters;
Partial product computing unit, for calculating section product;And
Compression unit for the partial product to be added, and obtains the output valve of the multiplier.
5. computing device according to claim 4, which is characterized in that the Booth encoding unit uses the Buss of base four Coding mode.
6. computing device according to claim 5, which is characterized in that the computing unit further includes for the multiplication The output valve of device and the addition parameter execute the adder of add operation.
7. a kind of calculation method towards nonlinear function, comprising the following steps:
The multiplication factor and addition parameter of the corresponding linear function in the function section are calculated using the endpoint in the function section And save as look-up table;Wherein, several sections divided corresponding to different nonlinear functions are also stored in the look-up table With linear function parameter;
The corresponding function section of input value for searching the nonlinear function using the look-up table and the linear letter Several multiplication factors and addition parameter;
It is carried out using the input value of the nonlinear function and the multiplication factor and addition parameter of the corresponding linear function It calculates;
Wherein, the function section is according to the regularity of distribution of function argument or the space size of look-up table or calculating point What at least one of resolution divided.
8. calculation method according to claim 7, further comprising the steps of:
Booth encoding is executed to the multiplication factor and the input value and generates partial product;
Add operation will be executed with the addition parameter after partial product summation and obtain calculated result.
CN201710777378.6A 2017-09-01 2017-09-01 Computing device and method towards nonlinear function Active CN107590105B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710777378.6A CN107590105B (en) 2017-09-01 2017-09-01 Computing device and method towards nonlinear function

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710777378.6A CN107590105B (en) 2017-09-01 2017-09-01 Computing device and method towards nonlinear function

Publications (2)

Publication Number Publication Date
CN107590105A CN107590105A (en) 2018-01-16
CN107590105B true CN107590105B (en) 2019-02-01

Family

ID=61050714

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710777378.6A Active CN107590105B (en) 2017-09-01 2017-09-01 Computing device and method towards nonlinear function

Country Status (1)

Country Link
CN (1) CN107590105B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108920748B (en) * 2018-05-22 2023-01-06 复旦大学 Nonlinear operation circuit structure with high flexibility and precision

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1741394A (en) * 2005-09-16 2006-03-01 北京中星微电子有限公司 Method for computing nonlinear function in inverse quantization formula
CN102354111A (en) * 2011-07-14 2012-02-15 哈尔滨工业大学 Working fluid level prediction-based optimization method for stroke frequency of submersible reciprocating oil pumping unit
CN105468335A (en) * 2015-11-24 2016-04-06 中国科学院计算技术研究所 Pipeline-level operation device, data processing method and network-on-chip chip

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2666067B1 (en) * 2011-01-21 2020-05-13 NXP USA, Inc. Device and method for computing a function value of a function

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1741394A (en) * 2005-09-16 2006-03-01 北京中星微电子有限公司 Method for computing nonlinear function in inverse quantization formula
CN102354111A (en) * 2011-07-14 2012-02-15 哈尔滨工业大学 Working fluid level prediction-based optimization method for stroke frequency of submersible reciprocating oil pumping unit
CN105468335A (en) * 2015-11-24 2016-04-06 中国科学院计算技术研究所 Pipeline-level operation device, data processing method and network-on-chip chip

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
基于Radix-4 Booth编码的模2n+1乘法器设计;鄢斌;《通信技术》;20151031;第48卷(第10期);第1-3节 *
定点参考独立分量分析算法的FPGA实现;王佑锋;《中国优秀硕士学位论文全文数据库 信息科技辑》;20090515(第05期);中国优秀硕士学位论文全文数据库 信息科技辑 *
王佑锋.定点参考独立分量分析算法的FPGA实现.《中国优秀硕士学位论文全文数据库 信息科技辑》.2009,(第05期),中国优秀硕士学位论文全文数据库 信息科技辑. *

Also Published As

Publication number Publication date
CN107590105A (en) 2018-01-16

Similar Documents

Publication Publication Date Title
CN107589935A (en) A kind of nonlinear function computing device and method
CN107729984A (en) A kind of computing device and method suitable for neutral net activation primitive
TWI701612B (en) Circuit system and processing method for neural network activation function
CN105955706B (en) A kind of divider and division operation method
CN106990937A (en) A kind of floating number processing unit
Lin et al. A digital circuit design of hyperbolic tangent sigmoid function for neural networks
CN110362292A (en) A kind of approximate multiplying method based on approximate 4-2 compressor and approximate multiplier
CN113038302B (en) Flow prediction method and device and computer storage medium
CN105005029B (en) Multi-mode radar signal sorting method based on data field hierarchical clustering
CN112051980B (en) Non-linear activation function computing device based on Newton iteration method
CN110852434A (en) CNN quantization method, forward calculation method and device based on low-precision floating point number
CN106940689A (en) High-precision Eigenvalue Decomposition implementation method based on Jacobi iterative algorithms
CN109308520A (en) Realize the FPGA circuitry and method that softmax function calculates
CN107590105B (en) Computing device and method towards nonlinear function
Garg et al. Reconfigurable rounding based approximate multiplier for energy efficient multimedia applications
CN104731762B (en) Cube phase modulated parameter estimating method based on cyclic shift
CN103809931A (en) Design of dedicated high-speed floating point index arithmetic unit
CN110222305A (en) A kind of logarithmic function computing system and method based on hyperbolic CORDIC
Micchelli et al. On computing with the Hilbert spline transform
CN110837624A (en) Approximate calculation device for sigmoid function
Yuan et al. Image segmentation based on modified superpixel segmentation and spectral clustering
Trejo-Arellano et al. Adaptive segmentation methodology for hardware function evaluators
CN108268982A (en) A kind of extensive active power distribution network decomposition strategy evaluation method and device
Rao et al. Efficient Design of Rounding-Based Approximate Multiplier Using Modified Karatsuba Algorithm
Lei et al. Critical conditions and asymptotics for discrete systems of the Hardy-Littlewood-Sobolev type

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230104

Address after: 518063 14th Floor, West Tower, Baidu International Building, No. 8, Haitian 1st Road, Binhai Community, Yuehai Street, Nanshan District, Shenzhen, Guangdong

Patentee after: Zhongke Times (Shenzhen) Computer System Co.,Ltd.

Address before: 100190 No. 6 South Road, Zhongguancun Academy of Sciences, Beijing, Haidian District

Patentee before: Institute of Computing Technology, Chinese Academy of Sciences