A computing device and method

By converting input data into fixed-point data for calculation in the computing device, the problem of low efficiency of general-purpose processors in information processing is solved, and faster calculation speed and higher accuracy are achieved.

CN110276447BActive Publication Date: 2024-09-24SHANGHAI CAMBRICON INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201810207915.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-03-14
Publication Date
2024-09-24
Estimated Expiration
2039-09-24

AI Technical Summary

Technical Problem

When running software programs based on general-purpose processors to process information, the efficiency is low and the delay is large, especially under heavy loads, which affects the calculation speed of the training model.

Method used

A computing device is designed, including an arithmetic unit, a controller unit and a storage unit. By converting input data into fixed-point data for calculation, floating-point data results are obtained, which improves the calculation speed and saves data transmission bandwidth.

Benefits of technology

The efficiency and speed of information processing are improved, especially in training operations, the completion time is significantly shortened and the accuracy of calculation results is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110276447B
    Figure CN110276447B
Patent Text Reader

Abstract

The present application provides a computing device, which is used to perform calculations on a network model, the network model including a neural network model and / or a non-neural network model; the computing device includes: a storage unit for obtaining at least one input data, a network model, and a computing instruction; a controller unit for extracting the computing instruction from the storage unit, decoding the computing instruction to obtain one or more operation instructions, and sending the one or more operation instructions and at least one input data to the computing unit; and a computing unit for performing calculations on at least one input data according to the one or more operation instructions to obtain the result of the calculation instruction. The embodiment of the present invention uses fixed-point data to represent the data involved in the network model calculation, which can improve the processing speed and efficiency of the training operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of information processing technology, and in particular to a computing device and method. Background Art

[0002] With the continuous development of information technology and people's growing needs, people have higher and higher requirements for information timeliness. At present, the acquisition and processing of information by terminals are all based on general-purpose processors.

[0003] In practice, it is found that this method of processing information by running software programs based on a general-purpose processor is limited by the operating speed of the general-purpose processor. In particular, when the general-purpose processor is overloaded, the information processing efficiency is low and the latency is large. For information processing computational models such as training models, the training operations require more computational effort, and the general-purpose processor takes a long time to complete the training operations, resulting in low efficiency.

[0004] Application Contents

[0005] The embodiments of the present application provide a computing device and method, which can increase the processing speed of operations and improve efficiency.

[0006] In a first aspect, an embodiment of the present invention provides a computing device, the computing device is used to perform calculations of a network model, the network model includes: a neural network model and / or a non-neural network model; the computing device includes: a computing unit, a controller unit and a storage unit, the storage unit includes: a data input and output unit;

[0007] The data input and output unit is used to obtain at least one input data, a network model and a calculation instruction, wherein the at least one input data is fixed-point data;

[0008] The controller unit is configured to extract the computing instruction from the storage unit, decode the computing instruction to obtain one or more computing instructions, and send the one or more computing instructions and the at least one input data to the computing unit;

[0009] The computing unit is used to perform calculations on the at least one input data according to the one or more computing instructions to obtain a result of the computing instruction, where the result of the computing instruction is floating-point data.

[0010] In a feasible embodiment, the storage unit further includes:

[0011] A storage medium, used for storing the network model and the at least one input data;

[0012] The scalar data storage unit is used to store scalar data.

[0013] In a feasible embodiment, the controller unit includes:

[0014] An instruction cache unit, used to store computing instructions associated with the network model;

[0015] An instruction processing unit, configured to decode the computing instruction pair to obtain the one or more operation instructions;

[0016] The storage queue unit is used to store an instruction queue, which includes one or more operation instructions or calculation instructions to be executed in a front-to-back order of the queue.

[0017] In a feasible embodiment, the data input and output unit further obtains a data conversion instruction, the data conversion instruction includes an operation field and an operation code, the operation code is used to indicate the function of the data conversion instruction, and the operation field of the data conversion instruction includes a decimal point position of the input data and a conversion method identifier of the data type;

[0018] The controller unit also includes:

[0019] The instruction processing unit is further used to parse the data conversion instruction to obtain the decimal point position of the input data and the conversion mode identifier of the data type when the at least one input data is floating point data;

[0020] A data conversion unit is used to convert the at least one input data into fixed-point data according to the decimal point position of the input data and the conversion mode identifier of the data type.

[0021] In a feasible embodiment, the computing unit includes:

[0022] a dependency processing unit, configured to determine whether a first operation instruction has an association relationship with a zeroth operation instruction before the first operation instruction, and if the first operation instruction has an association relationship with the zeroth operation instruction, cache the first operation instruction in the instruction storage unit, and extract the first operation instruction from the instruction storage unit and transmit it to the operation unit after the zeroth operation instruction is executed;

[0023] The determining whether the first operation instruction has an association relationship with the zeroth operation instruction before the first operation instruction comprises:

[0024] Extracting a first storage address interval of data required in the first operation instruction according to the first operation instruction, and extracting a zeroth storage address interval of data required in the zeroth operation instruction according to the zeroth operation instruction, and if the first storage address interval and the zeroth storage address interval have an overlapping area, determining that the first operation instruction and the zeroth operation instruction have an associated relationship, and if the first storage address interval and the zeroth storage address interval do not have an overlapping area, determining that the first operation instruction and the zeroth operation instruction do not have an associated relationship;

[0025] The first operation instruction and the zeroth operation instruction are any two of the multiple operation instructions.

[0026] In a feasible embodiment, the computing unit includes: a plurality of computing modules, wherein the plurality of computing modules are used to perform calculations of n pipeline stages;

[0027] The operation unit is specifically used to perform a first pipeline stage calculation on the at least one input data to obtain a first intermediate result, input the first intermediate result to the second pipeline stage to perform the second pipeline stage calculation to obtain a second intermediate result, ..., input the n-1th intermediate result to the nth pipeline stage to perform the nth pipeline stage calculation to obtain an nth intermediate result, and input the nth intermediate result to the storage unit, where n is an integer greater than or equal to 3.

[0028] In a feasible embodiment, the controller unit sends the decimal point position of the at least one input data to the operation unit, and the operation unit further includes:

[0029] A derivation unit is configured to derive a decimal point position of one or more intermediate results according to a decimal point position of the at least one input data.

[0030] In a feasible embodiment, the computing unit further includes:

[0031] A data cache unit is used to cache the one or more intermediate results.

[0032] In a feasible embodiment, the computing unit includes a main processing circuit, a branch processing circuit and a plurality of slave processing circuits.

[0033] The main processing circuit is used to distribute the input data A into multiple data blocks, and send at least one data block of the multiple data blocks and a calculation instruction for the input data A to the branch processing circuit, wherein the input data A is any one of the at least one input data;

[0034] The branch processing circuit is used to forward data between the main processing circuit and the plurality of slave processing circuits;

[0035] The plurality of slave processing circuits are used to perform operations on the received data blocks according to the operation instruction to obtain at least one intermediate result, and transmit the at least one intermediate result to the branch processing circuit;

[0036] The main processing circuit is used to process at least one intermediate result sent by the branch processing circuit to obtain a result of the calculation instruction, and send the result of the calculation instruction to the controller unit;

[0037] Wherein, the at least one intermediate result is floating point data.

[0038] In a feasible embodiment, the computing unit includes a master processing circuit and a plurality of slave processing circuits;

[0039] The multiple slave processing circuits are distributed in an array; each slave processing circuit is connected to other adjacent slave processing circuits, and the master processing circuit is connected to K slave processing circuits among the multiple slave processing circuits, and the K slave processing circuits are: n slave processing circuits in the first row, n slave processing circuits in the mth row, and m slave processing circuits in the first column;

[0040] The K slave processing circuits are used to forward data and instructions between the master processing circuit and the plurality of slave processing circuits;

[0041] The master processing circuit is used to distribute the input data A into multiple data blocks, and send at least one data block among the multiple data blocks and a calculation instruction for the input data A to participate in the calculation to the K slave processing circuits, wherein the input data A is any one of the at least one input data;

[0042] The K slave processing circuits are used to convert data between the master processing circuit and the plurality of slave processing circuits;

[0043] The multiple slave processing circuits are used to perform operations on the received data blocks according to the operation instruction to obtain at least one intermediate result, and transmit the at least one intermediate result to the K slave processing circuits;

[0044] The main processing circuit is used to process at least one intermediate result sent by the K slave processing circuits to obtain a result of the calculation instruction, and send the result of the calculation instruction to the controller unit;

[0045] Wherein, the at least one intermediate result is floating point data.

[0046] In a feasible embodiment, the main processing circuit is specifically used to combine and sort the intermediate results sent by multiple processing circuits to obtain the result of the calculation instruction;

[0047] Or the main processing circuit is specifically used to combine and sort the intermediate results sent by multiple processing circuits and obtain the result of the calculation instruction after activation processing.

[0048] In a feasible embodiment, the main processing circuit includes: one or any combination of a conversion processing circuit, an activation processing circuit, and an addition processing circuit;

[0049] The conversion processing circuit is used to perform an exchange between a first data structure and a second data structure on a data block or an intermediate result received by the main processing circuit; or to perform an exchange between a first data type and a second data type on a data block or an intermediate result received by the main processing circuit;

[0050] The activation processing circuit is used to perform activation operations on data in the main processing circuit;

[0051] The addition processing circuit is used to perform addition operation or accumulation operation.

[0052] In a feasible embodiment, the slave processing circuit includes: a multiplication processing circuit;

[0053] The multiplication processing circuit is used to perform a multiplication operation on the received data block to obtain a product result.

[0054] In a feasible embodiment, the slave processing circuit further includes: an accumulation processing circuit, and the accumulation processing circuit is used to perform an accumulation operation on the product result to obtain the intermediate result.

[0055] In a second aspect, an embodiment of the present invention provides a calculation method, the method is used to perform calculations on a network model, the network model includes: a neural network model and / or a non-neural network model, the method includes:

[0056] Acquire at least one input data, the network model and a calculation instruction, wherein the at least one input data is fixed-point data;

[0057] Decoding the computing instruction to obtain one or more operation instructions;

[0058] The at least one input data is calculated according to the one or more operation instructions to obtain a result of the calculation instruction, where the result of the calculation instruction is floating-point data.

[0059] In a feasible embodiment, when the at least one input data is floating point data, the method further includes:

[0060] Acquire a data conversion instruction, the data conversion instruction including an operation code and an operation field, the operation code is used to indicate a function of the data conversion instruction, and the operation field includes a decimal point position of input data and a conversion mode identifier of a data type;

[0061] Parsing the data conversion instruction to obtain a conversion method identifier of a decimal point position and a data type of the input data;

[0062] The at least one input data is converted into fixed-point data according to the decimal point position of the input data and the conversion mode identifier of the data type.

[0063] In a feasible embodiment, performing calculation on the at least one input data according to the one or more operation instructions to obtain a result of the calculation instruction includes:

[0064] The second input data is operated according to the one or more operation instructions to obtain one or more intermediate results, wherein the last intermediate result of the one or more intermediate results is the result of the calculation instruction;

[0065] When the last intermediate result is fixed-point data, the last intermediate result is converted into floating-point data according to the decimal point position of the last intermediate result.

[0066] In a feasible embodiment, the method further includes:

[0067] The decimal point position of the one or more intermediate results is derived according to the decimal point position of the at least one input data.

[0068] In a third aspect, an embodiment of the present invention provides a neural network computing device, which includes one or more computing devices described in the first aspect. The neural network computing device is used to obtain data to be computed and control information from other processing devices, and perform specified neural network operations, and transmit the execution results to other processing devices through an input / output (I / O) interface;

[0069] When the neural network computing device includes a plurality of computing devices, the plurality of computing devices may be linked and transmit data through a specific structure;

[0070] Among them, multiple computing devices are interconnected and transmit data through a high-speed serial computer expansion bus standard peripheral component interconnect express (PCIE) bus to support larger-scale neural network operations; multiple computing devices share the same control system or have their own control systems; multiple computing devices share memory or have their own memory; the interconnection method of multiple computing devices is any interconnection topology.

[0071] In a fourth aspect, an embodiment of the present invention provides a combined processing device, which includes the neural network processing device, the universal interconnection interface, and other processing devices as described in the third aspect. The neural network operation device interacts with the above-mentioned other processing devices to jointly complete the operation specified by the user. The combined processing device may also include a storage device, which is respectively connected to the neural network operation device and the other processing device, and is used to store data of the neural network operation device and the other processing device.

[0072] In a fifth aspect, an embodiment of the present invention provides a neural network chip, which includes the computing device described in the first aspect, the neural network computing device described in the third aspect, or the combined processing device described in the fourth aspect.

[0073] In a sixth aspect, an embodiment of the present invention provides a neural network chip packaging structure, wherein the neural network chip packaging structure includes the neural network chip described in the fifth aspect above;

