Neural network computation device and method
AssigneeCambricon Technologies Corporation Limited
InventorsXiaofu Meng, Haochong Zhang
Life of this patent
Estimating the term…
Abstract
The present disclosure provides a neural network computation device and a neural network computation method. The device is configured to perform artificial neural network training operations including neural network multi-layer training operations. The present disclosure has technical effects of low cost and low energy consumption.
Claims12
A neural network computation device configured to perform neural network operations of a floating point data type, comprising:
- a controller unit and an operation unit, wherein
- the controller unit and the operation unit are connected;
- the controller unit is configured to obtain initial input neuron data of an ith layer of a neural network model of the floating point data type and a computational instruction of the ith layer, parse the computational instruction of the ith layer to obtain a plurality of operation instructions, send the initial input neuron data of the ith layer to the operation unit, and send the plurality of operation instructions to the operation unit, wherein i is a positive integer;
- the operation unit is configured to compute the initial input neuron data of the ith layer, and compute conversion parameters of an ith layer of a neural network model of a fixed point data type according to the initial input neuron data of the ith layer;
- and
- the controller unit is further configured to write the conversion parameters of the ith layer of the neural network model of the fixed point data type into the ith layer of the neural network model of the floating point data type,
- wherein regarding the computing the conversion parameters of the ith layer of the neural network model of the fixed point data type according to the initial input neuron data of the ith layer, the operation unit is configured to compute the conversion parameters of the ith layer of the neural network model of the fixed point data type according to the following formula:
- if the conversion parameters only include a value of a decimal point position of a fixed point number, the computation formula is:
- a value of a floating point number=a value of a fixed point number×2{circumflex over ( )}position,
- or
- if the conversion parameters only include a value of a scale factor, the computation formula is:
- a value of a floating point number=a value of a fixed point number×scale,
- or
- if the conversion parameters include a position value and a scale factor value, the computation formula is:
- a value of a floating point number=(a value of a fixed point number×2{circumflex over ( )}position)/scale,
- wherein position denotes the decimal point position of a fixed point number, and scale denotes the scale factor.
A neural network computation method applied to a neural network computation device, wherein the device is configured to perform artificial neural network operations of a floating point data type and includes a controller unit and an operation unit, and the method includes:
- obtaining, by the controller unit, initial input neuron data of an ith layer of a neural network model of the floating point data type and a computational instruction of the ith layer, parsing the computational instruction of the ith layer to obtain a plurality of operation instructions, sending the initial input neuron data of the ith layer to the operation unit, and sending the plurality of operation instructions to the operation unit, wherein i is a positive integer;
- computing, by the operation unit, the initial input neuron data of the ith layer, and computing conversion parameters of an ith layer of a neural network model of a fixed point data type according to the initial input neuron data of the ith layer;
- and
- writing, by the controller unit, the conversion parameters of the ith layer of the neural network model of the fixed point data type into the ith layer of the neural network model of the floating point data type,
- wherein the computing the conversion parameters of the ith layer of the neural network model of the fixed point data type according to the initial input neuron data of the ith layer further includes:
- computing the conversion parameters of the ith layer of the neural network model of the fixed point data type according to the following formula:
- if the conversion parameters only include a value of a decimal point position of a fixed point number, the computation formula is:
- a value of a floating point number=a value of a fixed point number×2{circumflex over ( )}position,
- or
- if the conversion parameters only include a value of a scale factor, the computation formula is:
- a value of a floating point number=a value of a fixed point number×scale,
- or
- if the conversion parameters include a position value and a scale factor value, the computation formula is:
- a value of a floating point number=(a value of a fixed point number×2{circumflex over ( )}position)/scale,
- wherein position denotes the decimal point position of a fixed point number, and scale denotes the scale factor.
Dependencies are inferred from the claim text.