[0074] In a seventh aspect, an embodiment of the present invention provides a board card, which includes the neural network chip packaging structure described in the sixth aspect.

[0075] In an eighth aspect, an embodiment of the present invention provides an electronic device, which includes the neural network chip described in the sixth aspect or the board described in the seventh aspect.

[0076] In some embodiments, the electronic device includes a data processing device, a robot, a computer, a printer, a scanner, a tablet computer, a smart terminal, a mobile phone, a driving recorder, a navigator, a sensor, a camera, a server, a cloud server, a camera, a camcorder, a projector, a watch, a headset, a mobile storage, a wearable device, a vehicle, a household appliance, and / or a medical device.

[0077] In some embodiments, the means of transportation include airplanes, ships and / or vehicles; the household appliances include televisions, air conditioners, microwave ovens, refrigerators, rice cookers, humidifiers, washing machines, electric lights, gas stoves, and range hoods; the medical equipment includes magnetic resonance imaging, ultrasound equipment and / or electrocardiographs.

[0078] It can be seen that in the scheme of the embodiment of the present application, the computing device includes: a storage unit including: a data input and output unit, the data input and output unit obtains at least one input data, a network model and a computing instruction, and the at least one input data is fixed-point data; a controller unit extracts the computing instruction from the storage unit, parses the computing instruction to obtain one or more operation instructions, and sends the multiple operation instructions and at least one input data to the operation unit; performs calculations on at least one input data according to one or more operation instructions to obtain the result of the calculation instruction, which is floating-point data. The embodiment of the present invention uses fixed-point data to represent the data involved in the network model calculation, and then performs fixed-point operations, and finally obtains the result of the calculation instruction represented by floating-point data, thereby improving the processing speed of the training operation and saving the bandwidth of data transmission. BRIEF DESCRIPTION OF THE DRAWINGS

[0079] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0080] Figure 1 A data structure diagram of fixed-point data is provided for an embodiment of the present application;

[0081] Figure 2 A data structure diagram of another fixed-point data is provided for an embodiment of the present application;

[0082] Figure 3A is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;

[0083] Figure 3B is a schematic diagram of the structure of a computing device provided by an embodiment of the present application;

[0084] Figure 3C is a schematic diagram of the structure of a computing device provided by another embodiment of the present application;

[0085] Figure 3D is a structural diagram of a main processing circuit provided in an embodiment of the present application;

[0086] Figure 3E is a structural diagram of a main processing circuit provided in an embodiment of the present application;

[0087] Figure 3F is a structural diagram of a main processing circuit provided in an embodiment of the present application;

[0088] Figure 4A single-layer artificial neural network forward operation flow chart provided in an embodiment of the present application;

[0089] Figure 5 A flowchart of a neural network forward operation and reverse training provided in an embodiment of the present application;

[0090] Figure 6 is a structural diagram of a combined processing device provided in an embodiment of the present application;

[0091] Figure 7 is a structural diagram of another combined processing device provided in an embodiment of the present application;

[0092] Figure 8 A flowchart of a calculation method provided in an embodiment of the present application;

[0093] Fig. 9 A schematic diagram of a process for determining and adjusting the decimal point position of data provided in an embodiment of the present application;

[0094] Fig.10 A schematic diagram of another structure of fixed-point data provided in an embodiment of the present application;

[0095] Fig.11 A schematic diagram of another structure of fixed-point data provided in an embodiment of the present application;

[0096] Fig.12 A schematic diagram of the structure of a distributed system provided in an embodiment of the present application;

[0097] Fig.13 A schematic diagram of the structure of another distributed system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0098] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0099] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0100] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0101] First, we introduce the structure of fixed-point data. Figure 1 , Figure 1 A data structure diagram of fixed-point data is provided for an embodiment of the present application. Figure 1 The fixed-point data with a sign shown in the figure occupies X bits, and the fixed-point data can also be called X-bit fixed-point data. The X-bit fixed-point data includes a sign bit of 1 bit, an integer bit of M bits, and a decimal bit of N bits, X-1=M+N. For unsigned fixed-point data, it only includes an integer bit of M bits and a decimal bit of N bits, that is, X=M+N.

[0102] Compared with the 32-bit floating-point data representation, the short-bit fixed-point data representation adopted by the present invention not only occupies fewer bits, but also sets a flag to record the decimal point position of the fixed-point data for the same layer and the same type of data in the network model, such as all convolution kernels, input neurons or bias data of the first convolution layer. The flag is Point Location. In this way, the size of the flag can be adjusted according to the distribution of the input data, thereby adjusting the precision of the fixed-point data and the representable range of the fixed-point data.

[0103] See also Figure 3A , Figure 3A A schematic diagram of a computing device is provided for the implementation of the present application, the computing device comprising: a storage unit 10, a controller unit 11 and a computing unit 12, wherein the controller unit 11 is connected to the storage unit 10 and the computing unit 12;

[0104] The storage unit 10 may include: a data I / O unit 203,

[0105] The data I / O unit 203 is used to obtain at least one input data, a network model and a calculation instruction.

[0106] Optionally, the storage unit 10 may further include: a storage medium 201 and a scalar data storage unit 202

[0107] The storage medium 201 can be an off-chip memory, and of course in practical applications, it can also be an on-chip memory for storing data blocks, which can specifically be n-dimensional data, where n is an integer greater than or equal to 1. For example, when n=1, it is 1-dimensional data, i.e., a vector; when n=2, it is 2-dimensional data, i.e., a matrix; and when n=3 or more, it is a multi-dimensional tensor.

[0108] The scalar data storage unit 202 is used to store scalar data.

[0109] The controller unit 11 is used to extract the above-mentioned calculation instructions from the storage unit 10, and parse the calculation instructions to obtain one or more operation instructions.

[0110] Wherein, the controller unit 11 comprises:

[0111] An instruction cache unit, used to store computing instructions related to the above network model;

[0112] An instruction processing unit, used for decoding the above-mentioned calculation instruction to obtain one or more operation instructions;

[0113] The storage queue unit is used to store an instruction queue, which includes one or more operation instructions or calculation instructions to be executed in a front-to-back order of the queue.

[0114] It should be noted that the above-mentioned operation instructions can be regarded as microinstructions, that is, the above-mentioned controller unit decodes the above-mentioned calculation instructions to obtain one or more microinstructions.

[0115] In a feasible embodiment, the embodiment of the present application also includes a data type, and the data type includes an adjustment factor, and the adjustment factor is used to indicate the value range and precision of the data type.

[0116] The adjustment factor includes a first scaling factor and a second scaling factor (optionally), wherein the first scaling factor is used to indicate the precision of the data type; and the second scaling factor is used to adjust the value range of the data type.

[0117] Optionally, the first scaling factor may be 2 -m , 8 -m , 10 -m , 2, 3, 6, 9, 10, 2 m , 8 m , 10 m or other values.

[0118] Specifically, the first scaling factor may be the decimal point position. For example, the decimal point position of the input data INA1 represented in binary is shifted to the right by m bits to obtain the input data INB1=INA1*2 m, that is, the input data INB1 is amplified by 2 relative to the input data INA1 m times; for another example, the decimal point of the input data INA2 expressed in decimal is shifted to the left by n places to obtain the input data INB2 = INA2 / 10 n , that is, the input data INA2 is reduced by 10 relative to the input data INB2 n times, m and n are both integers.

[0119] Optionally, the second scaling factor may be 2, 8, 10, 16 or other values.

[0120] For example, the data type corresponding to the above input data has a value range of 8 -15 -8 16 During the operation, if the result is greater than the maximum value of the value range of the data type corresponding to the input data, the value range of the data type is multiplied by the second scaling factor of the data type (i.e. 8) to obtain a new value range of 8. -14 -8 17 ; When the above operation result is less than the minimum value corresponding to the value range of the data type corresponding to the above input data, the value range of the data type is divided by the second scaling factor (8) of the data type to obtain a new value range of 8 -16 -8 15 .

[0121] It should be noted that the decimal point position mentioned below in the specification of this application can all be the above-mentioned first scaling factor, which will not be described here.

[0122] In a feasible embodiment, the at least one input data includes first input data and second input data, the first input data is data whose data type is inconsistent with the operation type indicated by the operation instruction involved in the operation, and the second input data is data whose data type is consistent with the operation type indicated by the operation instruction involved in the operation, and the data input and output unit further obtains a data conversion instruction, the data conversion instruction includes an operation code and an operation domain, the operation code is used to indicate the function of the data conversion instruction, and the operation domain includes a decimal point position and a conversion method identifier of the data type. The data conversion unit converts the first input data into the second input data according to the decimal point position and the conversion method identifier of the data type.

[0123] In a feasible embodiment, the controller unit further includes a data statistics unit, and the network model includes different layers, such as a fully connected layer, a convolutional layer, and a pooling layer. The operation result of the previous layer is the input data of the next layer. The at least one data can be divided into different types of data or different layers of data, and the data statistics unit of the controller unit performs statistics on the same type of data or the same layer of data, and determines the bit width and decimal point position of the same type of data or the same layer of data according to the absolute maximum value of the same type of data or the same layer of data.

[0124] Optionally, the data statistics unit of the above-mentioned controller unit can determine the bit width and decimal point position of the data of the same type or the same layer according to the median value of the above-mentioned data of the same type or the same layer, or determine the bit width and decimal point position of the data of the same type or the same layer according to the average value of the above-mentioned data of the same type or the same layer.

[0125] Optionally, when the intermediate result obtained by the above-mentioned operation unit based on the operation on the above-mentioned data of the same type or the same layer of data exceeds the value range corresponding to the decimal point position and the bit width of the data of the same layer type or the same layer of data, the operation unit does not truncate the intermediate result, and caches the intermediate result in the data cache unit of the operation unit for subsequent operations.

[0126] Specifically, the operation domain includes a conversion method identifier of a decimal point position and a data type of the input data. The instruction processing unit parses the data conversion instruction to obtain a conversion method identifier of a decimal point position and a data type of the input data. The controller unit also includes a data conversion unit, which converts the first input data into the second input data according to the conversion method identifier of the decimal point position and the data type of the input data.

[0127] It should be noted that the above network model includes multiple layers, such as a fully connected layer, a convolutional layer, a pooling layer and an input layer. In the above at least one input data, the input data belonging to the same layer have the same decimal point position, that is, the input data of the same layer share or share the same decimal point position.

[0128] The at least one input data includes different types of data, such as input neurons, weights and bias data. The input data of the same type in the at least one input data have the same decimal point position, that is, the input data of the same type share or share the same decimal point position.

[0129] For example, if the operation type indicated by the operation instruction is fixed-point operation, and the input data involved in the operation indicated by the operation instruction is floating-point data, then before performing the fixed-point operation, the above-mentioned number conversion unit converts the input data from floating-point data to fixed-point data; for another example, if the operation type indicated by the operation instruction is floating-point operation, and the input data involved in the operation indicated by the operation instruction is fixed-point data, then before performing the floating-point operation, the above-mentioned data conversion unit converts the input data corresponding to the above-mentioned operation instruction from fixed-point data to floating-point data.

[0130] For the macroinstructions involved in this application (such as calculation instructions and data conversion instructions), the above-mentioned controller unit can parse the macroinstructions to obtain the operation domain and operation code of the macroinstructions; generate microinstructions corresponding to the macroinstructions based on the operation domain and operation code; or, the above-mentioned controller unit decodes the macroinstructions to obtain microinstructions corresponding to the macroinstructions.

[0131] Specifically, the conversion method identifiers of the above data types correspond to the conversion methods of the above data types. See Table 1 below, which is a correspondence table of a feasible conversion method identifier of a data type and the conversion method of the data type.

[0132] Data type conversion method identifier How to convert data types 0000 Convert 64-bit fixed-point data to 64-bit floating-point data 0001 Convert 32-bit fixed-point data to 64-bit floating-point data 0010 Convert 16-bit fixed-point data to 64-bit floating-point data 0011 Convert 32-bit fixed-point data to 32-bit floating-point data 0100 Convert 16-bit fixed-point data to 32-bit floating-point data 0101 Convert 16-bit fixed-point data to 16-bit floating-point data 0110 Convert 64-bit floating point data to 64-bit fixed point data 0111 Convert 32-bit floating point data to 64-bit fixed point data 1000 Convert 16-bit floating point data to 64-bit fixed point data 1001 Convert 32-bit floating point data to 32-bit fixed point data 1010 Convert 16-bit floating point data to 32-bit fixed point data 1011 Convert 16-bit floating point data to 16-bit fixed point data

[0133] Table 1

[0134] As shown in Table 1, when the conversion method of the above data type is identified as 0000, the conversion method of the above data type is 64-bit fixed-point data converted to 64-bit floating-point data; when the conversion method of the above data type is identified as 0001, the conversion method of the above data type is 32-bit fixed-point data converted to 64-bit floating-point data; when the conversion method of the above data type is identified as 0010, the conversion method of the above data type is 16-bit fixed-point data converted to 64-bit floating-point data; when the conversion method of the above data type is identified as 0011, the conversion method of the above data type is 32-bit fixed-point data converted to 32-bit floating-point data; when the conversion method of the above data type is identified as 0100, the conversion method of the above data type is 16-bit fixed-point data converted to 32-bit floating-point data; when the conversion method of the above data type is identified as 0101, the conversion method of the above data type is 16-bit fixed-point data converted to 16-bit floating-point data. data; when the conversion mode of the above data type is identified as 0110, the conversion mode of the above data type is 64-bit floating-point data converted to 64-bit fixed-point data; when the conversion mode of the above data type is identified as 0111, the conversion mode of the above data type is 32-bit floating-point data converted to 64-bit fixed-point data; when the conversion mode of the above data type is identified as 1000, the conversion mode of the above data type is 16-bit floating-point data converted to 64-bit fixed-point data; when the conversion mode of the above data type is identified as 1001, the conversion mode of the above data type is 32-bit floating-point data converted to 32-bit fixed-point data; when the conversion mode of the above data type is identified as 1010, the conversion mode of the above data type is 16-bit floating-point data converted to 32-bit fixed-point data; when the conversion mode of the above data type is identified as 1011, the conversion mode of the above data type is 16-bit floating-point data converted to 16-bit fixed-point data.

[0135] Specifically, the data conversion unit determines the conversion method of the data type according to the conversion method identifier of the data type, and then converts the first input data into the second input data according to the conversion method of the data type and the decimal point position of the input data, that is, converts from fixed-point data to floating-point data or from floating-point data to fixed-point data.

[0136] For example, the floating point number 68.6875 is converted into a signed 16-bit fixed-point data with a decimal point position of 5. Among them, for the signed 16-bit fixed-point data with a decimal point position of 5, the integer part occupies 10 bits, the decimal part occupies 5 bits, and the sign bit occupies 1 bit. The above data conversion unit converts the above floating point number 68.6875 into a signed 16-bit fixed-point data of 0000010010010110, such as Figure 2 shown.

[0137] The controller unit 11 sends the one or more operation instructions, the input data involved in the operation indicated by the operation instruction, and the decimal point position of one or more intermediate results obtained in the process of performing operations according to the one or more operation instructions to the operation unit 12.

[0138] In a feasible embodiment, the controller unit 11 sends the one or more operation instructions and the corresponding input data and the decimal point position thereof to the operation unit 12 .

[0139] The computing unit 12 performs computing on the corresponding input data according to the one or more computing instructions to obtain a result of the computing instruction.

[0140] The computing unit 12 includes:

[0141] An operation subunit, used to operate on the corresponding input data according to one or more operation instructions to obtain one or more intermediate operation results;

[0142] The data cache unit is used to cache the above one or more intermediate results.

[0143] Among them, the last intermediate result among the multiple intermediate results is the result of the above-mentioned calculation instruction, and the result is floating-point data.

[0144] The operation unit further includes a rounding unit. During the neural network operation, since the precision of the intermediate result obtained by performing addition operation, multiplication operation and / or other operation on the second input data exceeds the precision range of the current fixed-point data, the rounding unit performs rounding operation on the intermediate result exceeding the precision range of the fixed-point data to obtain the rounded intermediate result.

[0145] Specifically, the rounding unit performs rounding operations on the one or more intermediate calculation results.

[0146] Optionally, the rounding operation may be a random rounding operation, a round-to-nearest operation, a round-up operation, a round-down operation, a truncation rounding operation, a round-towards-zero operation, a round-towards-odd operation, a round-towards-even operation, or other operations.

[0147] Preferably, the rounding operation is a random rounding operation, a rounding operation or a rounding-towards-zero operation.

[0148] When the rounding unit performs a random rounding operation, the rounding unit specifically performs the following operations:

[0149]

[0150] Where y represents the data obtained by randomly rounding the intermediate result x before rounding, that is, the intermediate result after rounding, and ε is the smallest positive number that can be represented by the current fixed-point data representation format, that is, 2 -Point Location , represents the number obtained by directly truncating the fixed-point data of the intermediate result x before rounding (similar to rounding down a decimal), wp represents the probability, and the above formula represents the data obtained by randomly rounding the intermediate result x before rounding. The probability of The data obtained by randomly rounding the above intermediate result x is The probability of

[0151] When the rounding unit performs a rounding operation, the rounding unit specifically performs the following operations:

[0152]

[0153] Where y represents the data obtained by rounding the intermediate result x before rounding, that is, the intermediate result after rounding, and ε is the smallest positive integer that can be represented by the current fixed-point data representation format, that is, 2 -Point Location , is an integer multiple of ε, and its value is the largest number less than or equal to x. The above formula means that when the intermediate result x before rounding satisfies the condition When , the intermediate result after the above rounding is When the intermediate result before rounding meets the conditions When , the intermediate result after the above rounding is

[0154] When the rounding unit performs the rounding-up operation, the rounding unit specifically performs the following operations:

[0155]

[0156] Wherein, y represents the data obtained by rounding up the intermediate result x before the above rounding, that is, the intermediate result after the above rounding, is an integer multiple of ε, whose value is the smallest number greater than or equal to x. ε is the smallest positive integer that can be represented by the current fixed-point data representation format, that is, 2 -Point Location .

[0157] When the rounding unit performs a rounding down operation, the rounding unit specifically performs the following operations:

[0158]

[0159] Wherein, y represents the data obtained by rounding down the intermediate result x before the above rounding, that is, the intermediate result after the above rounding, is an integer multiple of ε, whose value is the largest number less than or equal to x. ε is the smallest positive integer that can be represented by the current fixed-point data representation format, that is, 2 -Point Location .

[0160] When the rounding unit performs a truncation rounding operation, the rounding unit specifically performs the following operations:

[0161] y=[x]

[0162] Wherein, y represents the data obtained by truncating and rounding the intermediate result x before the rounding, that is, the intermediate result after the rounding, and [x] represents the data obtained by directly truncating the intermediate result x to fixed-point data.

[0163] In a feasible embodiment, the computing unit does not perform truncation processing on the intermediate results whose data type is floating point data among the one or more intermediate results.

[0164] Since the intermediate results generated during the calculation process of the present application do not need to be stored in the memory, there is no need to truncate the intermediate results that exceed the storage range of the memory, which greatly reduces the precision loss of the intermediate results and improves the accuracy of the calculation results.

[0165] In a feasible embodiment, the operation unit 12 further includes a derivation unit. When the operation unit 12 receives the decimal point position of the input data involved in the fixed-point operation, the derivation unit derives the decimal point position of one or more intermediate results obtained in the fixed-point operation process according to the decimal point position of the input data involved in the fixed-point operation. When the intermediate result obtained by the operation subunit exceeds the range indicated by the corresponding decimal point position, the derivation unit shifts the decimal point position of the intermediate result to the left by M places, so that the precision of the intermediate result is within the precision range indicated by the decimal point position of the intermediate result, and M is an integer greater than 0.

[0166] For example, the at least one input data includes input data I1 and input data I2, and the corresponding decimal point positions are P1 and P2 respectively, and P1>P2. When the operation type indicated by the above operation instruction is addition operation or subtraction operation, that is, when the above operation subunit performs I1+I2 or I1-I2 operation, the above derivation unit derives that the decimal point position of the intermediate result of the operation process indicated by the above operation instruction is P1; when the operation type indicated by the above operation instruction is multiplication operation, that is, when the above operation subunit performs I1*I2 operation, the above derivation unit derives that the decimal point position of the intermediate result of the operation process indicated by the above operation instruction is P1*P2.

[0167] In a feasible embodiment, the above-mentioned computing unit further includes:

[0168] The data cache unit is used to cache the above one or more intermediate results.

[0169] Specifically, the process in which the operation unit 12 performs operations according to the one or more operation instructions and the corresponding input data includes n operations, where n is an integer greater than or equal to 1. Accordingly, the n operations generate n intermediate results. The n operations include m fixed-point operations. Where m is an integer less than or equal to n. The operation unit 12 does not perform truncation processing on x intermediate results among the m intermediate results obtained by the m fixed-point operations, where x is an integer less than or equal to m.

[0170] The decimal point position of the above one or more intermediate results is the decimal point position of any one or more intermediate results among the above n intermediate results.

[0171] Optionally, the decimal point position of the above-mentioned intermediate result is the decimal point position of the last intermediate result among the above-mentioned n intermediate results.

[0172] Optionally, the operation includes a multiplication operation, and the decimal point position of the one or more intermediate results is the decimal point position of the intermediate results obtained by executing the multiplication operation instruction.

[0173] In a feasible embodiment, the above-mentioned operation unit is also used to convert the last intermediate result among the above-mentioned multiple intermediate results into floating-point data according to the decimal point position of the last intermediate result when the last intermediate result is fixed-point data, and the last intermediate result represented by floating-point data is the result of the above-mentioned calculation instruction.

[0174] It should be noted that the above-mentioned operation instructions can be regarded as microinstructions, that is, the above-mentioned controller unit decodes the above-mentioned calculation instructions to obtain one or more microinstructions.

[0175] In a specific application scenario, the following operations are performed on the fully connected layer of the above network model, such as the above computing unit:

[0176] f(a,b)=a*b+z

[0177] The above operation process includes two operations of multiplication and addition, and generates two intermediate results: c1=a*b, c2=c1+z. In the above operation process, the intermediate results c1 and c2 are not truncated. When the intermediate result c2 is fixed-point data, the data conversion unit in the above operation unit converts c2 into floating-point data.

[0178] For example, the above operation unit performs the following operation:

[0179] f(a,b)=c'

[0180] The arithmetic unit performs one operation to obtain an intermediate result c', and does not perform truncation processing on the intermediate result c'. When c' is fixed-point data, c' is converted into floating-point data.

[0181] Among them, the above-mentioned calculation instruction may include: one or more operation domains and an operation code. The calculation instruction may include a neural network operation instruction. Taking the neural network operation instruction as an example, as shown in Table 2, register number 0, register number 1, register number 2, register number 3, and register number 4 may be operation domains. Among them, each register number 0, register number 1, register number 2, register number 3, and register number 4 may be the number of one or more registers. See Table 2 below for details:

[0182]

[0183]

[0184] Table 2

[0185] Optionally, the controller unit 11 may further include:

[0186] The dependency processing unit is used to determine whether a first operation instruction has an association relationship with a zeroth operation instruction before the first operation instruction when there are multiple operation instructions, and if the first operation instruction has an association relationship with the zeroth operation instruction, cache the first operation instruction in the instruction storage unit, and extract the first operation instruction from the instruction storage unit and transmit it to the operation unit after the zeroth operation instruction is executed;

[0187] The determining whether the first operation instruction has an association relationship with the zeroth operation instruction before the first operation instruction comprises:

[0188] Extracting a first storage address interval of data (e.g., a matrix) required in the first operation instruction according to the first operation instruction, and extracting a zeroth storage address interval of the matrix required in the zeroth operation instruction according to the zeroth operation instruction; if the first storage address interval and the zeroth storage address interval have an overlapping area, determining that the first operation instruction and the zeroth operation instruction have an associated relationship; if the first storage address interval and the zeroth storage address interval do not have an overlapping area, determining that the first operation instruction and the zeroth operation instruction do not have an associated relationship;

[0189] The first operation instruction and the zeroth operation instruction are any two of the multiple operation instructions.

[0190] In one embodiment, the computing unit 12 may include a plurality of computing modules, and the plurality of computing modules are used to perform calculations of n pipeline stages, where n is greater than or equal to 2;

[0191] The operation unit 12 is specifically used to perform a first pipeline stage calculation on the at least one input data to obtain a first intermediate result, input the first intermediate result to a second pipeline stage to perform a second pipeline stage calculation to obtain a second intermediate result, ..., input the n-1th intermediate result to the nth pipeline stage to perform a nth pipeline stage calculation to obtain an nth intermediate result, and input the nth intermediate result to the storage unit. n can be an integer greater than or equal to 3.

[0192] For example, it is assumed that the operation module of the above operation unit includes an addition operation module, a multiplication operation module and an activation module.

[0193] The arithmetic unit performs the following operations:

[0194] f(a,b)=F(a*b+z)

[0195] Among them, the above-mentioned operation unit performs three operations (including multiplication operation, addition operation and activation operation), and there are two intermediate results (including c1 and c2). The operation unit performs three-stage pipeline calculation, the multiplication module performs the calculation of the first pipeline stage, the addition module performs the calculation of the second pipeline stage, and the activation module performs the calculation of the third pipeline stage. The multiplication module of the above-mentioned operation unit performs the multiplication operation c1=a*b to obtain the first result c1; the first result c1 is input to the above-mentioned addition module, and the addition module performs the addition operation c2=c1+z to obtain the second result c2; the second result c2 is input to the above-mentioned activation module, and the activation module performs the activation operation. In one embodiment, the operation unit 12 includes but is not limited to: one or more multipliers of the first part; one or more adders of the second part (more specifically, the adders of the second part can also form an addition tree); the activation function unit of the third part; and / or the vector processing unit of the fourth part. More specifically, the vector processing unit can process vector operations and / or pooling operations. The first part multiplies the input data 1 (in1) and the input data 2 (in2) to obtain the output (out) after the multiplication, and the process is: out = in1 * in2; the second part adds the input data in1 through an adder to obtain the output data (out). More specifically, when the second part is an addition tree, the input data in1 is added level by level through the addition tree to obtain the output data (out), where in1 is a vector of length N, N is greater than 1, and the process is: out = in1[1] + in1[2] + ... + in1[N], and / or the input data (in1) is added to the input data (in2) after adding the addition number to obtain the output data (out), and the process is: out = in1[1] + in1[2] + ... + in1[N] + in2, or the input data (in1) and the input data (in2) are added together. The output data (out) is obtained by adding them together, and the process is: out = in1 + in2; the third part uses the activation function (active) to operate the input data (in) to obtain the activated output data (out), and the process is: out = active (in). The activation function active can be sigmoid, tanh, relu, softmax, etc. In addition to the activation operation, the third part can implement other nonlinear functions, and the input data (in) can be operated (f) to obtain the output data (out), and the process is: out = f (in). The vector processing unit uses the pooling operation on the input data (in) to obtain the output data (out) after the pooling operation, and the process is out = pool (in), where pool is a pooling operation, and the pooling operation includes but is not limited to: average pooling, maximum pooling, median pooling, and the input data in is the data in a pooling kernel related to the output out.

[0196] The operation unit performs the operation including the first part of multiplying the input data 1 and the input data 2 to obtain the multiplied data; and / or the second part performs the addition operation (more specifically, the addition tree operation, which is used to add the input data 1 step by step through the addition tree), or the input data 1 is added to the input data 2 to obtain the output data; and / or the third part performs the activation function operation, and the input data is operated by the activation function (active) to obtain the output data; and / or the fourth part performs the pooling operation, out = pool (in), where pool is a pooling operation, and the pooling operation includes but is not limited to: average pooling, maximum pooling, median pooling, and the input data in is the data in a pooling core related to the output out. The operations of the above parts can freely select multiple parts to be combined in different orders, so as to realize operations with various functions. The computing unit accordingly forms a two-level, three-level, or four-level pipeline architecture.

[0197] In another optional embodiment, the computing unit 12 may include a main processing circuit 101 , a branch processing circuit 103 , and a plurality of slave processing circuits 102 .

[0198] The main processing circuit 101 is used to distribute the input data A into multiple data blocks, and send at least one data block among the multiple data blocks and a computing instruction for the input data A to the branch processing circuit 103, where the input data A is any one of the at least one input data; the branch processing circuit 103 is used to forward data between the main processing circuit 101 and the slave processing circuit 102. The branch processing circuit 103 forwards at least one data block among the multiple data blocks and a computing instruction corresponding to the input data among the multiple computing instructions to the slave processing circuit 102.

[0199] The plurality of slave processing circuits 102 are configured to perform operations on the received data blocks according to the operation instruction to obtain at least one intermediate result, and transmit the at least one intermediate result to the master processing circuit 101;

[0200] The main processing circuit 101 is used to process at least one intermediate result sent by the plurality of slave processing circuits 102 to obtain a result of the calculation instruction, and send the result of the calculation instruction to the controller unit 11;

[0201] Among them, the at least one intermediate result is floating-point data.

[0202] In another alternative embodiment, if Figure 3B As shown, the operation unit 12 may include a branch processing circuit 103 (optionally); its specific connection structure is as follows Figure 3BAs shown, the main processing circuit 101 is connected to the branch processing circuit 103, and the branch processing circuit 103 is connected to multiple slave processing circuits 102;

[0203] The branch processing circuit 103 is used to execute data forwarding or operation instructions between the main processing circuit 101 and the slave processing circuit 102 .

[0204] Specifically, the main processing circuit 101 may include a register and / or an on-chip cache circuit. The main processing circuit 101 may also include: a control circuit, a vector operator circuit, an arithmetic and logic unit (ALU) circuit, an accumulator circuit, a direct memory access (DMA) circuit, and other circuits. Of course, in practical applications, the main processing circuit 101 may also be added with other circuits such as a conversion circuit (such as a matrix transposition circuit), a data rearrangement circuit or an activation circuit.

[0205] Optionally, the main processing circuit 101 may include: a data type conversion circuit, which may be used to convert the received or sent data from floating point data to fixed point data. Of course, in practical applications, fixed point data may also be converted into floating point data. The present invention does not limit the specific form of the above data type conversion circuit.

[0206] The main processing circuit 101 also includes a data sending circuit, a data receiving circuit or an interface. The data sending circuit can integrate a data distribution circuit and a data broadcasting circuit. Of course, in practical applications, the data distribution circuit and the data broadcasting circuit can also be set separately; in practical applications, the above-mentioned data sending circuit and the data receiving circuit can also be integrated together to form a data transceiver circuit. For broadcast data, that is, data that needs to be sent to each slave processing circuit 102. For distribution data, that is, data that needs to be selectively sent to some slave processing circuits 102, the specific selection method can be specifically determined by the main processing circuit 101 based on the load and the calculation method. For the broadcast sending method, the broadcast data is sent to each slave processing circuit 102 in the form of broadcast. (In practical applications, the broadcast data is sent to each slave processing circuit 102 by a single broadcast, and the broadcast data can also be sent to each slave processing circuit 102 by multiple broadcasts. The specific implementation method of this application does not limit the number of the above broadcasts). For the distribution sending method, the distribution data is selectively sent to some slave processing circuits 102.

[0207] It should be noted that the above-mentioned broadcast data includes the above-mentioned data blocks and operation instructions, and the above-mentioned distribution data includes the above-mentioned data blocks and operation instructions.

[0208] When distributing data, the control circuit of the master processing circuit 101 transmits data to some or all of the slave processing circuits 102 (the data may be the same or different. Specifically, if data is sent in a distributed manner, the data received by each slave processing circuit 102 receiving data may be different. Of course, the data received by some of the slave processing circuits 102 may be the same.

[0209] Specifically, when broadcasting data, the control circuit of the master processing circuit 101 transmits data to part or all of the slave processing circuits 102 , and each slave processing circuit 102 receiving data can receive the same data.

[0210] Optionally, the vector operator circuit of the main processing circuit 101 can perform vector operations, including but not limited to: addition, subtraction, multiplication and division of two vectors, addition, subtraction, multiplication and division of a vector and a constant, or any operation on each element in the vector. Among them, the continuous operation can specifically be addition, subtraction, multiplication and division of a vector and a constant, activation operation, accumulation operation, etc.

[0211] Each slave processing circuit 102 may include a basic register and / or a basic on-chip cache circuit; each slave processing circuit 102 may also include: one or any combination of an inner product operator circuit, a vector operator circuit, an accumulator circuit, etc. The inner product operator circuit, the vector operator circuit, and the accumulator circuit may all be integrated circuits, or they may be separately provided circuits.

[0212] Optionally, the operation unit 12 may also include one or more branch processing circuits 103. When there is a branch processing circuit 103, the main processing circuit 101 is connected to the branch processing circuit 103, and the branch processing circuit 103 is connected to the slave processing circuit 102. The inner product operator circuit of the slave processing circuit 102 is used to perform inner product operations between data blocks. The control circuit of the main processing circuit 101 controls the data receiving circuit or the data sending circuit to receive and send external data, and controls the data sending circuit to distribute external data to the branch processing circuit 103 through the control circuit. The branch processing circuit 103 is used to receive and send data (including data blocks, operation instructions, and results obtained by operating the data blocks according to the operation instructions) from the main processing circuit 101 or the slave processing circuit 102. Figure 3B The structure shown is suitable for the calculation of complex data, because the number of units connected to the main processing circuit 101 is limited, so it is necessary to add a branch processing circuit 103 between the main processing circuit 101 and the slave processing circuit 102 to achieve the access of more slave processing circuits 102, thereby realizing the calculation of complex data blocks. The connection structure of the branch processing circuit 103 and the slave processing circuit 102 can be arbitrary and is not limited to Figure 3B H-type structure.

[0213] Optionally, the structure from the master processing circuit 101 to the slave processing circuit 102 is a broadcast or distribution structure, and the structure from the slave processing circuit 102 to the master processing circuit 101 is a gather structure. The definitions of broadcast, distribution and gather are as follows: for the distribution or broadcast structure, the number of slave processing circuits 102 is greater than the master processing circuit 101, that is, one master processing circuit 101 corresponds to multiple slave processing circuits 102, that is, the structure from the master processing circuit 101 to multiple slave processing circuits 102 is a broadcast or distribution structure, and conversely, the structure from multiple slave processing circuits 102 to the master processing circuit 101 can be a gather structure.

[0214] The slave processing circuit 102 receives data (including data blocks and operation instructions) distributed or broadcast by the master processing circuit 101, and saves it in the on-chip cache of the slave processing circuit 102. It can perform operations to generate results, and can send the results obtained by calculating the data blocks according to the operation instructions to the master processing circuit 101.

[0215] The data involved in the processing circuit 102 can be data of any data type, can be data represented by floating-point numbers of any bit width, and can also be data represented by fixed-point numbers of any bit width; all the operation circuits and storage circuits involved can be operation circuits and storage circuits that can process any data type, can be operation circuits and storage circuits of floating-point numbers of any bit width, and can also be operation circuits and storage circuits of fixed-point numbers of any bit width.

[0216] Optionally, each slave processing circuit 102 may include a data type conversion circuit, or a data type conversion circuit may be configured in part of the slave processing circuits 102; the data type conversion circuit may be used to convert the received or sent data from floating-point data to fixed-point data, or to convert the fixed-point data to floating-point data. The present invention does not limit the specific form of the above data type conversion circuit.

[0217] In another optional embodiment, the computing unit 12 is as follows: Figure 3C As shown, it may include a master processing circuit 101 and a plurality of slave processing circuits 102. In one embodiment, as Figure 3C As shown, multiple slave processing circuits 102 are distributed in an array; each slave processing circuit 102 is connected to other adjacent slave processing circuits 102, and the master processing circuit 101 is connected to K slave processing circuits 102 among the multiple slave processing circuits 102, and the K slave processing circuits 102 are: n slave processing circuits 102 in the 1st row, n slave processing circuits 102 in the mth row, and m slave processing circuits 102 in the 1st column.

[0218] The K slave processing circuits 102 are used for forwarding data and instructions between the master processing circuit 101 and the plurality of slave processing circuits 102 .

[0219] The master processing circuit 101 is used to distribute the input data A into multiple data blocks, and send at least one data block among the multiple data blocks and a computing instruction for the input data A to the K slave processing circuits 102, where the input data A is any one of the at least one input data;

[0220] The K slave processing circuits 102 are used to convert data between the master processing circuit 101 and the plurality of slave processing circuits 102;

[0221] The plurality of slave processing circuits 102 are configured to perform operations on the received data blocks according to the operation instructions for the input data A to obtain at least one intermediate result, and transmit the at least one intermediate result to the K slave processing circuits 102;

[0222] The main processing circuit 101 is used to process at least one intermediate result sent by the K slave processing circuits 102 to obtain a result of the calculation instruction, and send the result of the calculation instruction to the controller unit 11.

[0223] Specifically, the above-mentioned multiple slave processing circuits 102 are arranged in an array (m*n array), wherein the value range of m and n is an integer greater than or equal to 1 and at least one of the values ​​of m and n is greater than or equal to 2. For the multiple slave processing circuits distributed in the m*n array, each slave processing circuit 102 is connected to an adjacent slave processing circuit 102, and the master processing circuit 102 is connected to k slave processing circuits 102 among the multiple slave processing circuits 102, and the k slave processing circuits 102 can be: n slave processing circuits 102 in the first row, n slave processing circuits 102 in the mth row, and m slave processing circuits 102 in the first column. Figure 3C The computing unit 12, the master processing circuit 101 and / or the multiple slave processing circuits 102 shown may include a data type conversion circuit. Specifically, some of the multiple slave processing circuits 102 may include a data type conversion circuit.

[0224] For example, in an optional technical solution, k slave processing circuits 102 may be configured with data type conversion circuits, so that n slave processing circuits 102 may be respectively responsible for performing data type conversion steps on the data of m slave processing circuits 102 in this column. This setting can improve the operation efficiency and reduce the power consumption, because for the n slave processing circuits 102 in the first row, since they first receive the data sent by the master processing circuit 101, then converting the received data into fixed-point data can reduce the amount of calculation of the subsequent slave processing circuits 102 and the amount of data transmission with the subsequent slave processing circuits 102. Similarly, configuring the data type conversion circuit for the m slave processing circuits 102 in the first column also has the advantages of small amount of calculation and low power consumption. In addition, according to this structure, the main processing circuit 101 can adopt a dynamic data sending strategy. For example, the main processing circuit 101 broadcasts data to the m slave processing circuits 102 in the first column, and the main processing circuit 101 sends distribution data to the n slave processing circuits 102 in the first row. This has the advantage that different data is transmitted to the slave processing circuit 102 through different data input ports. In this way, the slave processing circuit 102 does not need to distinguish what kind of data is received, and only needs to determine from which receiving port the data is received to know what kind of data it is.

[0225] The main processing circuit is used to execute various continuous operations in the neural network operation and transmit data to the slave processing circuit 102 connected thereto; the above-mentioned continuous operations include but are not limited to: addition operations, arithmetic and logic unit (ALU) operations, activation operations, etc.

[0226] The multiple slave processing circuits 102 are used to perform operations in the neural network in parallel according to the transmitted data, and transmit the operation results to the master processing circuit through the slave processing circuits 102 connected to the master processing circuit. The operations in the neural network performed in parallel include but are not limited to: inner product operations, matrix or vector multiplication operations, etc.

[0227] The above-mentioned main processing circuit 101 may include: a data sending circuit, a data receiving circuit or an interface. The data sending circuit may integrate a data distribution circuit and a data broadcasting circuit. Of course, in practical applications, the data distribution circuit and the data broadcasting circuit may also be set separately. For broadcast data, that is, data that needs to be sent to each slave processing circuit 102. For distributed data, that is, data that needs to be selectively sent to some slave processing circuits 102. Specifically, such as convolution operation, the convolution input data of the convolution operation needs to be sent to all slave processing circuits 102, so it is broadcast data, and the convolution kernel needs to be selectively sent to some basic data blocks, so the convolution kernel is distributed data. The specific selection of the distribution data to be sent to which slave processing circuit 102 can be specifically determined by the main processing circuit according to the load and other distribution methods. For the broadcast transmission method, the broadcast data is sent to each slave processing circuit 102 in the form of broadcast. (In actual applications, the broadcast data is sent to each slave processing circuit 102 by means of one broadcast, or by means of multiple broadcasts. The specific implementation mode disclosed herein does not limit the number of the above broadcasts.) For the distributed sending mode, the distributed data is selectively sent to some slave processing circuits 102.

[0228] The main processing circuit 101 (such as Figure 3E The main processing circuit 101 may include registers and / or on-chip cache circuits. The main processing circuit 101 may also include: control circuits, vector operator circuits, ALUs, accumulator circuits, DMA circuits and other circuits. Of course, in practical applications, the main processing circuit 101 may also be added with conversion circuits (such as matrix transposition circuits), data rearrangement circuits or activation circuits and other circuits.

[0229] Each slave processing circuit 102 may include a basic register and / or a basic on-chip cache circuit; each slave processing circuit 102 may also include: one or any combination of an inner product operator circuit, a vector operator circuit, an accumulator circuit, etc. The inner product operator circuit, the vector operator circuit, and the accumulator circuit may all be integrated circuits, or they may be separately provided circuits.

[0230] In a specific application scenario, the above-mentioned computing unit includes a main processing circuit (also referred to as a main unit) and multiple slave processing circuits (also referred to as basic units); the structure of the embodiment is as follows Figure 3DAs shown; the dotted box is the internal structure of the neural network computing device; the gray filled arrows represent the data transmission path between the master processing circuit and the slave processing circuit array, and the hollow arrows represent the data transmission path between each slave processing circuit (adjacent slave processing circuits) in the slave processing circuit array. The length, width and length of the slave processing circuit array can be different, that is, the values ​​of m and n can be different, or they can be the same, and the present disclosure does not limit the specific values ​​of the above values.

[0231] From the circuit structure of the processing circuit Figure 3D As shown; the dotted box in the figure represents the boundary of the processing circuit, and the thick arrows crossing the dotted box represent data input and output channels (pointing into the dotted box is the input channel, and pointing out the dotted box is the output channel); the rectangular box in the dotted box represents the storage unit circuit (register and / or on-chip cache), including input data 1, input data 2, multiplication or inner product result, and accumulated data; the diamond box represents the operator circuit, including a multiplication or inner product operator and an adder.

[0232] In this embodiment, the operation unit includes a master processing circuit and 16 slave processing circuits (16 slave processing circuits are only for illustration, and other values ​​may be used in actual applications);

[0233] In this embodiment, the slave processing circuit has two data input interfaces and two data output interfaces; in the subsequent description of this embodiment, the horizontal input interface ( Figure 3D The horizontal arrow pointing to this unit) is called input 0, and the vertical input interface ( Figure 3D The vertical arrow pointing to this unit) is called input 1; each horizontal data output interface ( Figure 3D The horizontal arrow pointing out of this unit) is called output 0, and the vertical data output interface ( Figure 3D The vertical arrow pointing out from this unit in the figure is called output 1.

[0234] The data input interface and data output interface of each slave processing circuit can be connected to different units, including the master processing circuit and other slave processing circuits;

[0235] In this example, from processing circuits 0, 4, 8, and 12 (see Figure 3D ) The input 0s of the four slave processing circuits are connected to the data output interface of the master processing circuit;

[0236] In this example, the input 1 of the four slave processing circuits 0, 1, 2, and 3 is connected to the data output interface of the master processing circuit;

[0237] In this example, the outputs 1 of the four slave processing circuits 12, 13, 14, and 15 are connected to the data input interface of the master processing circuit;

[0238] In this example, the output interface of the slave processing circuit is connected to the input interface of other slave processing circuits. Figure 3D As shown, no more listing;

[0239] This embodiment includes a main processing circuit, which is connected to an external device (that is, it has both an input interface and an output interface), a part of the data output interface of the main processing circuit is connected to a part of the data input interface of the slave processing circuit; a part of the data input interface of the main processing circuit is connected to a part of the data output interface of the slave processing circuit.

[0240] The fixed-point data mentioned in this application can be signed fixed-point data or unsigned fixed-point data.

[0241] The decimal point location is used to indicate the number of bits occupied by the decimal part of the fixed-point data, or the decimal point location is used to indicate the precision of the fixed-point data, i.e., 2 -Point Location The larger the value of the decimal point position, the higher the precision of the fixed-point data.

[0242] It should be noted that the above-mentioned first input data is long-bit non-fixed-point data, such as 32-bit floating-point data, and can also be standard 64-bit or 16-bit floating-point data, etc., and here only 32 bits are used as a specific embodiment for explanation; the above-mentioned second input data is short-bit fixed-point data, also known as less-bit fixed-point data, which means that relative to the first input data of long-bit non-fixed-point data, it is fixed-point data represented by fewer bits.

[0243] Specifically, for different layers of different network models, the first input data includes different types of data. The decimal point positions of the different types of data are different, that is, the precision of the corresponding fixed-point data is different. For the fully connected layer, the first input data includes data such as input neurons, weights and bias data; for the convolutional layer, the first input data includes data such as convolution kernels, input neurons and bias data.

[0244] For example, for a fully connected layer, the above decimal point positions include the decimal point positions of input neurons, the decimal point positions of weights, and the decimal point positions of bias data. The decimal point positions of the above input neurons, the decimal point positions of weights, and the decimal point positions of bias data may be all the same, partially the same, or different from each other.

[0245] Optional, such as Figure 3F As shown, the main processing circuit includes: one or any combination of a conversion processing circuit 110, an activation processing circuit 111, and an addition processing circuit 112;

[0246] The conversion processing circuit 110 is used to perform an exchange between a first data structure and a second data structure (e.g., conversion between continuous data and discrete data) on a data block or an intermediate result received by the main processing circuit; or perform an exchange between a first data type and a second data type (e.g., conversion between a fixed-point type and a floating-point type) on a data block or an intermediate result received by the main processing circuit;

[0247] An activation processing circuit 111 is used to perform activation operations on data in the main processing circuit;

[0248] The addition processing circuit 112 is used to perform addition operations or accumulation operations.

[0249] The master processing circuit is used to distribute an input data into a plurality of data blocks, and send at least one data block of the plurality of data blocks and at least one operation instruction of the plurality of operation instructions to the slave processing circuit;

[0250] The multiple slave processing circuits are used to perform operations on the received data blocks according to the operation instructions to obtain intermediate results, and transmit the operation results to the master processing circuit;

[0251] The main processing circuit is used to process the intermediate results sent by the multiple slave processing circuits to obtain the result of the calculation instruction, and send the result of the calculation instruction to the controller unit.

[0252] The slave processing circuit includes: a multiplication processing circuit;

[0253] The multiplication processing circuit is used to perform a multiplication operation on the received data block to obtain a product result;

[0254] A forwarding processing circuit (optional) is used to forward the received data block or product result.

[0255] The accumulation processing circuit is used to perform an accumulation operation on the product result to obtain the intermediate result.

[0256] In a feasible embodiment, the computing unit obtains one or more computing results in the process of computing the at least one input data according to the one or more computing instructions. The computing unit backs up and saves the floating-point data in the at least one input data and the floating-point data in the one or more intermediate results; when the computing unit performs reverse training on the network model, the computing unit uses the backed-up floating-point data to perform reverse training on the network model to improve the accuracy of the network model training.

[0257] In a specific application scenario, the data input and output unit obtains at least one input data, a network model and a calculation instruction, and the at least one input data is fixed-point data. The instruction processing unit of the controller unit decodes the calculation instruction to obtain one or more operation instructions. The controller unit sends the at least one input data and the one or more operation instructions to the operation unit. The operation unit operates on the at least one input data according to the one or more operation instructions to obtain a result of the calculation instruction, and the result of the calculation instruction is floating-point data.

[0258] Specifically, the computing unit operates on the at least one input data according to the one or more computing instructions to obtain one or more intermediate results, wherein the last intermediate result of the one or more intermediate results is the result of the computing instruction. When the last intermediate result is fixed-point data, the computing unit converts the last intermediate result into floating-point data according to the decimal point position of the last intermediate result to perform subsequent operations.

[0259] The data input and output unit further acquires a data conversion instruction, which includes an operation field and an operation code, wherein the operation code is used to indicate the function of the data conversion instruction, and the operation field of the data conversion instruction includes the decimal point position of the input data and the conversion method identification of the data type. When the at least one input data is floating-point data, the instruction processing unit of the controller unit parses the data conversion instruction to obtain the decimal point position of the input data and the conversion method identification of the data type, and the data conversion unit determines the conversion method of the data type according to the conversion method identification of the data type and the correspondence table between the conversion method identification of the data type and the conversion method of the data type, and then the data conversion unit converts the at least one input data into fixed-point data according to the decimal point position of the input data and the conversion method of the data type.

[0260] In a feasible embodiment, the controller unit sends the decimal point position of the at least one input data to the computing unit, and the derivation unit of the computing unit derives the decimal point position of one or more intermediate results based on the decimal point position of the at least one input data.

[0261] Figure 4 A single-layer neural network forward operation flow chart provided by an embodiment of the present invention. The flow chart describes the process of a single-layer neural network forward operation implemented by the neural network operation device and instruction set implemented by the present invention. For each layer, the input neuron vector is first weighted and summed to calculate the intermediate result vector of this layer. The intermediate result vector is biased and activated to obtain the output neuron vector. The output neuron vector is used as the input neuron vector of the next layer.

[0262] In a specific application scenario, the computing device may be a training device. Before training a neural network model, the training device obtains training data involved in the training of the neural network model, which is non-fixed-point data, and obtains the decimal point position of the training data according to the above method. The training device converts the training data into training data represented by fixed-point data according to the decimal point position of the training data. The training device performs a forward neural network operation on the training data represented by the fixed-point data to obtain a neural network operation result. The training device performs a random rounding operation on the neural network operation result that exceeds the data precision range that can be represented by the decimal point position of the training data to obtain a rounded neural network operation result, which is within the data precision range that can be represented by the decimal point position of the training data. According to the above method, the training device obtains the neural network operation result of each layer of the multi-layer neural network, that is, the output neuron. The training device obtains the gradient of the output neuron according to each layer of the output neuron, and performs a reverse operation according to the gradient of the output neuron to obtain the weight gradient, thereby updating the weight of the neural network model according to the weight gradient.

[0263] The training device repeatedly executes the above process to achieve the purpose of training the neural network model.

[0264] Among them, the above-mentioned forward operation includes the above-mentioned multi-layer neural network operation, and the multi-layer neural network operation includes operations such as convolution, and the convolution operation is implemented by a convolution operation instruction.

[0265] The above-mentioned convolution operation instruction is an instruction in the Cambricon instruction set. The Cambricon instruction set is characterized in that an instruction consists of an operation code and an operand. The instruction set contains four types of instructions, namely control instructions, data transfer instructions, computational instructions, and logical instructions.

[0266] Preferably, the length of each instruction in the instruction set is fixed length. For example, the length of each instruction in the instruction set may be 64 bits.

[0267] Furthermore, control instructions are used to control the execution process, and control instructions include jump instructions and conditional branch instructions.

[0268] Furthermore, data transfer instructions are used to complete data transfer between different storage media. Data transfer instructions include load instructions, store instructions, and move instructions. The load instruction is used to load data from the main memory to the cache, the store instruction is used to store data from the cache to the main memory, and the move instruction is used to move data between cache and cache, cache and register, or register and register. Data transfer instructions support three different data organization methods, including matrix, vector, and scalar.

[0269] Furthermore, the operation instructions are used to perform neural network arithmetic operations, including matrix operation instructions, vector operation instructions and scalar operation instructions.

[0270] Furthermore, matrix operation instructions complete matrix operations in neural networks, including matrix multiply vector, vector multiply matrix, matrix multiply scalar, outer product, matrix add matrix, and matrix subtract matrix.

[0271] Furthermore, vector operation instructions complete vector operations in neural networks, including vector elementary arithmetics, vector transcendental functions, dot product, random vector generator, and maximum / minimum of a vector. Vector elementary operations include vector addition, subtraction, multiplication, and division. Vector transcendental functions refer to functions that do not satisfy any polynomial equation with polynomials as coefficients, including but not limited to exponential functions, logarithmic functions, trigonometric functions, and inverse trigonometric functions.

[0272] Furthermore, the scalar operation instructions complete the scalar operations in the neural network, including scalar elementary arithmetics and scalar transcendental functions. Scalar elementary operations include scalar addition, subtraction, multiplication, and division (add, subtract, multiply, divide), and scalar transcendental functions refer to those functions that do not satisfy any polynomial equations with polynomials as coefficients, including but not limited to exponential functions, logarithmic functions, trigonometric functions, and inverse trigonometric functions.

[0273] Furthermore, the logic instructions are used for the logic operation of the neural network. The logic operation includes vector logic operation instructions and scalar logic operation instructions.

[0274] Furthermore, the vector logical operation instructions include vector compare, vector logical operations and vector greater than merge. The vector compare includes but greater than, less than, equal to, greater than or equal to, less than or equal to and not equal to. The vector logical operations include and, or, not.

[0275] Furthermore, scalar logical operations include scalar compare and scalar logical operations. Scalar compare includes but greater than, less than, equal to, greater than or equal to, less than or equal to, and not equal to. Scalar logical operations include and, or, and not.

[0276] For multi-layer neural networks, the implementation process is that in the forward operation, when the execution of the previous layer of artificial neural network is completed, the operation instructions of the next layer will use the output neurons calculated in the operation unit as the input neurons of the next layer for operation (or perform certain operations on the output neurons and then use them as the input neurons of the next layer), and at the same time, the weights will also be replaced by the weights of the next layer; in the reverse operation, when the reverse operation of the previous layer of artificial neural network is completed, the operation instructions of the next layer will use the input neuron gradient calculated in the operation unit as the output neuron gradient of the next layer for operation (or perform certain operations on the input neuron gradient and then use it as the output neuron gradient of the next layer), and at the same time, the weights will be replaced by the weights of the next layer. Figure 5 As shown, Figure 5 The dashed arrows in the middle represent reverse operations, and the realized arrows represent forward operations.

[0277] In another embodiment, the operation instruction is a matrix multiplication instruction, an accumulation instruction, an activation instruction, or the like, including a forward operation instruction and a direction training instruction.

[0278] The following is an explanation of the neural network operation instructions. Figure 3A The specific calculation method of the calculation device shown in the figure. For the neural network operation instruction, the formula that actually needs to be executed can be: s=s(∑wx i +b), where the weight w is multiplied by the input data x i , sum it up, then add the bias b and do the activation operation s(h) to get the final output result s.

[0279] like Figure 3A The method for the computing device shown to execute the neural network forward operation instruction may specifically be:

[0280] The controller unit extracts the neural network forward operation instruction, the operation domain corresponding to the neural network operation instruction and at least one operation code from the instruction storage unit, transmits the operation domain to the data access unit, and sends the at least one operation code to the operation unit.

[0281] The controller unit extracts the weight w and bias b corresponding to the operation domain from the storage medium (when b is 0, there is no need to extract bias b), and transmits the weight w and bias b to the main processing circuit of the operation unit. The controller unit extracts the input data Xi from the storage medium and sends the input data Xi to the main processing circuit.

[0282] The main processing circuit splits the input data Xi into n data blocks.

[0283] The instruction processing unit of the controller unit determines the multiplication instruction, the bias instruction and the accumulation instruction according to the at least one operation code, and sends the multiplication instruction, the bias instruction and the accumulation instruction to the main processing circuit, the main processing circuit sends the multiplication instruction and the weight w to multiple slave processing circuits in a broadcast manner, and distributes the n data blocks to the multiple slave processing circuits (for example, if there are n slave processing circuits, then each slave processing circuit sends a data block); multiple slave processing circuits are used to perform multiplication operations on the weight w and the received data blocks according to the multiplication instruction to obtain an intermediate result, and send the intermediate result to the main processing circuit, the main processing circuit performs accumulation operations on the intermediate results sent by the multiple slave processing circuits according to the accumulation instruction to obtain an accumulation result, adds bias b to the accumulation result according to the bias instruction to obtain a final result, and sends the final result to the controller unit.

[0284] In addition, the order of addition and multiplication operations can be reversed.

[0285] It should be noted that the method by which the computing device executes the reverse training instruction of the neural network is similar to the process by which the computing device executes the forward operation instruction of the neural network. For details, please refer to the relevant description of the reverse training, which will not be described here.

[0286] The technical solution provided by the present application realizes the multiplication operation and bias operation of the neural network through one instruction, namely the neural network operation instruction. The intermediate results of the neural network calculation do not need to be stored or extracted, which reduces the storage and extraction operations of the intermediate data. Therefore, it has the advantages of reducing the corresponding operation steps and improving the calculation effect of the neural network.

[0287] The present application also discloses a neural network computing device, which includes one or more computing devices mentioned in the present application, and is used to obtain data to be calculated and control information from other processing devices, perform specified neural network operations, and transmit the execution results to peripheral devices through I / O interfaces. Peripheral devices include cameras, displays, mice, keyboards, network cards, wifi interfaces, and servers. When more than one computing device is included, the computing devices can be linked and data can be transmitted through a specific structure, for example, interconnected and data can be transmitted through a PCIE bus to support larger-scale neural network operations. At this time, the same control system can be shared, or each independent control system can be provided; memory can be shared, or each accelerator can have its own memory. In addition, the interconnection method can be any interconnection topology.

[0288] The neural network computing device has high compatibility and can be connected to various types of servers through a PCIE interface.

[0289] The present application also discloses a combined processing device, which includes the above-mentioned neural network computing device, a universal interconnection interface, and other processing devices. The neural network computing device interacts with other processing devices to jointly complete the operation specified by the user. Figure 6 A schematic diagram of a combined processing device.

[0290] Other processing devices include one or more types of processors such as central processing unit (CPU), graphics processing unit (GPU), neural network processor, and other general / special processors. There is no limit on the number of processors included in other processing devices. Other processing devices serve as interfaces between the neural network computing device and external data and control, including data handling, to complete basic control of the neural network computing device such as starting and stopping; other processing devices can also collaborate with the neural network computing device to complete computing tasks.

[0291] A universal interconnection interface is used to transmit data and control instructions between the neural network computing device and other processing devices. The neural network computing device can obtain the required input data from other processing devices and write it into the storage device on the neural network computing device chip; it can obtain control instructions from other processing devices and write them into the control cache on the neural network computing device chip; it can also read data in the storage module of the neural network computing device and transmit it to other processing devices.

[0292] Optionally, the structure is Figure 7 As shown, a storage device may also be included, and the storage device is connected to the neural network operation device and the other processing device respectively. The storage device is used to store data in the neural network operation device and the other processing device, and is particularly suitable for data that cannot be fully stored in the internal storage of the neural network operation device or other processing devices.

[0293] The combined processing device can be used as a SOC chip system for mobile phones, robots, drones, video surveillance equipment and other devices, effectively reducing the core area of ​​the control part, improving the processing speed, and reducing the overall power consumption. In this case, the universal interconnection interface of the combined processing device is connected to certain components of the device. Certain components include cameras, displays, mice, keyboards, network cards, and wifi interfaces.

[0294] In a feasible embodiment, a distributed system is also applied for, the system includes n1 main processors and n2 coprocessors, n1 is an integer greater than or equal to 0, and n2 is an integer greater than or equal to 1. The system can be of various types of topology, including but not limited to Figure 3B The topological results shown are Figure 3C The topology shown, Fig.12 The topology shown and Fig.13 The topology shown.

[0295] The main processor sends the input data, the decimal point position and the calculation instruction to the above-mentioned multiple coprocessors respectively; or the above-mentioned main processor sends the above-mentioned input data, the decimal point position and the calculation instruction to some of the above-mentioned multiple slave processors, and the above-mentioned slave processors then send the above-mentioned input data, the decimal point position and the calculation instruction to other slave processors. The above-mentioned coprocessor includes the above-mentioned calculation device, which calculates the above-mentioned input data according to the above-mentioned method and calculation instruction to obtain a calculation result;

[0296] The above input data includes but is not limited to input neurons, weights and bias data, etc.

[0297] The coprocessor sends the calculation result directly to the main processor, or the coprocessor that is not connected to the main processor sends the calculation result to the coprocessor that is connected to the main processor first, and then the coprocessor sends the received calculation result to the main processor.

[0298] In some embodiments, a chip is also applied for, which includes the above-mentioned neural network computing device or combined processing device.

[0299] In some embodiments, a chip packaging structure is applied for, which includes the above-mentioned chip.

[0300] In some embodiments, a board is applied for, which includes the above-mentioned chip packaging structure.

[0301] In some embodiments, an electronic device is applied for, which includes the above-mentioned board.

[0302] The above-mentioned electronic devices include data processing devices, robots, computers, printers, scanners, tablet computers, smart terminals, mobile phones, driving recorders, navigators, sensors, cameras, servers, cloud servers, cameras, camcorders, projectors, watches, headphones, mobile storage, wearable devices, vehicles, household appliances, and / or medical equipment.

[0303] The transportation means include airplanes, ships and / or vehicles; the household appliances include televisions, air conditioners, microwave ovens, refrigerators, rice cookers, humidifiers, washing machines, electric lights, gas stoves, and range hoods; the medical equipment includes magnetic resonance imaging, ultrasound machines and / or electrocardiographs.

[0304] See also Figure 8 , Figure 8 A calculation method provided in an embodiment of the present invention is used to perform calculation of a network model, wherein the network model includes: a neural network model and / or a non-neural network model, and the method includes:

[0305] S801. The computing device obtains at least one input data, the network model and a computing instruction, wherein the at least one input data is fixed-point data.

[0306] S802: The computing device decodes the computing instruction to obtain one or more operation instructions.

[0307] In a feasible embodiment, when the at least one input data is floating point data, the method further includes:

[0308] Acquire a data conversion instruction, the data conversion instruction including an operation code and an operation field, the operation code is used to indicate a function of the data conversion instruction, and the operation field includes a decimal point position of input data and a conversion mode identifier of a data type;

[0309] Parsing the data conversion instruction to obtain a conversion method identifier of a decimal point position and a data type of the input data;

[0310] The at least one input data is converted into fixed-point data according to the decimal point position of the input data and the conversion mode identifier of the data type.

[0311] S803: The computing device performs calculations on the at least one input data according to the one or more operation instructions to obtain a result of the calculation instruction, where the result of the calculation instruction is floating-point data.

[0312] The step of performing calculation on the at least one input data according to the one or more operation instructions to obtain a result of the calculation instruction includes:

[0313] The second input data is operated according to the one or more operation instructions to obtain one or more intermediate results, wherein the last intermediate result of the one or more intermediate results is the result of the calculation instruction;

[0314] When the last intermediate result is fixed-point data, the last intermediate result is converted into floating-point data according to the decimal point position of the last intermediate result.

[0315] In a feasible embodiment, the method further includes:

[0316] The decimal point position of the one or more intermediate results is derived according to the decimal point position of the at least one input data.

[0317] The above-mentioned operation instructions include forward operation instructions and reverse training instructions, that is, during the execution of the forward operation instructions and / or reverse training instructions (that is, the operation device performs forward operation and / or reverse training), the above-mentioned operation device may perform the following operations according to the above-mentioned Figure 8 The illustrated embodiment converts the data involved in the operation into fixed-point data and performs fixed-point operation.

[0318] It should be noted that the specific description of the above steps S801-S803 can be found in Figure 1-7 The relevant description of the illustrated embodiment will not be repeated here.

[0319] In a specific application scenario, the computing device converts the data involved in the computing into fixed-point data and adjusts the decimal point position of the fixed-point data. For the specific process, see Fig. 9 ,like Fig. 9 As shown, the method includes:

[0320] S901. The computing device obtains first input data.

[0321] The first input data is data participating in the operation of the mth layer of the multi-layer network model, and the first input data is data of any type, such as fixed-point data, floating-point data, integer data or discrete data, and m is an integer greater than 0.

[0322] The mth layer of the multi-layer network model is a linear layer, which includes but is not limited to a convolutional layer and a fully connected layer. The first input data includes input neurons, weights, output neurons, input neuron derivatives, weight derivatives, and output neuron derivatives.

[0323] S902: The computing device determines the decimal point position of the first input data and the bit width of the fixed-point data.

[0324] The bit width of the fixed-point data of the first input data is the bits occupied by the first input data represented by the fixed-point data, and the decimal point position is the bits occupied by the decimal part of the first data represented by the fixed-point data. The decimal point position is used to characterize the precision of the fixed-point data.

[0325] See also Fig.10 , Fig.10 This is a schematic diagram of the format of fixed-point data. Fig.10 As shown, the number of bits occupied by the fixed-point data is bitnum, the decimal point position is s, and the precision of the fixed-point data is 2 s The first bit is the sign bit, which is used to indicate whether the fixed-point data is positive or negative. For example, when the sign bit is 0, it means that the fixed-point data is positive; when the sign bit is 1, it means that the fixed-point data is negative. The range of the fixed-point data is [neg, pos], where pos = (2 bitnum-1 -1)*2 s , neg=-(2 bitnum-1 -1)*2 s .

[0326] The bitnum can be any positive integer. The s can be any integer not less than s_min.

[0327] Optionally, the bitnum may be 8, 16, 24, 32, 64 or other values.

[0328] Preferably, the above s_min is -64.

[0329] Optionally, the bitnum is 8, 16, 24, 32 or other values. s can be any integer not less than s_min, preferably, s_min is -64.

[0330] Specifically, the first input data can be any type of data, and the first input data a is converted into the second input data according to the above decimal point position and the bit width of the fixed-point data. The details are as follows:

[0331]

[0332] When the first input data a satisfies the condition neg≤a≤pos, the second input data for When the first input data a is greater than pos, the second input data is pos; when the first input data a is less than neg, the second input data It is neg.

[0333] In one embodiment, the input neurons, weights, output neurons, input neuron derivatives, output neuron derivatives, and weight derivatives of the convolutional layer and the fully connected layer are all represented by fixed-point data.

[0334] Optionally, the bit width of the fixed-point data used by the input neuron may be 8, 16, 32, 64 or other values. Preferably, the bit width of the fixed-point data used by the input neuron is 8.

[0335] Optionally, the bit width of the fixed-point data used by the weights may be 8, 16, 32, 64 or other values. Preferably, the bit width of the fixed-point data used by the weights is 8.

[0336] Optionally, the bit width of the fixed-point data used in the above-mentioned input neuron derivatives may be 8, 16, 32, 64 or other values. Preferably, the bit width of the fixed-point data used in the above-mentioned input neuron derivatives is 16.

[0337] Optionally, the bit width of the fixed-point data used in the output neuron derivative may be 8, 16, 32, 64 or other values. Preferably, the bit width of the fixed-point data used in the output neuron derivative is 24.

[0338] Optionally, the bit width of the fixed-point data used by the weight derivative may be 8, 16, 32, 64 or other values. Preferably, the bit width of the fixed-point data used by the weight derivative is 24.

[0339] In one embodiment, a plurality of fixed-point representation methods can be used for the data a with larger values ​​in the data involved in the multi-layer network model operation. Fig.11 :

[0340] like Fig.11As shown, the data a (i.e., the first input data) is represented by three fixed-point data combinations, i.e., the data a is composed of fixed-point data 1, fixed-point data 2, and fixed-point data 3. Among them, the bit width of fixed-point data 1 is bitnum1, and the decimal point position is s1; the bit width of fixed-point data 2 is bitnum2, and the decimal point position is s2; the bit width of fixed-point data 3 is bitnum3, and the decimal point position is s2, and bitnum2-2=s1-1, bitnum3-2=s2-1. The range represented by three fixed-point data is [neg,pos], where pos=(2 bitnum-1 -1)*2 s , neg=-(2 bitnum-1 -1)*2 s .

[0341] Specifically, the first input data can be any type of data, and the first input data a is converted into the second input data according to the above decimal point position and the bit width of the fixed-point data. The details are as follows:

[0342]

[0343] When the first input data a satisfies the condition neg≤a≤pos, the second input data for and When the first input data a is greater than pos, the second input data is pos; when the first input data a is less than neg, the second input data It is neg.

[0344] S903: The computing device initializes the decimal point position of the first input data and adjusts the decimal point position of the first input data.

[0345] Among them, the above decimal point position s needs to be initialized and dynamically adjusted according to different categories of data, data of different neural network layers, and data in different iteration rounds.

[0346] The following specifically introduces the initialization process of the decimal point position s of the first input data, that is, determining the decimal point position s used by the fixed-point data when converting the first input data for the first time.

[0347] Among them, the initialization of the decimal point position s of the first input data of the above-mentioned computing device includes: initializing the decimal point position s of the first input data according to the maximum absolute value of the first input data; initializing the decimal point position s of the first input data according to the minimum absolute value of the first input data; initializing the decimal point position s of the first input data according to the relationship between different data types in the first input data; initializing the decimal point position s of the first input data according to an empirical value constant.

[0348] Specifically, the above initialization process is introduced in detail below.

[0349] a) Initialize the decimal point position s of the first input data according to the maximum absolute value of the first input data:

[0350] Specifically, the decimal point position s of the first input data is calculated through the following formula:.

[0351]

[0352] Among them, the above a max is the maximum absolute value of the first input data, bitnum is the bit width of the first input data converted into fixed-point data, and s a is the decimal point position of the first input data.

[0353] Among them, the data involved in the operation can be divided into the following categories and network levels: the input neurons X in the first layer (l) , output neuron Y (l) , weight W (l) , input neuron derivative Output neuron derivative and weight derivative When searching for the maximum absolute value, you can search by data category; you can search by layer, by category; you can search by layer, by category, by group. The method for determining the maximum absolute value of the first input data includes:

[0354] a.1) Find the maximum absolute value by data category

[0355] Specifically, the first input data includes a vector / matrix in which each element is a i (l) , where a (l) Can be the input neuron X (l) Or output neuron Y (l) Or weight W (l) Or input neuron derivatives or the output neuron derivative or weight derivative In other words, the first input data includes input neurons, weights, output neurons, input neuron derivatives, weight derivatives and output neuron derivatives, and the decimal point positions of the first input data include the decimal point positions of input neurons, weights, output neurons, input neuron derivatives, weight derivatives and output neuron derivatives. The input neurons, weights, output neurons, input neuron derivatives, weight derivatives and output neuron derivatives are all represented in the form of matrices or vectors. By traversing the above multi-layer network model. All elements in the vector / matrix of each layer are obtained to obtain the absolute maximum value of each category of data, that is, By formula Determine the decimal point position s for each category data a converted to fixed-point data a .

[0356] a.2) Find the maximum absolute value by stratification and classification

[0357] Specifically, each element in the first input data vector / matrix is ​​a i (l) , where a (l) Can be the input neuron X (l) Or output neuron Y (l) Or weight W (l) Or input neuron derivatives or the output neuron derivative or weight derivative In other words, each layer of the multi-layer network model includes input neurons, weights, output neurons, input neuron derivatives, weight derivatives, and output neuron derivatives. The decimal point position of the first input data includes the decimal point position of the input neurons, the decimal point position of the weights, the decimal point position of the output neurons, the decimal point position of the input neuron derivatives, the decimal point position of the weight derivatives, and the decimal point position of the output neuron derivatives. The input neurons, weights, output neurons, input neuron derivatives, weight derivatives, and output neuron derivatives are all represented by matrices / vectors. By traversing all elements in the vectors / matrices of each type of data in each layer of the multi-layer network model, the maximum absolute value of each category of data is obtained, that is, By formula: Determine the decimal point position of each category of data a at level l

[0358] a.3) Find the maximum absolute value by stratification and classification

[0359] Specifically, each element in the first input data vector / matrix is ​​a i (l) , where a (l)Can be the input neuron X (l) Or output neuron Y (l) Or weight W (l) Or input neuron derivatives or the output neuron derivative or weight derivative In other words, the data categories of each layer of the multi-layer network model include input neurons, weights, output neurons, input neuron derivatives, weight derivatives, and output neuron derivatives. Each type of data of each layer of the multi-layer network model is divided into g groups, or grouped by any other grouping rules. Then, each element of each group of data in the g groups of data corresponding to each type of data in each layer of the multi-layer network model is traversed to obtain the element with the largest absolute value in the group of data, that is, By formula Determine the decimal point position of each group of g data corresponding to each data category in each layer

[0360] Among them, the above-mentioned arbitrary grouping rules include but are not limited to grouping according to data range, grouping according to data training batches and other rules.

[0361] b) Initializing the decimal point position s of the first input data according to the minimum absolute value of the first input data:

[0362] Specifically, find the absolute minimum value a of the data to be quantized min , the fixed-point accuracy s is determined by the following formula.

[0363]

[0364] Among them, the above a min is the absolute minimum value of the first input data. Get a min The specific process can be found in the above steps a.1), a.2), and a.3).

[0365] c) Initialize the fixed-point precision s according to the relationship between different data types in the first input data:

[0366] Specifically, the data type a of any layer (such as layer l) in a multi-layer network model (l) The decimal point position The data type b of the lth layer can be (l) The decimal point position According to the formula Sure.

[0367] Among them, a (l) and b (l) Can be the input neuron X (l) Or output neuron Y (l) Or weight W(l) Or input neuron derivatives or the output neuron derivative or weight derivative Among them, a (l) and b (l) is an integer constant.

[0368] d) Initialize the decimal point of the first input data for child s according to the empirical constant:

[0369] Specifically, the data type a of any layer (such as the lth layer) of the above multi-layer network model (l) The decimal point position s a (l) Can be set manually a (l) =c, where c is an integer constant, the above a (l) Can be the input neuron X (l) Or output neuron Y (l) Or weight W (l) Or input neuron derivatives or the output neuron derivative or weight derivative

[0370] Preferably, the decimal point initialization value of the above-mentioned input neuron and the decimal point initialization value of the output neuron can be selected in the range of [-8, 8]; the decimal point initialization value of the weight can be selected in the range of [-17, 8], the decimal point initialization value of the input neuron derivative and the decimal point initialization value of the output neuron derivative can be selected in the range of [-40, -20]. The decimal point initialization value of the weight derivative can be selected in the range of [-48, -12].

[0371] The following specifically introduces the method of dynamically adjusting the decimal point position s of the data.

[0372] The method of dynamically adjusting the decimal point position s includes adjusting s upward (s becomes larger) and adjusting s downward (s becomes smaller). Specifically, it includes adjusting upward in a single step according to the maximum absolute value of the first input data; adjusting upward in a step-by-step manner according to the maximum absolute value of the first input data; adjusting upward in a single step according to the distribution of the first input data; adjusting upward in a step-by-step manner according to the distribution of the first input data; and adjusting downward in a step-by-step manner according to the maximum absolute value of the first input data.

[0373] a) Adjust upwards in a single step according to the maximum absolute value of the data in the first input data:

[0374] Assuming that the decimal point position before adjustment is s_old, the fixed-point data corresponding to the decimal point position s_old can represent the data range of [neg, pos]. Where pos = (2 bitnum-1-1)*2 s_old , neg=-(2 bitnum-1 -1)*2 s_old When the maximum absolute value a of the data in the first input data is max ≥pos, the decimal point position after adjustment is Otherwise, the decimal point position is not adjusted, that is, s_new=s_old.

[0375] b) Adjust upward step by step according to the maximum absolute value of the data in the first input data:

[0376] Assuming that the decimal point position before adjustment is s_old, the fixed-point data corresponding to the decimal point position s_old can represent the data range of [neg, pos], where pos = (2 bitnum-1 -1)*2 s_old , neg=-(2 bitnum-1 -1)*2 s_old When the maximum absolute value a of the data in the first input data is max ≥pos, the decimal point position after adjustment is s_new=s_old+1; otherwise, the decimal point position is not adjusted, that is, s_new=s_old.

[0377] c) Adjust upwards in a single step according to the first input data distribution:

[0378] Assuming that the decimal point position before adjustment is s_old, the fixed-point data corresponding to the decimal point position s_old can represent the data range of [neg, pos], where pos = (2 bitnum-1 -1)*2 s_old , neg=-(2 bitnum-1 -1)*2 s_old . Calculate the statistics of the absolute value of the first input data, such as the mean of the absolute value a mean and the standard deviation of the absolute value a std . Set the maximum range of data a max =a mean +na std . when a max ≥pos, Otherwise, the decimal point position is not adjusted, that is, s_new=s_old.

[0379] Preferably, the above n can be 2 or 3

[0380] d) Adjust upward step by step according to the first input data distribution:

[0381] Assuming that the decimal point position before adjustment is s_old, the fixed-point data corresponding to the decimal point position s_old can represent the data range of [neg, pos], where pos = (2 bitnum-1 -1)*2 s_old , neg=-(2 bitnum-1 -1)*2 s_old . Calculate the statistics of the absolute value of the first input data, such as the mean of the absolute value a mean and the standard deviation of the absolute value a std . Set the maximum range of data a max =a mean +na std , n can be 3. max ≥pos, s_new=s_old+1, otherwise the decimal point position is not adjusted, that is, s_new=s_old.

[0382] e) Adjust downward according to the maximum absolute value of the data to be quantified:

[0383] Assuming that the decimal point position before adjustment is s_old, the fixed-point data corresponding to the decimal point position s_old can represent the data range of [neg, pos], where pos = (2 bitnum-1 -1)*2 s_old , neg=-(2 bitnum-1 -1)*2 s_old When the absolute value of the first input data is the maximum value a max <2 s_old+(bitnum-n) And s_old≥s min When s_new=s_old-1, n is an integer constant, s min Can be an integer or negative infinity.

[0384] Preferably, the above n is 3, the above s min is -64.

[0385] Optionally, the frequency of adjusting the decimal point position may be that the decimal point position of the first input data is never adjusted; or it is adjusted once every n first training cycles (i.e., iterations), where n is a constant; or it is adjusted once every n second training cycles (i.e., epochs), where n is a constant; or it is adjusted once every n first training cycles or n second training cycles, and once every n first training cycles or second training cycles, and then n=αn is adjusted, where α is greater than 1; or it is adjusted once every n first training cycles or second training cycles, and n is gradually reduced as the number of training rounds increases.

[0386] Preferably, the decimal point positions of input neurons, weights and output neurons are adjusted once every 100 first training cycles, and the decimal point positions of input neuron derivatives and output neuron derivatives are adjusted once every 20 first training cycles.

[0387] It should be noted that the first training cycle is the time required to train a batch of samples, and the second training cycle is the time required to train all training samples once.

[0388] It should be pointed out that the above-mentioned computing device and the above-mentioned operation device are the same device, and the two names are interchangeable.

[0389] It should be noted that the above-mentioned initialization and adjustment of the decimal point position of the above-mentioned data by the average value or median value of the absolute value of the above-mentioned data can be specifically referred to the relevant description of initialization and adjustment of the decimal point position of the above-mentioned data by the maximum value of the absolute value of the data, which will not be described here.

[0390] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0391] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0392] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be electrical or other forms.

[0393] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0394] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of a software program module.

[0395] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or CD-ROM and other media that can store program codes.

[0396] A person skilled in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing the relevant hardware through a program, and the program may be stored in a computer-readable memory, which may include a flash drive, ROM, RAM, a magnetic disk or an optical disk, etc.

[0397] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of ​​the present application. At the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A computing device, It is characterized in that The computing device is used to perform the calculation of the network model, the network model includes: a neural network model and / or a non-neural network model; the computing device includes: an operation unit, a controller unit and a storage unit, the storage unit includes: a data input and output unit; The data input and output unit is used to obtain at least one input data, a network model and a calculation instruction, wherein the at least one input data is fixed-point data; The controller unit is configured to extract the computing instruction from the storage unit, decode the computing instruction to obtain one or more computing instructions, and send the one or more computing instructions and the at least one input data to the computing unit; The computing unit is used to perform a calculation on the at least one input data according to the one or more computing instructions to obtain a result of the computing instruction, wherein the result of the computing instruction is floating-point data; The data input and output unit further acquires a data conversion instruction, wherein the data conversion instruction includes an operation field and an operation code, wherein the operation code is used to indicate a function of the data conversion instruction, and the operation field of the data conversion instruction includes a decimal point position of the input data and a conversion mode identifier of the data type; The controller unit also includes: The instruction processing unit is further configured to obtain the data conversion instruction from the storage unit when the at least one input data is floating point data, and parse the data conversion instruction to obtain the decimal point position of the input data and the conversion mode identifier of the data type; A data conversion unit, configured to convert the at least one input data into fixed-point data according to a decimal point position of the input data and a conversion mode identifier of the data type; The controller unit sends the decimal point position of the at least one input data to the operation unit, and the operation unit further includes: A derivation unit is configured to derive a decimal point position of one or more intermediate results according to a decimal point position of the at least one input data.

2. The device according to claim 1, It is characterized in that The storage unit also includes: A storage medium, used for storing the network model and the at least one input data; The scalar data storage unit is used to store scalar data.

3. The device according to claim 1, It is characterized in that The controller unit comprises: An instruction cache unit, used to store computing instructions associated with the network model; An instruction processing unit, configured to decode the computing instruction pair to obtain the one or more operation instructions; The storage queue unit is used to store an instruction queue, which includes one or more operation instructions or calculation instructions to be executed in a front-to-back order of the queue.

4. The device according to claim 3, It is characterized in that The computing unit comprises: a dependency processing unit, configured to determine whether a first operation instruction has an association relationship with a zeroth operation instruction before the first operation instruction, and if the first operation instruction has an association relationship with the zeroth operation instruction, cache the first operation instruction in the instruction storage unit, and extract the first operation instruction from the instruction storage unit and transmit it to the operation unit after the zeroth operation instruction is executed; The determining whether the first operation instruction has an association relationship with the zeroth operation instruction before the first operation instruction comprises: Extracting a first storage address interval of data required in the first operation instruction according to the first operation instruction, and extracting a zeroth storage address interval of data required in the zeroth operation instruction according to the zeroth operation instruction, and if the first storage address interval and the zeroth storage address interval have an overlapping area, determining that the first operation instruction and the zeroth operation instruction have an associated relationship, and if the first storage address interval and the zeroth storage address interval do not have an overlapping area, determining that the first operation instruction and the zeroth operation instruction do not have an associated relationship; The first operation instruction and the zeroth operation instruction are any two of the multiple operation instructions.

5. The device according to any one of claims 1 to 3, It is characterized in that The computing unit includes: a plurality of computing modules, the plurality of computing modules are used to perform calculations of n pipeline stages; The operation unit is specifically used to perform a first pipeline stage calculation on the at least one input data to obtain a first intermediate result, input the first intermediate result to the second pipeline stage to perform the second pipeline stage calculation to obtain a second intermediate result, ..., input the n-1th intermediate result to the nth pipeline stage to perform the nth pipeline stage calculation to obtain an nth intermediate result, and input the nth intermediate result to the storage unit, where n is an integer greater than or equal to 3.

6. The device according to claim 1, It is characterized in that The computing unit also includes: A data cache unit is used to cache the one or more intermediate results.

7. The device according to any one of claims 1 to 4, It is characterized in that The computing unit includes a main processing circuit, a branch processing circuit and a plurality of slave processing circuits. The main processing circuit is used to distribute the input data A into multiple data blocks, and send at least one data block of the multiple data blocks and a calculation instruction for the input data A to the branch processing circuit, wherein the input data A is any one of the at least one input data; The branch processing circuit is used to forward data between the main processing circuit and the plurality of slave processing circuits; The plurality of slave processing circuits are used to perform operations on the received data blocks according to the operation instruction to obtain at least one intermediate result, and transmit the at least one intermediate result to the branch processing circuit; The main processing circuit is used to process at least one intermediate result sent by the branch processing circuit to obtain a result of the calculation instruction, and send the result of the calculation instruction to the controller unit; Wherein, the at least one intermediate result is floating point data.

8. The device according to any one of claims 1 to 4, It is characterized in that The computing unit includes a master processing circuit and a plurality of slave processing circuits; The multiple slave processing circuits are distributed in an array; each slave processing circuit is connected to other adjacent slave processing circuits, and the master processing circuit is connected to K slave processing circuits among the multiple slave processing circuits, and the K slave processing circuits are: n slave processing circuits in the first row, n slave processing circuits in the mth row, and m slave processing circuits in the first column; The K slave processing circuits are used to forward data and instructions between the master processing circuit and the plurality of slave processing circuits; The master processing circuit is used to distribute the input data A into multiple data blocks, and send at least one data block among the multiple data blocks and a calculation instruction for the input data A to participate in the calculation to the K slave processing circuits, wherein the input data A is any one of the at least one input data; The K slave processing circuits are used to convert data between the master processing circuit and the plurality of slave processing circuits; The multiple slave processing circuits are used to perform operations on the received data blocks according to the operation instruction to obtain at least one intermediate result, and transmit the at least one intermediate result to the K slave processing circuits; The main processing circuit is used to process at least one intermediate result sent by the K slave processing circuits to obtain a result of the calculation instruction, and send the result of the calculation instruction to the controller unit; Wherein, the at least one intermediate result is floating point data.

9. The device according to claim 8, It is characterized in that The main processing circuit is specifically used to combine and sort the intermediate results sent by multiple processing circuits to obtain the result of the calculation instruction; Or the main processing circuit is specifically used to combine and sort the intermediate results sent by multiple processing circuits and obtain the result of the calculation instruction after activation processing.

10. The device according to claim 8, It is characterized in that The main processing circuit includes: one or any combination of a conversion processing circuit, an activation processing circuit, and an addition processing circuit; The conversion processing circuit is used to perform an exchange between a first data structure and a second data structure on a data block or an intermediate result received by the main processing circuit; or to perform an exchange between a first data type and a second data type on a data block or an intermediate result received by the main processing circuit; The activation processing circuit is used to perform activation operations on data in the main processing circuit; The addition processing circuit is used to perform addition operation or accumulation operation.

11. The device according to claim 8, It is characterized in that The slave processing circuit includes: a multiplication processing circuit; The multiplication processing circuit is used to perform a multiplication operation on the received data block to obtain a product result.

12. The device according to claim 11, It is characterized in that The slave processing circuit further includes: an accumulation processing circuit, and the accumulation processing circuit is used to perform an accumulation operation on the product result to obtain the intermediate result.

13. A neural network computing device, It is characterized in that The neural network operation device includes one or more computing devices according to any one of claims 1 to 12, which are used to obtain data to be operated and control information from other processing devices, and perform specified neural network operations, and transmit the execution results to other processing devices through an I / O interface; When the neural network computing device includes a plurality of computing devices, the plurality of computing devices may be connected and transmit data through a specific structure; Wherein, the plurality of computing devices are interconnected and transmit data via a PCIE bus to support the operation of a larger neural network; the plurality of computing devices share the same control system or have their own control system; The plurality of computing devices share memory or have their own memory; the interconnection method of the plurality of computing devices is any interconnection topology.

14. A combined processing device, It is characterized in that The combined processing device includes the neural network computing device as claimed in claim 13, a universal interconnection interface and other processing devices; The neural network computing device interacts with the other processing devices to jointly complete the computing operations specified by the user.

15. The combined processing device according to claim 14, It is characterized in that It also includes: a storage device, which is connected to the neural network operation device and the other processing device respectively, and is used to store data of the neural network operation device and the other processing device.

16. A neural network chip, It is characterized in that The neural network chip includes the neural network operation device as described in claim 13 or the combined processing device as described in claim 14 or the combined processing device as described in claim 15.

17. An electronic device, It is characterized in that The electronic device comprises the chip according to claim 16.

18. A method of calculation, It is characterized in that The method is used to perform calculation of a network model, wherein the network model includes: a neural network model and / or a non-neural network model, and the method includes: Acquire at least one input data, the network model and a calculation instruction, wherein the at least one input data is fixed-point data; Decoding the computing instruction to obtain one or more operation instructions; Execute calculation on the at least one input data according to the one or more operation instructions to obtain a result of the calculation instruction, wherein the result of the calculation instruction is floating-point data; When the at least one input data is floating point data, the method further comprises: Acquire a data conversion instruction, the data conversion instruction including an operation code and an operation field, the operation code is used to indicate a function of the data conversion instruction, and the operation field includes a decimal point position of input data and a conversion mode identifier of a data type; Parsing the data conversion instruction to obtain a conversion method identifier of a decimal point position and a data type of the input data; Converting the at least one input data into fixed-point data according to the decimal point position of the input data and the conversion mode identifier of the data type; The method further comprises: The decimal point position of the one or more intermediate results is derived according to the decimal point position of the at least one input data.

19. The method according to claim 18, It is characterized in that The performing calculation on the at least one input data according to the one or more operation instructions to obtain the result of the calculation instruction comprises: The second input data is operated according to the one or more operation instructions to obtain one or more intermediate results, wherein the last intermediate result of the one or more intermediate results is the result of the calculation instruction; When the last intermediate result is fixed-point data, the last intermediate result is converted into floating-point data according to the decimal point position of the last intermediate result.