Data processing device, method, acceleration unit, electronic device and storage medium
By designing a memory computing core that integrates storage and calculation in the AI chip, and using cross matrix and vector operation units to perform neural network model operations, the problem of high computing power and limited data transmission bandwidth of the computing unit in the AI chip is solved, and efficient Neural network model execution.
Patent Information
- Application Number
- CN202410757509.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-06-13
AI Technical Summary
The computing units in the existing AI chip architecture have high computing power, but the data transmission bandwidth is limited, resulting in high computational time complexity.
A data processing device and acceleration unit are designed, including a cross matrix, input memory, vector operation unit, output memory and a microcontroller. By executing the calculation of the neural network model in the memory computing core, it avoids the need for external memory and the processor. Data transmission realizes an integrated storage and calculation architecture.
It greatly reduces the computational time complexity, improves the execution efficiency and throughput of the neural network model, and solves the problem of high computing power of the computing unit and limited data transmission bandwidth.
Smart Images

Figure CN118333118B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of artificial intelligence chip technology, and in particular, to a data processing device, method, acceleration unit, electronic device, and computer-readable storage medium. Background Art
[0002] According to the development history, DNN (Deep Neural Network) runs on general-purpose processors. Although this solution is still widely adopted, they are not enough to meet the application fields with power range below watt or a few watts. For this reason, customized hardware platforms have emerged to achieve low power consumption and efficient execution of DNN, but the cost is time-consuming circuit design, and to some extent, the scale of calculation is limited, and hardware-aware training of DNN is usually required.
[0003] Independent of the hardware platform, whether it is a general-purpose processor or an ASIC (Application Specific Integrated Circuit), different performance can be achieved depending on the computing paradigm used. In general, the von Neumann architecture is inherently limited in performance due to the need to move data from memory to the computing unit: in modern DNN models, the number of parameters can reach hundreds of millions and retrieving them from memory will severely affect performance. This phenomenon is also called the von Neumann bottleneck and has triggered many research works on alternative non-von Neumann paradigms.
[0004] Some of the current AI chip architectures only implement near-storage computing, that is, the computing unit is adjacent to the storage unit and connected using a high-speed interconnect bus to increase bandwidth and shorten the data path. However, there is still a contradiction between the high computing power of the computing unit and the limited data transmission bandwidth. Summary of the invention
[0005] An embodiment of the present invention provides a data processing device, method, acceleration unit, electronic device and computer-readable storage medium to solve the problem that the architecture of existing AI chips has high computing power of computing units but limited data transmission bandwidth.
[0006] The embodiment of the present invention discloses a data processing device, comprising: a cross matrix, an input memory, a vector operation unit, an output memory and a microcontroller;
[0007] The input memory is used to store data that the data processing device needs to perform calculation operations;
[0008] The cross matrix and the vector operation unit are used to implement the operation of the data processing device;
[0009] The output memory is used to store the data obtained after the data processing device completes the calculation operation;
[0010] The microcontroller is used to realize the logical functions of the data processing device.
[0011] The embodiment of the present invention discloses a data processing method, which is applied to a data processing device, wherein the device comprises: a cross matrix, an input memory, a vector operation unit, an output memory and a microcontroller, and the method comprises:
[0012] The data that the data processing device needs to perform calculation operations on is stored in the input memory;
[0013] Execute the computing operation of the data processing device by means of the cross matrix and the vector computing unit;
[0014] The output memory stores the data obtained after the data processing device completes the calculation operation;
[0015] The data in the input memory is stored by the microcontroller, the data in the input memory is sent to the cross matrix and the vector operation unit to perform the operation, and the data obtained after the operation is completed is sent to the output memory for data storage.
[0016] The embodiment of the present invention discloses an acceleration unit for executing a neural network model, the acceleration unit comprising: a plurality of memory computing cores, an on-chip interconnect bus, a memory read-write circuit and a high-speed digital interface, the memory computing core comprising a cross matrix, an input memory, a vector operation unit, an output memory and a microcontroller;
[0017] The multiple memory computing cores communicate with each other via the on-chip interconnect bus;
[0018] The memory read / write circuit and the high-speed digital interface are used to load input data into the input memory of the memory computing core;
[0019] The cross matrix and the vector operation unit are used to perform operations of the neural network model;
[0020] The output memory is used to cache the output data obtained after the cross matrix and the vector operation unit perform the operation of the neural network model;
[0021] The output data obtained by the memory computing core is used as the input data and loaded into the input memory of the next memory computing core through the on-chip interconnection bus;
[0022] The microcontroller is used to implement the logical functions of the memory computing core.
[0023] The embodiment of the present invention further discloses a data processing method, which is applied to an acceleration unit for executing a neural network model, wherein the acceleration unit comprises: a plurality of memory computing cores, an on-chip interconnect bus, a memory read-write circuit, and a high-speed digital interface, wherein the memory computing core comprises a cross matrix, an input memory, a vector operation unit, an output memory, and a microcontroller, wherein the plurality of memory computing cores communicate with each other through the on-chip interconnect bus, and wherein the method comprises:
[0024] Determine a target memory computing core for executing the neural network model and a data transmission path between the target memory computing cores;
[0025] According to the data transmission path, the image data of the neural network model is loaded into the input memory of the first memory computing core through the memory read-write circuit and the high-speed digital interface;
[0026] Execute operations of the first memory computing core through the cross matrix of the first memory computing core and the vector operation unit of the first memory computing core to obtain activation data of the first memory computing core;
[0027] caching activation data of the first memory computing core through the output memory of the first memory computing core; the activation data of the first memory computing core is a calculation result obtained after the calculation of the first memory computing core is completed;
[0028] According to the data transmission path, the activation data of the first memory computing core is loaded into the input memory of the second memory computing core through the memory read-write circuit and the high-speed digital interface, and the operation of the second memory computing core is performed through the cross matrix of the second memory computing core and the vector operation unit of the second memory computing core to obtain the activation data of the second memory computing core, and cache it in the output memory of the second memory computing core; wherein, the first memory computing core and the second memory computing core belong to some memory computing cores in the target memory computing core, and the operation of the first memory computing core and the operation of the second memory computing core belong to the operation of the neural network model;
[0029] The activation data of the second memory computing core is output to the neural network model through the memory read and write circuit and the high-speed digital interface, so that the neural network model completes the processing of the image data.
[0030] Optionally, performing operations of the first memory computing core through a cross matrix of the first memory computing core and a vector operation unit of the first memory computing core to obtain activation data of the first memory computing core includes:
[0031] The kernel matrix of the neural network model is mapped to the cross matrix of the first memory computing core through an intra-layer parallel method, a convolution operation is performed through the cross matrix of the first memory computing core and the image data to obtain the convolution result of the first memory computing core, and the convolution result is activated and pooled by the vector operation unit of the first memory computing core to obtain the activation data of the first memory computing core.
[0032] Optionally, the kernel matrix includes multiple weight matrices, and the intra-layer parallel method includes input channel parallelism, output channel parallelism, input feature map parallelism, and output feature map parallelism.
[0033] Optionally, mapping the kernel matrix of the neural network model to the cross matrix of the first memory computing core through an intra-layer parallel method, performing a convolution operation on the cross matrix of the first memory computing core and the image data to obtain a convolution result of the first memory computing core, and activating and pooling the convolution result through a vector operation unit of the first memory computing core to obtain activation data of the first memory computing core, includes:
[0034] When the intra-layer parallel method is the input channel parallelism, the image data and the input channel of the kernel matrix are split to obtain a plurality of first split matrices, the plurality of first split matrices are respectively mapped to the cross matrix of the first memory computing kernel, the convolution operation, the activation and pooling operation are performed to obtain a plurality of first output results, and the plurality of first output results are added to obtain first activation data;
[0035] When the intra-layer parallel method is the output channel parallelism, the multiple weight matrices are respectively mapped to the cross matrix of the first memory computing core, the convolution operation, the activation and pooling operation are performed to obtain multiple second output results, and the multiple second output results are spliced to obtain second activation data;
[0036] When the intra-layer parallel method is the input feature map parallelism, the kernel matrices of the plurality of neural network models are respectively mapped to the cross matrix of the first memory computing kernel, and the convolution operation, the activation and pooling operation are performed to obtain a plurality of third activation data;
[0037] When the intra-layer parallel method is the output feature map parallelism, the activation data is dimensionally split to obtain a plurality of second split matrices, the plurality of second split matrices are respectively mapped to the cross matrix of the first memory computing core, the convolution operation, the activation and pooling operation are performed to obtain a plurality of fourth output results, and the plurality of fourth output results are spliced to obtain fourth activation data;
[0038] The first activation data, the second activation data, the third activation data and the fourth activation data are used as activation data of the first memory computing core.
[0039] Optionally, mapping the kernel matrix of the neural network model to the cross matrix of the first memory computing kernel includes:
[0040] According to the number of output channels of the kernel matrix, the kernel matrix is mapped to adjacent columns of the cross matrix of the first memory computing kernel.
[0041] Optionally, the kernel matrix includes a plurality of weight matrices, and after mapping the kernel matrix of the neural network model to the cross matrix of the first memory computing kernel, the method further includes:
[0042] The mapped multiple weight matrices are positionally shifted on the cross matrix of the first memory computing core.
[0043] Optionally, loading the image data of the neural network model into the input memory of the first memory computing core includes:
[0044] Loading adjacent pixels in the image data into the input memory of the first memory computing core;
[0045] Or, different pixels in the picture data are loaded into a storage basic unit in the input memory of the first memory computing core, and the remaining bits of the storage basic unit containing the last pixel of the picture data are left blank; the different pixels in the picture data belong to the same row of pixels;
[0046] Or, load the same pixels in the image data into two storage basic units in the input memory of the first memory computing core, and leave the remaining bits of the last pixel storage basic unit containing the image data empty.
[0047] Optionally, before loading the activation data of the first memory computing core into the input memory of the second memory computing core through the memory read / write circuit and the high-speed digital interface according to the data transmission path, the method further includes:
[0048] The logical functions of the first memory computing core are implemented by the microcontroller of the first memory computing core.
[0049] Optionally, the microcontroller is a core of an open source instruction set architecture based on a reduced instruction set principle, and the microcontroller includes an on-chip interconnect bus control module, a direct memory access module, a matrix operation control module, a vector operation control module, an external bus module core and an internal bus module.
[0050] Optionally, the implementing the logic function of the first memory computing core by the microcontroller of the first memory computing core includes:
[0051] The on-chip interconnect bus is configured through the on-chip interconnect bus control module of the first memory computing core, data packets are received and parsed, data packets are sent and packaged, data is cached, and the direct memory access module of the first memory computing core is interacted with to load the image data into the input memory of the first memory computing core;
[0052] Implementing data interaction of the first memory computing core through a direct memory access module of the first memory computing core;
[0053] The loading, storage and calculation of the picture data are realized by the matrix operation control module of the first memory computing core;
[0054] The operator of the first memory computing core is expanded through the vector operation control module of the first memory computing core.
[0055] Optionally, the direct memory access module includes a first memory access module and a second memory access module, and implementing data interaction of the first memory computing core through the direct memory access module of the first memory computing core includes:
[0056] Data interaction between the first memory computing core and the remaining memory computing cores is realized through the first memory access module of the first memory computing core; the remaining memory computing cores are the memory computing cores in the target memory computing cores except the first memory computing core;
[0057] Data interaction in the first memory computing core is achieved through the second memory access module of the first memory computing core.
[0058] Optionally, the expanding the operator of the first memory computing core through the vector operation control module of the first memory computing core includes:
[0059] The vector operation control module of the first memory computing core adopts the instruction set of the open source instruction set architecture based on the reduced instruction set principle to write an extended operator to expand the operator of the first memory computing core; the extended operator is the operator required for the neural network model operation and is an operator that cannot be implemented by the first memory computing core.
[0060] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0061] The memory is used to store computer programs;
[0062] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0063] The embodiment of the present invention further discloses a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the embodiment of the present invention.
[0064] The embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the method described in the embodiment of the present invention.
[0065] The embodiments of the present invention include the following advantages:
[0066] The embodiment of the present invention provides a data processing device, comprising: a cross matrix, an input memory, a vector operation unit, an output memory and a microcontroller; the input memory is used to store data required by the data processing device to perform the operation; the cross matrix and the vector operation unit are used to implement the operation of the data processing device; the output memory is used to store data obtained after the data processing device performs the operation; the microcontroller is used to implement the logical function of the data processing device. Through the data processing device, the embodiment of the present invention can place the storage unit and the computing unit in one device, avoiding the contradiction between the high computing power of the computing unit and the limited data transmission bandwidth, eliminating the data transmission between the external memory and the processor, and thus greatly reducing the complexity of the computing time.
[0067] The embodiment of the present invention provides a data processing method, which is applied to a data processing device, wherein the input memory is used to store data that the data processing device needs to perform calculation operations on; the cross matrix and the vector operation unit are used to perform the calculation operations of the data processing device; the output memory is used to store data obtained after the data processing device completes the calculation operations; the microcontroller is used to implement data storage in the input memory, the data in the input memory is sent to the cross matrix and the vector operation unit to perform the calculation operations, and the data obtained after the calculation operations are completed is sent to the output memory for data storage. The embodiment of the present invention uses this data processing method to implement data storage and calculation through one device, avoiding the contradiction between high computing power of the computing unit and limited data transmission bandwidth, eliminating the need for data transmission between the external memory and the processor, and thus greatly reducing the complexity of computing time.
[0068] An embodiment of the present invention provides an acceleration unit for executing a neural network model, comprising: multiple memory computing cores, an on-chip interconnect bus, a memory read-write circuit and a high-speed digital interface, wherein the memory computing core comprises a cross matrix, an input memory, a vector operation unit, an output memory and a microcontroller; the multiple memory computing cores communicate with each other through the on-chip interconnect bus; the memory read-write circuit and the high-speed digital interface are used to load input data into the input memory of the memory computing core; the cross matrix and the vector operation unit are used to perform operations on the neural network model; the output memory is used to cache output data obtained after the cross matrix and the vector operation unit perform operations on the neural network model; the output data obtained by the memory computing core is used as the input data and loaded into the input memory of the next memory computing core through the on-chip interconnect bus; the microcontroller is used to implement the logical functions of the memory computing core. The embodiment of the present invention integrates multiple memory computing cores that execute operations of the neural network model into one acceleration unit through the acceleration unit, which not only can realize the placement of storage units and computing units in the memory computing core, but also can realize data transmission between multiple memory computing cores, avoiding the contradiction between high computing power of the computing unit and limited data transmission bandwidth, and eliminating the data transmission between the external memory and the processor. Therefore, it not only greatly reduces the complexity of calculation time, but also accelerates the execution of the neural network model.
[0069] An embodiment of the present invention provides a data processing method, which is applied to an acceleration unit for executing a neural network model, determines a target memory computing core for executing the neural network model and a data transmission path between the target memory computing core; according to the data transmission path, loads the image data of the neural network model into the input memory of a first memory computing core through the memory read-write circuit and the high-speed digital interface; performs operations of the first memory computing core through the cross matrix of the first memory computing core and the vector operation unit of the first memory computing core to obtain activation data of the first memory computing core; caches the activation data of the first memory computing core through the output memory of the first memory computing core; the activation data of the first memory computing core is the operation result obtained after the operation of the first memory computing core is completed; according to the data transmission path, through The memory read-write circuit and the high-speed digital interface load the activation data of the first memory computing core into the input memory of the second memory computing core, and perform the operation of the second memory computing core through the cross matrix of the second memory computing core and the vector operation unit of the second memory computing core to obtain the activation data of the second memory computing core, and cache it in the output memory of the second memory computing core; wherein the first memory computing core and the second memory computing core belong to some memory computing cores in the target memory computing core, and the operation of the first memory computing core and the operation of the second memory computing core belong to the operation of the neural network model; the activation data of the second memory computing core is output to the neural network model through the memory read-write circuit and the high-speed digital interface, so that the neural network model completes the processing of the image data. The embodiment of the present invention can perform the convolution layer operation of the neural network model through memory computing (IMC, In-Memory Computing) through the data processing method. Since the calculation is performed in the memory, the weights of the neural network model and the input image (or the activation data obtained by the intermediate calculation) are stored in the memory, eliminating the data transmission between the external memory and the processor, thereby greatly reducing the complexity of the calculation time. The operation of the neural network model is performed through the memory computing core (IMC core) inside the acceleration unit structure. During the execution of the operation, the intermediate results must be cached in the local memory of the memory computing core. By transferring the activation data obtained from the intermediate calculation to the next memory computing core, the data flow inside the acceleration unit structure is optimized, and the data is processed effectively. The acceleration unit can achieve high throughput and high efficiency execution of the neural network model, thereby accelerating the operation process of the neural network model. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 (a) is a schematic diagram of the traditional convolutional neural network calculation method;
[0071] FIG1( b ) is a schematic diagram of an in-memory computing solution provided in an embodiment of the present invention;
[0072] Figure 2 is a structural schematic diagram of a data processing device provided in an embodiment of the present invention;
[0073] Figure 3 is a flow chart of steps of a data processing method provided in an embodiment of the present invention;
[0074] Figure 4 An acceleration unit for executing a neural network model is provided in an embodiment of the present invention.
[0075] Figure 5 is a schematic diagram of communication between multiple memory computing cores provided in an embodiment of the present invention;
[0076] Figure 6 is a flow chart of steps of a data processing method provided in an embodiment of the present invention;
[0077] Figure 7 This is a simple schematic diagram of the convolutional neural network calculation process;
[0078] Figure 8 It is a schematic diagram of mapping two convolutional layers to two memory computing cores provided in an embodiment of the present invention;
[0079] Fig. 9 It is a schematic diagram of a neural network model performing pipeline parallel reasoning on n batches of inputs;
[0080] Fig.10 is a schematic diagram of four intra-layer parallel methods provided by an embodiment of the present invention;
[0081] Fig.11 It is a schematic diagram of the mapping of a kernel matrix onto a cross matrix;
[0082] Fig.12 is a schematic diagram of a convolution of an input feature map and a kernel weight provided in an embodiment of the present invention;
[0083] Fig.13 is a schematic diagram of mapping a kernel matrix on a cross matrix provided in an embodiment of the present invention;
[0084] Fig.14 is a schematic diagram of a data storage method provided in an embodiment of the present invention;
[0085] Fig.15 is a schematic diagram of functional modules of a microcontroller provided in an embodiment of the present invention;
[0086] Fig.16is a schematic diagram of a calculation process of an acceleration unit provided in an embodiment of the present invention;
[0087] Fig.17 is a schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention;
[0088] Fig.18 is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0089] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0090] In-memory computing (IMC) is a non-von Neumann paradigm that has recently emerged as a promising energy-efficient, high-throughput hardware for deep learning applications. A prominent application of IMC is to perform matrix-vector multiplication with O(1) time complexity by mapping the synaptic weights of a neural network layer onto an IMC-based device. However, due to the significant difference in computational methods from other hardware, the design of deep learning hardware using IMC requires a redesign of the architecture. The present invention focuses on the specific application IMC core for convolutional neural network (CNN) reasoning, and provides methods for implementing various architectural components of the IMC core and methods for deploying convolutional neural networks on these architectural components and accelerating computation.
[0091] Convolutional neural networks are usually composed of multiple convolutional layers, each of which contains convolution operations, activation operations, pooling operations, etc. Multiplication and addition operations are the main operations, accounting for more than 90% of the total computation. Although this example is a relatively simple network, it is very representative. Complex models are usually composed of these simple networks through the superposition of different types, and the core algorithm is still the multiplication and addition operation of matrix multiplication.
[0092] Characteristics of convolution operation:
[0093] The operation type is single, mainly multiplication and addition operations, and other types of calculations account for a very small proportion;
[0094] Model sharing: The convolutional neural network model is shared by multiple images, that is, the model remains unchanged during the inference process, while the images are constantly changing, making it easy to implement parallel computing of multiple images;
[0095] Image sharing: The input feature data of the current convolution layer is shared by all kernels of the current convolution layer. Each convolution layer only needs to load feature data once.
[0096] The operations of each kernel and feature in each convolutional layer are independent, and there is no correlation between kernels, so it is easy to implement kernel parallel operations;
[0097] When each kernel and feature are calculated, each output result is obtained by multiplying and adding the kernel and the part of the feature data corresponding to the position. Therefore, the feature can be divided into multiple parts and convolved with the same kernel at the same time to achieve parallel operation of features.
[0098] From the above characteristics, it can be seen that the calculation of convolutional neural networks is particularly suitable for large-scale parallel computing.
[0099] Referring to Figure 1 (a), a schematic diagram of the traditional convolutional neural network calculation method is shown. The processor reads the input image (X) and synaptic weight (w) (or the activation data b obtained in the middle) from the external memory, caches it in the processing cache (Cache), and the processor's operations are completed. After the calculation of Y=w*X+b is completed, the processing result is stored back in the external memory. As mentioned above, the core operation of the convolutional neural network is the multiplication and addition operation of the matrix multiplication. The method for traditional AI processors to improve computing power is to stack a large number of multiplication and addition units (PE) in the chip to adapt to the large-scale multiplication and addition operations of the convolutional neural network, but at the same time, the required multipliers and multiplicands also increase dramatically, resulting in the data transmission bandwidth not meeting the demand, that is, the contradiction of data transmission.
[0100] To solve this problem, referring to FIG. 1 (b), a schematic diagram of a memory computing solution provided in an embodiment of the present invention is shown. By using a group of resistance-based or charge-based storage devices, such as memristors, and organizing these devices in a cross matrix configuration, memory computing is equivalent to integrating the entire column of PE calculations in FIG. 1 (a) into FIG. 1 (b). According to their physical properties, matrix-vector multiplication can be performed with O(1) time complexity, which is completely different from the O(N^2) of the traditional architecture. Since the calculation is performed in memory, and the kernel weights and input images of the convolutional neural network (or the processing results obtained by the intermediate calculation) are stored in the memory, the data transmission between the external memory and the processor is eliminated, so the calculation time complexity is greatly reduced. Among them, the memory computing (IMC0) is connected to the chip through pins.
[0101] Reference Figure 2 , shows a schematic diagram of the structure of a data processing device provided in an embodiment of the present invention, wherein the device specifically includes a cross matrix, an input memory, a vector operation unit, an output memory and a microcontroller. The data processing device in the embodiment of the present invention is an in-memory computing core (IMC core).
[0102] The input memory is used to store data that the data processing device needs to perform calculation operations;
[0103] The cross matrix and the vector operation unit are used to implement the operation of the data processing device;
[0104] The output memory is used to store the data obtained after the data processing device completes the calculation operation;
[0105] The microcontroller is used to realize the logical functions of the data processing device.
[0106] The embodiment of the present invention uses the data processing device to place the storage unit and the computing unit in one device, avoiding the contradiction between the high computing power of the computing unit and the limited data transmission bandwidth, and eliminating the data transmission between the external memory and the processor, thereby greatly reducing the complexity of the calculation time.
[0107] Reference Figure 3 , showing a flow chart of the steps of a data processing method provided in an embodiment of the present invention, applied to Figure 2 A data processing device, the method comprising:
[0108] Step 301: storing data required for operation by the data processing device through the input memory;
[0109] Step 302: Execute the computing operation of the data processing device through the cross matrix and the vector computing unit;
[0110] Step 303: storing the data obtained after the data processing device completes the calculation operation in the output memory;
[0111] Step 304: Implement data storage in the input memory through the microcontroller, send the data in the input memory to the cross matrix and the vector operation unit to perform the operation, and send the data obtained after the operation is completed to the output memory for data storage.
[0112] The embodiment of the present invention uses the data processing method to realize data storage and calculation through one device, avoiding the contradiction between high computing power of the computing unit and limited data transmission bandwidth, eliminating the need for data transmission between the external memory and the processor, and thus greatly reducing the complexity of calculation time.
[0113] Reference Figure 4, shows an acceleration unit for executing a neural network model provided in an embodiment of the present invention, including: multiple memory computing cores, an on-chip interconnect bus, a memory read-write circuit, and a high-speed digital interface, wherein the memory computing core includes a cross matrix, an input memory, a vector operation unit, an output memory, and a microcontroller; the acceleration unit in the embodiment of the present invention is an artificial intelligence chip (AI processor).
[0114] The multiple memory computing cores communicate with each other via the on-chip interconnect bus;
[0115] The memory read-write circuit and the high-speed digital interface are used to load input data into the input memory of the memory computing core; specifically, the data exchange between the IMC core and the outside is realized through the high-speed digital interface and the memory read-write circuit. The function of this part is similar to DDR (Double Data Rate), realizing high-speed interaction with external data.
[0116] The cross matrix and the vector operation unit are used to perform operations on the neural network model; the output memory is used to cache output data obtained after the cross matrix and the vector operation unit perform operations on the neural network model; the output data obtained by the memory computing core is used as the input data and loaded into the input memory of the next memory computing core through the on-chip interconnection bus; the microcontroller is used to implement the logical functions of the memory computing core.
[0117] The embodiment of the present invention integrates multiple memory computing cores that execute operations of the neural network model into one acceleration unit through the acceleration unit, which not only can realize the placement of storage units and computing units in the memory computing core, but also can realize data transmission between multiple memory computing cores, avoiding the contradiction between high computing power of the computing unit and limited data transmission bandwidth, and eliminating the data transmission between the external memory and the processor. Therefore, it not only greatly reduces the complexity of calculation time, but also accelerates the execution of the neural network model.
[0118] In an embodiment of the present invention, the core of the acceleration unit is the IMC core, which is built around a cross matrix that performs matrix-vector multiplication and has peripheral circuits for additional functions required by CNN. Figure 2As shown in the figure, the IMC core consists of a cross matrix, input memory, vector operation unit, output memory and microcontroller. The cross matrix is a storage and computing integration, which can be based on different media such as SRAM (Static Random-Access Memory), DRAM (Dynamic Random-Access Memory), FLASH (Flash Memory), ReRAM (Resistive Random-Access Memory), PCM (Phase-Change Memory), FeFET (Ferroelectric Field-Effect Transistor), MRAM (Magnetoresistive Random-Access Memory), etc., to realize the multiplication and addition operation of matrix multiplication (i.e., the convolution operation in the convolution layer). The input memory is used to cache the input image data or the activation data calculated by the previous layer, the vector operation unit is used to realize efficient activation and pooling operations (non-linear operations in the convolution layer), and the output memory caches the calculation results of the current IMC core. The logic control of the entire IMC core is implemented by a microcontroller (MC), which is an open source riscv (open source instruction set architecture based on the reduced instruction set principle) core. The functions it implements include: caching and decoding control instructions; connecting to the on-chip interconnect bus (NOC) to achieve data exchange between other modules and input memory / output memory; and controlling the operations of the storage and computing array and vector operation unit.
[0119] Reference Figure 5 , shows a schematic diagram of communication between multiple memory computing cores provided in an embodiment of the present invention, specifically, communication is achieved through an on-chip interconnect bus.
[0120] Reference Figure 6 , shows a flow chart of the steps of a data processing method provided in an embodiment of the present invention, the method comprising:
[0121] Step 601, determining a target memory computing core and a data transmission path between target memory computing cores;
[0122] In the acceleration unit structure of the embodiment of the present invention, the number of memory computing cores inside the acceleration unit that are needed is determined according to the size of the input data of the neural network model. Therefore, before the IMC core performs calculations, it is necessary to determine the target memory computing cores required for reasoning the neural network model. In addition, in order to improve the efficiency of neural network model reasoning, the data transmission path between the target memory computing cores can be determined in advance.
[0123] Step 602: according to the data transmission path, the image data of the neural network model is loaded into the input memory of the first memory computing core through the memory read-write circuit and the high-speed digital interface;
[0124] The neural network model in the embodiment of the present invention may be a convolutional neural network or other deep learning neural network models. To facilitate the description of subsequent solutions, the neural network model is defined as a convolutional neural network.
[0125] The computational input of a convolutional neural network consists of two parts: image data and synaptic weights (constants obtained by training the neural network model, also called neural network model data). When using the acceleration unit in the embodiment of the present invention to perform convolutional neural network operations, the image data first needs to be loaded into the input memory of the first IMCcore through a high-speed digital interface and a memory read-write circuit.
[0126] Step 603: Execute operations of the first memory computing core through the cross matrix of the first memory computing core and the vector operation unit of the first memory computing core to obtain activation data of the first memory computing core;
[0127] The convolutional neural network architecture typically consists of a series of interconnected layers, each defined by learnable parameters and usually an activation function. The result of the activation function is called an activation. As the name implies, each layer of a CNN performs a convolution on the activation. The convolutional layer converts a feature map input volume of size Hin *Win*Cin into a feature map output volume of size Hout*Wout*Cout. Unless otherwise stated, the present invention considers input and output volumes of Hin=Hout=Hout and Win=Wout=W. It should be noted here that these assumptions do not affect the generality, because for layers involving pooling, strides, and padding, the methods followed in designing various architectural choices will remain unchanged. In addition, we refer to activations along the planes marked by H and W as being on the (H, W) plane.
[0128] Each convolutional layer consists of many dot products. Specifically, each output element lying in the (H, W) plane is obtained by the dot product operation between the input element of size F1*F2*Cin and the parameter matrix of the same size of this layer (also known as the kernel). Cout times the dot product is performed by applying Cout different kernel weights to obtain all Cout output channels of the output data. The result of the matrix-vector multiplication is called pre-activation. After operating on the kernel weights, the resulting pre-activation undergoes post-processing, which usually involves additive and multiplicative scaling, called batch normalization, and non-linear activation functions. Considering the above operations, the matrix-vector multiplication that converts the activation of the previous layer into the pre-activation of the next layer is particularly suitable for the IMC core, while the subsequent operations of the pre-activation are more suitable for standard digital processing units.
[0129] In a convolutional neural network, each convolutional layer has the same structure, which is composed of convolution operations and other nonlinear operations. In the embodiment of the present invention, the function of the convolutional layer is realized through the IMC core, and the matrix multiplication and addition operation (i.e., the convolution operation in the convolutional layer) needs to be realized through the cross matrix, and the efficient activation and pooling operation (nonlinear operation in the convolutional layer) needs to be realized through the vector operation unit, that is, it can be understood that the result obtained by the cross matrix in the embodiment of the present invention is activation, and the pre-activation generated is post-processed by the vector operation unit.
[0130] In order to realize the convolution operation of the convolution layer in the cross matrix, the core weights of the convolutional neural network need to be moved to the IMC core. In the embodiment of the present invention, the core weights of the convolutional neural network can be mapped to the cross matrix of the IMC core. The embodiment of the present invention solves the contradiction between chip computing power and bus bandwidth caused by the separation of computing module and data storage module in the traditional AI chip architecture. By using the IMC structure with integrated storage and computing, it is only necessary to move the core weights of the convolutional neural network to the IMC CORE for direct calculation, without the need to move the core weights to the computing unit again (i.e. avoiding the von Neumann bottleneck), thus solving the limitation of chip computing power being restricted by bus bandwidth.
[0131] Step 604: caching activation data of the first memory computing core through the output memory of the first memory computing core; the activation data of the first memory computing core is a calculation result obtained after the calculation of the first memory computing core is completed;
[0132] In an embodiment of the present invention, when the cross matrix and vector operation unit of the first memory computing core completes the operation of the convolution layer, the activation data corresponding to the first memory computing core (that is, the calculation result of the first memory computing core) will be obtained. At this time, the calculation result needs to be cached in the output memory of the first memory computing core.
[0133] Step 605: according to the data transmission path, the activation data of the first memory computing core is loaded into the input memory of the second memory computing core through the memory read-write circuit and the high-speed digital interface, and the operation of the second memory computing core is performed through the cross matrix of the second memory computing core and the vector operation unit of the second memory computing core to obtain the activation data of the second memory computing core, and cache it in the output memory of the second memory computing core; wherein, the first memory computing core and the second memory computing core belong to some memory computing cores in the target memory computing core;
[0134] In contrast to the von Neumann computing paradigm, IMC considers one operand of the matrix-vector multiplication to be physically instantiated and ready for execution. In the case of inference on CNNs, the two operands of the matrix-vector multiplication are activation data and kernel weights as described above. Based on the hardware capabilities inherent to IMC, the kernel weights of each convolutional layer are physically instantiated on the compute memory device in the IMC core and are fixed to their assigned memory compute cores during execution. This is in stark contrast to the von Neumann hardware model, in which the kernel weights of each convolutional layer must be obtained from memory and cannot be used at the same time. Therefore, in order to improve the utilization of the IMC core, we in principle want to parallelize operations across layers. CNN is a class of neural networks that is particularly suitable for this particular parallelization because, as described in the previous section, in contrast to other classes of neural networks, the matrix-vector operations of each convolutional layer only depend on a subset of the pixel population generated by the previous convolutional layer or multiple convolutional layers (i.e., the activation data obtained by the intermediate calculation). In an embodiment of the present invention, a method for performing inference on such a network by pipeline matrix-vector multiplication across different layers is proposed.
[0135] Assume that there is an array of IMC cores interconnected by a communication structure. Fundamentally, data flow means that each IMC core operates independently, receives pixels from the IMC cores interconnected with it, and triggers its own calculations based on the parameters of the convolution layer it is executing after receiving enough pixels. After the calculation is completed, it will provide data to the IMC core that needs it. The execution of the data flow will largely depend on the communication structure of the interconnected IMC core array. A high-speed on-chip interconnect bus NOC is used in the present invention, which allows any IMC core to communicate with any other IMC core through a point-to-point connection to obtain the data required by the IMC core.
[0136] Therefore, in an embodiment of the present invention, after obtaining the activation data corresponding to the first memory computing core (i.e., the calculation result of the first memory computing core), the calculation result not only needs to be cached in the output memory of the first memory computing core, but also needs to be loaded into the input memory of the second memory computing core to repeat the calculation process of the first memory computing core.
[0137] Reference Figure 7 , shows a simple schematic diagram of the convolutional neural network calculation process, which includes two convolutional layers (convolution operation + non-linear operation) and a fully connected layer (tiling), where the non-linear operation includes activation and pooling.
[0138] Reference Figure 8, showing a schematic diagram of mapping two convolutional layers to two memory computing cores provided in an embodiment of the present invention, specifically, the kernel weight w (synaptic weight, a constant obtained by training the neural network model, also called neural network model data) is loaded into the cross matrix of the first memory computing core and the second memory computing core, the image data (or the activation data obtained by the previous convolutional layer operation) is loaded into the input memory of the first memory computing core, the microcontroller controls the convolution timing to complete the convolution operation, and then the calculation result is activated and pooled in the vector operation unit to obtain the activation data, and the activation data is cached in the output memory of the first memory computing core, the second memory computing core completes the operation of the second convolutional layer, and the activation data corresponding to the first memory computing core is cached in the input memory, and the calculation process of the first memory computing core is repeated.
[0139] It should be noted that there is no absolute relationship between the number of memory computing cores and the number of convolutional layers. The number of memory computing cores needs to be determined based on the amount of data that the convolutional layer needs to process and the memory computing cores. It is possible that one memory computing core can process multiple convolutional layers, or it is possible that one convolutional layer requires multiple memory computing cores. That is, the "first" and "second" in the first memory computing core and the second memory computing core are only used to indicate the order of data flow between the memory computing cores, not to indicate the number of memory computing cores.
[0140] Reference Fig. 9 , shows a schematic diagram of a neural network model performing pipeline parallel reasoning on n batches of inputs. Assuming that the convolutional neural network at this time contains n computing layers (including convolutional layers and fully connected layers, or other matrix multiplication layers), the CNN model kernel is deployed on the n integrated memory computing (IMC) units in the first row; the IMC units in other rows repeat the kernel weights loaded by the IMC units in the first row, such as Figure 6 As shown. The number of rows of IMC units is the batch size of the input images. Using the pipeline parallel method, n batches of images (the size of each batch is rows number) can be inferred simultaneously. The general process is: at clock step 0, the first column of IMC units only infers the first layer of batch 0 input images; at step 1, the first column of IMC units starts to infer the next batch of input images, and the second column of IMC units starts to infer the second layer of batch 0; and so on to the last column of IMC units. At step n, the nth column of IMC units infers the last layer of batch 0 images.
[0141] The biggest difference between the embodiment of the present invention and the von Neumann structure is that the storage and computing are integrated, and each IMC has a separate input memory, output memory and logic control module. This architecture allows the AI chip to not spend a lot of time loading a huge convolutional neural network, and can also flexibly configure the relationship between multiple IMC cores, thereby making the AI chip more flexible. The above example is a pipeline parallelization of a neural network model on an AI chip. In addition, if the memory space allows, multiple neural network models can be loaded for parallel execution or pipeline execution.
[0142] Step 606: output the activation data of the second memory computing core to the neural network model through the memory read-write circuit and the high-speed digital interface, so that the neural network model completes the processing of the image data.
[0143] like Figure 8 As shown, assuming that the second memory computing core completes the calculation process, that is, the operation of all convolutional layers in the convolutional neural network is completed, the activation data corresponding to the second memory computing core will be obtained at this time. In order for the convolutional neural network to complete the remaining operations, the activation data corresponding to the second memory computing core needs to be sent to the convolutional neural network so that the convolutional neural network can continue to complete the processing of the input image data.
[0144] The acceleration unit structure in the embodiment of the present invention is suitable for convolutional neural networks, which solves the contradiction between chip computing power and bus bandwidth caused by the separation of computing modules and data storage modules in traditional AI chip architectures. By using the IMC structure with integrated storage and computing, it is only necessary to move the core weights of the convolutional neural network to the IMC CORE for direct calculation, without the need to move the core weights to the computing unit again (i.e. avoiding the von Neumann bottleneck), thus solving the limitation of chip computing power being restricted by bus bandwidth.
[0145] An embodiment of the present invention provides a data processing method, which is applied to an acceleration unit for executing a neural network model, determines a target memory computing core for executing the neural network model and a data transmission path between the target memory computing core; according to the data transmission path, loads the image data of the neural network model into the input memory of a first memory computing core through the memory read-write circuit and the high-speed digital interface; performs operations of the first memory computing core through the cross matrix of the first memory computing core and the vector operation unit of the first memory computing core to obtain activation data of the first memory computing core; caches the activation data of the first memory computing core through the output memory of the first memory computing core; the activation data of the first memory computing core is the operation result obtained after the operation of the first memory computing core is completed; according to the data transmission path, through The memory read-write circuit and the high-speed digital interface load the activation data of the first memory computing core into the input memory of the second memory computing core, and perform operations of the second memory computing core through the cross matrix of the second memory computing core and the vector operation unit of the second memory computing core to obtain the activation data of the second memory computing core, and cache it in the output memory of the second memory computing core; wherein, the first memory computing core and the second memory computing core belong to some memory computing cores in the target memory computing core, and the operations of the first memory computing core and the operations of the second memory computing core belong to the operations of the neural network model; the activation data of the second memory computing core is output to the neural network model through the memory read-write circuit and the high-speed digital interface, so that the neural network model completes the processing of the image data.
[0146] The embodiment of the present invention can perform the convolution layer operation of the neural network model through in-memory computing (IMC) through the data processing method. Since the calculation is performed in the memory, the weights and input images (or activation data obtained by intermediate calculation) of the neural network model are stored in the memory, eliminating the data transmission between the external memory and the processor, thereby greatly reducing the complexity of the calculation time. The operation of the neural network model is performed by the memory computing core (IMC core) inside the acceleration unit structure. During the execution of the operation, the intermediate results must be cached in the local memory of the memory computing core. By transferring the activation data obtained by the intermediate calculation to the next memory computing core, the data flow inside the acceleration unit structure is optimized, and the data is processed effectively. The acceleration unit can achieve high throughput and high efficiency execution of the neural network model, thereby accelerating the operation process of the neural network model.
[0147] In an embodiment of the present invention, the step 603, performing operations of the first memory computing core through the cross matrix of the first memory computing core and the vector operation unit of the first memory computing core to obtain activation data of the first memory computing core, includes:
[0148] The kernel matrix of the neural network model is mapped to the cross matrix of the first memory computing kernel through an intra-layer parallel method, a convolution operation is performed through the cross matrix of the first memory computing kernel and the image data to obtain the convolution result of the first memory computing kernel, and the convolution result is activated and pooled through the vector operation unit of the first memory computing kernel to obtain the activation data of the first memory computing kernel. The kernel matrix includes multiple weight matrices, and the intra-layer parallel method includes input channel parallelism, output channel parallelism, input feature map parallelism, and output feature map parallelism.
[0149] In a convolutional neural network, each convolutional layer has the same structure, which is composed of convolution operations and other nonlinear operations. In the embodiment of the present invention, the function of the convolutional layer is realized through the IMC core, and the matrix multiplication and addition operation (i.e., the convolution operation in the convolutional layer) needs to be realized through the cross matrix, and the efficient activation and pooling operation (nonlinear operation in the convolutional layer) needs to be realized through the vector operation unit, that is, it can be understood that the result obtained by the cross matrix in the embodiment of the present invention is activation, and the pre-activation generated is post-processed by the vector operation unit.
[0150] In order to realize the convolution operation of the convolution layer in the cross matrix, the core weights of the convolutional neural network need to be moved to the IMC core. In the embodiment of the present invention, the core weights of the convolutional neural network can be mapped to the cross matrix of the IMC core. The embodiment of the present invention solves the contradiction between chip computing power and bus bandwidth caused by the separation of computing module and data storage module in the traditional AI chip architecture. By using the IMC structure with integrated storage and computing, it is only necessary to move the core weights of the convolutional neural network to the IMC CORE for direct calculation, without the need to move the core weights to the computing unit again (i.e. avoiding the von Neumann bottleneck), thus solving the limitation of chip computing power being restricted by bus bandwidth.
[0151] According to the characteristics of the aforementioned convolutional neural network, an intra-layer parallel method suitable for the AI chip architecture in the embodiment of the present invention is designed. The intra-layer parallel method refers to the operation within a certain convolutional layer. CNN is usually composed of multiple convolutional layers, and the inter-layer parallel method refers to the simultaneous parallel operation of multiple convolutional layers. The intra-layer parallel method includes four parallel methods: input channel parallelism, output channel parallelism, input feature map parallelism, and output feature map parallelism.
[0152] Through the above discussion, it can be proved that the AI chip architecture provided in the embodiment of the present invention can flexibly map the CNN network and is suitable for various CNN networks or natural language (NLP) neural network model reasoning or training operations. This flexibility can realize various parallel operation methods of convolution operations, that is, the four aforementioned intra-layer parallel methods.
[0153] In one embodiment of the present invention, mapping the kernel matrix of the neural network model to the cross matrix of the first memory computing core through the intra-layer parallel method, performing a convolution operation through the cross matrix of the first memory computing core and the picture data to obtain the convolution result of the first memory computing core, and activating and pooling the convolution result through the vector operation unit of the first memory computing core to obtain the activation data of the first memory computing core, including:
[0154] When the intra-layer parallel method is the input channel parallelism, the image data and the input channel of the kernel matrix are split to obtain a plurality of first split matrices, the plurality of first split matrices are respectively mapped to the cross matrix of the first memory computing kernel, the convolution operation, the activation and pooling operation are performed to obtain a plurality of first output results, and the plurality of first output results are added to obtain first activation data;
[0155] When the intra-layer parallel method is the output channel parallelism, the multiple weight matrices are respectively mapped to the cross matrix of the first memory computing core, the convolution operation, the activation and pooling operation are performed to obtain multiple second output results, and the multiple second output results are spliced to obtain second activation data;
[0156] When the intra-layer parallel method is the input feature map parallelism, the kernel matrices of the plurality of neural network models are respectively mapped to the cross matrix of the first memory computing kernel, and the convolution operation, the activation and pooling operation are performed to obtain a plurality of third activation data;
[0157] When the intra-layer parallel method is the output feature map parallelism, the activation data is dimensionally split to obtain a plurality of second split matrices, the plurality of second split matrices are respectively mapped to the cross matrix of the first memory computing core, the convolution operation, the activation and pooling operation are performed to obtain a plurality of fourth output results, and the plurality of fourth output results are spliced to obtain fourth activation data;
[0158] The first activation data, the second activation data, the third activation data and the fourth activation data are used as activation data of the first memory computing core.
[0159] Reference Fig.10, showing a schematic diagram of four intra-layer parallel methods provided by an embodiment of the present invention. The four intra-layer parallel methods are described in detail as follows:
[0160] Input channel parallel: Fig.10 As shown in the figure, the channel of the input feature map is split into two parts, and the corresponding kernel matrix channel is also split into two parts, that is, the channels of the input feature map and the kernel matrix are split into C / 2, respectively mapped to different memory computing cores, and the final activation data (feature map) can be obtained by adding different output results;
[0161] Output channel parallel: Fig.10 As shown, different kernel matrices are mapped to different memory computing cores, each kernel matrix generates the output of a channel, and finally different output feature maps are spliced together to obtain the final activation data (feature map);
[0162] Input feature map parallelism: Fig.10 As shown, multiple neural network models (convolutional neural networks) are repeatedly arranged on the chip, and multiple neural network models are operated (inference) simultaneously;
[0163] Output feature map parallelism: Fig.10 As shown in the figure, the output feature map is split into multiple parts in the H or W dimension, and the calculations (inference) are performed on multiple memory computing cores at the same time. Finally, the different output feature maps are spliced together to obtain the final activation data (feature map).
[0164] Through the above four intra-layer parallel methods, the processing efficiency of the convolutional neural network can be improved, thereby accelerating the reasoning process of the convolutional neural network.
[0165] In one embodiment of the present invention, mapping the kernel matrix of the neural network model to the cross matrix of the first memory computing kernel includes:
[0166] According to the number of output channels of the kernel matrix, the kernel matrix is mapped to adjacent columns of the cross matrix of the first memory computing kernel.
[0167] The kernel weights (also called synaptic weights) are responsible for matrix-vector multiplication and constitute a convolutional layer. In the embodiment of the present invention, the overall kernel weight matrix of size F1*F2*Cin*Cout is referred to as the kernel matrix. In addition, for the sake of simplicity, the activation of a position in the (H, W) plane in all channels is referred to as a pixel.
[0168] Reference Fig.11, shows a schematic diagram of the mapping of a kernel matrix on a cross matrix. Without loss of generality, it is assumed that a kernel weight can be mapped to a computing storage device. Considering the common accuracy requirements of weights in DNNs and the effective accuracy provided by memory, this is a reasonable assumption for memory computing kernels. However, the embodiment of the present invention can be easily extended to the case where a single kernel weight is mapped to multiple devices. According to this mapping method, the kernel matrix is unfolded so that the kernel weight associated with an output channel is placed along a column of the cross matrix. In this way, the output channel column of the kernel matrix is mapped to the same number of adjacent columns of the cross matrix. Based on this physical layout, such as performing a matrix-vector multiplication: First, the input data (image data or activation data) retrieved from the input memory is unfolded and provided at the input row of the cross matrix, matching the corresponding row of the kernel matrix. Then, the pre-activation (i.e., the convolution result) of a single channel is read back from each column and converted into a digital value (the essence of IMC to implement convolution is digital-to-analog conversion, analog signal superposition, and analog-to-digital conversion). The pre-activation will then be digitally processed (activation and pooling), in principle implementing nonlinear functions and any other required digital processing.
[0169] In one embodiment of the present invention, the kernel matrix includes a plurality of weight matrices, and after mapping the kernel matrix of the neural network model to the cross matrix of the first memory computing kernel, the method further includes:
[0170] The mapped multiple weight matrices are positionally shifted on the cross matrix of the first memory computing core.
[0171] Fundamentally, the problem of mapping a kernel matrix to a cross matrix is to map the shape of (F1*F2*Cin)*Cout elements onto a fixed-size grid of computational memory elements. Fig.10In the example, a certain weight kernel matrix is first spread out as a one-dimensional matrix of F*F*C_I and then mapped to the cross matrix. Although the parameters F1, F2, Cin, and Cout vary from layer to layer and network to network, the most advanced CNNs for image classification usually have F1=F2. Based on this evaluation, the embodiment of the present invention sets F1=F2=3 and Cin=Cout, which is the most common set of hyperparameters in the CNN architecture. Regarding the dimension of the cross matrix, the actual implementation seems to adopt a square size, mainly for versatility and the possibility of performing reverse read operations when the matrix is also designed for training DNNs. Based on these considerations, the kernel matrix usually appears to have an aspect ratio equal to F1*F2=9 (i.e., the row size is F*F*C, and the column size is C, and they require 9 times more rows than columns), and is mapped to a cross matrix grid with an aspect ratio equal to 1, which means that during the execution of the CNN, a large number of cross switch matrix devices will eventually be unmapped and therefore not utilized. At this time, the method of parallelizing the convolution layer calculation by replicating the kernel matrix avoids this problem. For a convolutional layer, we map multiple copies of the kernel matrix onto the crossbar matrix so that multiple matrix-vector multiplications of the same layer can be performed in parallel. The number of kernel copies mapped to the crossbar array actually represents the number of dot products that can be performed in parallel on the array. Therefore, the number of kernel copies is equivalent to the parallelism of the dot product.
[0172] Reference Fig.12 , shows a schematic diagram of the convolution of an input feature map and a kernel weight provided in an embodiment of the present invention, specifically a convolution of a 4*4*C_I input feature map and a 3*3*C_I weight kernel. When the step length is 1, the convolution has 4 steps, generating a 2*2*1 output feature map. In this case, 3 kernel copies and 4 kernels can be mapped to the cross matrix. At this time, 1 step of convolution calculation can be completed, because the parallelism is 4 at this time, and 4 convolution operations are processed in 1 step. This method improves the column utilization of the cross matrix, thereby improving the computing efficiency of the memory computing kernel and accelerating the reasoning process of the neural network model. This is also a typical means of exchanging area for time.
[0173] Reference Fig.13 , showing a schematic diagram of the mapping of a kernel matrix on a cross matrix provided in an embodiment of the present invention. Because the convolution operation also requires input feature map data, the mapping of the feature map on the cross matrix is the same. The input feature map data corresponding to the kernel weight for the convolution operation is expanded into one-dimensional data F*F*C_I, and mapped to the position of the cross matrix corresponding to the corresponding kernel weight, ensuring that the input feature of the convolution operation corresponds to the kernel weight correctly. According to Fig.10 In the convolution process shown in Figure 2, the input feature map data corresponding to the two-step convolution is partially overlapped, such as Fig.11As shown, the data of 2*3*C_I is overlapped, so the current convolution operation can reuse part of the input feature map data of the previous convolution operation. At this time, in order to reuse the input feature map data, the current weight map is offset by the corresponding row, such as Fig.12 As shown in the figure, the 1*3*C_I rows are offset, which means that this convolution reuses the 2*3*C_I feature map data of the previous step. It only needs to re-read the new 1*3*C_I feature map data, which solves the problem that the cross matrix cannot be fully utilized.
[0174] In the embodiment of the present invention, a mapping method of the convolution kernel weights in the memory computing kernel is designed. This mapping method can design a suitable parallel operation according to the scale of the cross matrix of the memory computing kernel to improve the computing efficiency. In addition, the use of input feature map data reduces the time of data reading, further improving the computing efficiency.
[0175] In one embodiment of the present invention, loading the image data of the neural network model into the input memory of the first memory computing core includes:
[0176] Loading adjacent pixels in the image data into the input memory of the first memory computing core;
[0177] Or, different pixels in the picture data are loaded into a storage basic unit in the input memory of the first memory computing core, and the remaining bits of the storage basic unit containing the last pixel of the picture data are left blank; the different pixels in the picture data belong to the same row of pixels;
[0178] Or, load the same pixels in the image data into two storage basic units in the input memory of the first memory computing core, and leave the remaining bits of the last pixel storage basic unit containing the image data empty.
[0179] The data is stored in the input memory of the IMC core. The purpose of the input memory is to cache pixels, which are the input vectors for the matrix-vector multiplication performed on the cross matrix. At each time step, if the calculation conditions are met, each IMCcore must fetch a given number of pixels and provide them to the cross matrix interface to calculate the matrix-vector multiplication. In addition, an IMC core may have to store pixels received from other IMC cores. We assume that the input memory is a static random access memory (SRAM), which is usually used after the cache in ASICs.
[0180] In general, for pipeline operation of layers with a step size equal to 1, at each time node, the IMC core must obtain a number of pixels equal to the kernel size and store a pixel received from the previous layer (IMC core). The logical placement of pixels refers to the data arrangement required by the data flow required by the algorithm, and the physical placement in the local memory is the order in which the data is stored in the memory. Given that the pixel acquisition mode is related to the logical position of the pixels in the input data, in principle we prefer to store the pixels in the input memory in a way that mimics the logical position of the pixels. However, for a single network, different layers can generally have different channel depths, such as pixels in different layers are represented by different numbers of bits. In addition, the channel depth may vary from network to network. On the other hand, memory arrays such as on-chip SRAM have a fixed physical structure organized in words, each word contains a given number of bits, and the depth of the word is the total number of words. Therefore, in an embodiment of the present invention, three methods of mapping the varying data structures of pixels to the input memory are used.
[0181] Reference Fig.14 , showing a schematic diagram of a data storage method provided in an embodiment of the present invention, including intra-word adjacent placement, kernel-level interleaved placement, and pixel-level interleaved placement.
[0182] Placed adjacently within a word: Fig.14 As shown, pixels are stored adjacent to each other in memory so that different pixels can be stored on the same word. This placement mimics the logical arrangement of data so that adjacent pixels on the same row in the input data are stored adjacent to each other on the input memory. Fig.14 The word-to-word mapping of multiple pixels highlighted in the figure shows that each pixel is mapped adjacently, so pixels from different channels are mapped consecutively to physical memory. If there is enough space in a word, different pixels can be stored in the same word; for example, this is the case for pixel (0, 0) and pixel (0, 1) in word 1. For a given number of pixels to be cached, this method requires the least amount of memory, but since pixels from the same channel may be stored in different words, pixel size, word length information, and pixel index are required to obtain the read or input memory address when reading and writing memory. In addition, since the pixels in each row of the input pixel block occupy different word lengths, it is impossible to read each row of pixels in the input module with a fixed number of time steps.
[0183] Kernel-level interleaving: Fig.14 As shown, different pixels are stored in the same word provided they belong to a single row of the input module where matrix-vector multiplication must be calculated. Assume that in the figure below, the feature map volume will be convolved with a 3x3 kernel. Fig.13In the highlighted part, the pixel rows belonging to the convolution input block are [(0, 0), (0, 1), (0, 2)]; [(1, 0), (1, 1), (1, 2)]; and [(2, 0), (2, 1), (2, 2)]. Fig.13 The mapping on the input memory is shown in . The pixels of each row are stored contiguously to each other in memory. However, the remaining bits within the word containing the last pixel of the feature map are left empty. This practice of leaving part of the memory empty to allow the data to be mapped in a way that is closer to its logical location is somewhat similar to the concept of memory interleaving commonly employed in CPU memory management. Since this method leaves part of the memory empty to accommodate the location of the pixels in memory, it obviously does not use the minimum amount of memory possible for one pixel volume. As with the previous method, writing a pixel may require a different number of cycles depending on the time step. Furthermore, given that different pixels can still be stored in a word, writing requires a bit row index. During the convolution, a new row of input modules is loaded into memory at each time step where the calculation is performed. Since we place the pixels of the input module row contiguously, the number of read cycles is constant at each time step and no bit row index is required to read a row.
[0184] Pixel-level interleaving: Fig.14 As shown, different pixels are not allowed to be stored in the same word, and each pixel is stored in two memory words. The unoccupied portion of the last word storing each pixel is left empty. This is very similar to the concept of core-level interleaving, this time applied to individual pixels over the channel depth. This method has the finest granularity of logical units to be stored, and therefore makes the least efficient use of local memory. Since each pixel is interleaved individually, no bitline indexing is required to write or store a word. Also contrary to the previous method, the number of read and write cycles is constant regardless of the pixel being read or stored.
[0185] In the embodiment of the present invention, the above three data storage methods can reduce the time of data storage, improve the efficiency of data reading, and further improve the computing efficiency.
[0186] In one embodiment of the present invention, before the step 605, according to the data transmission path, the activation data of the first memory computing core is loaded into the input memory of the second memory computing core through the memory read / write circuit and the high-speed digital interface, the method further includes:
[0187] The logical functions of the first memory computing core are implemented by the microcontroller of the first memory computing core.
[0188] In the embodiment of the present invention, the logic control of the entire IMC core is implemented by a microcontroller (MC), which is an open source riscv (open source instruction set architecture based on the reduced instruction set principle) core, and the functions implemented include: caching and decoding control instructions; connecting with the on-chip interconnect bus (NOC) to realize data exchange between other modules and input memory / output memory; controlling the operation of the storage and calculation array and the vector operation unit.
[0189] Therefore, the microcontroller of the first memory computing core implements the logical functions of the first memory computing core. Similarly, the second memory computing core or other memory computing cores also implement logical functions based on the microcontroller.
[0190] In one embodiment of the present invention, the microcontroller is a core of an open source instruction set architecture based on the reduced instruction set principle, and the microcontroller includes an on-chip interconnect bus control module, a direct memory access module, a matrix operation control module, a vector operation control module, an external bus module core and an internal bus module.
[0191] In the AI chip structure of the embodiment of the present invention, since the microcontroller is the core of an open source instruction set architecture based on the reduced instruction set principle, it is compatible with the RISC-V reduced instruction set. The AI chips can also be interconnected through the on-chip mesh (Mesh) Internet network (NoC) to form an architecture with greater computing power to meet the computing power requirements of different terminals.
[0192] Reference Fig.15 , shows a functional module schematic diagram of a microcontroller provided in an embodiment of the present invention, including an on-chip interconnect bus control module, a direct memory access module, a matrix operation control module, a vector operation control module, an external bus module, and an internal bus module. The microcontroller is an open source RISCV (open source instruction set architecture based on the principle of reduced instruction set) core. Obviously, the functions of IMC core such as data access, data calculation, and interaction with other IMC cores are all implemented by the microcontroller (MC).
[0193] In one embodiment of the present invention, the implementation of the logic function of the first memory computing core by the microcontroller of the first memory computing core includes:
[0194] The on-chip interconnect bus is configured through the on-chip interconnect bus control module of the first memory computing core, data packets are received and parsed, data packets are sent and packaged, data is cached, and the direct memory access module of the first memory computing core is interacted with to load the image data into the input memory of the first memory computing core;
[0195] Implementing data interaction of the first memory computing core through a direct memory access module of the first memory computing core;
[0196] The loading, storage and calculation of the picture data are realized by the matrix operation control module of the first memory computing core;
[0197] The operator of the first memory computing core is expanded through the vector operation control module of the first memory computing core.
[0198] On-chip interconnect bus control module: configure NoC, receive or send data packets, parse received data packets or package sent data packets, cache data, etc. This module interacts with the RISC-V core and can be used to load the RISC-V driver; this module interacts with DMA (Direct Memory Access) and can load external data such as images or voices that need to be inferred and neural network model data into memory or IMC, and can also send the inferred result data to other external IMC cores.
[0199] Direct memory access module: including CDMA (Code Division Multiple Access) and SDMA (Space Division Multiple Access). CDMA is mainly used to exchange data with other IMC cores, while SDMA is mainly used for internal data interaction of the IMC core, such as data interaction between RISC-V and input and output memory, interaction between output memory and vector operation unit cache, etc.
[0200] Matrix operation control module: IMC data loading and storage, data calculation need to be performed according to special methods to improve the hardware resources and computing power of IMC.
[0201] Vector operation control module: This module uses a vector operation unit that is compatible with RISC-V vector extension instructions. It can directly use RISC-V extended vector instructions to write vector operators, such as relu (activation), norm (normalization), softmax (normalization) and other operators, to supplement the operators required for neural network model inference that IMC cannot achieve.
[0202] In an embodiment of the present invention, the direct memory access module includes a first memory access module and a second memory access module, and the data interaction of the first memory computing core is realized through the direct memory access module of the first memory computing core, including:
[0203] Data interaction between the first memory computing core and the remaining memory computing cores is realized through the first memory access module of the first memory computing core; the remaining memory computing cores are the memory computing cores in the target memory computing cores except the first memory computing core;
[0204] Data interaction in the first memory computing core is achieved through the second memory access module of the first memory computing core.
[0205] The direct memory access module in the embodiment of the present invention includes CDMA and SDMA. Through different memory access modules, CDMA is used to exchange data with other IMC cores, and SDMA is used for internal data interaction of the IMC core, such as data interaction between RISC-V and input and output memories, interaction between output memory and vector operation unit cache, etc.
[0206] In an embodiment of the present invention, the step of extending the operator of the first memory computing core through the vector operation control module of the first memory computing core includes:
[0207] The vector operation control module of the first memory computing core adopts the instruction set of the open source instruction set architecture based on the reduced instruction set principle to write an extended operator to expand the operator of the first memory computing core; the extended operator is the operator required for the neural network model operation and is an operator that cannot be implemented by the first memory computing core.
[0208] The vector operation control module in the embodiment of the present invention adopts a vector operation unit that is compatible with the RISC-V vector extension instructions. The RISC-V extended vector instructions can be directly used to write vector operators, such as relu, norm, softmax and other operators, to supplement the operators required for neural network model reasoning that cannot be implemented by IMC.
[0209] In the embodiment of the present invention, the AI chip is composed of multiple IMC cores through a meshed NoC, and each IMC core is composed of a cross matrix and vector operation unit, a microcontroller, and an input / output memory, so the entire AI chip can be summarized as consisting of storage resources, computing resources, and a controller. The reasoning calculation process of the AI chip can be regarded as the process in which data flows and is calculated in multiple IMC cores.
[0210] Therefore, the programming model of AI chips can be understood as the process of allocating memory and computing power and planning data flow for the neural network model reasoning and calculation process. Fig.16, shows a schematic diagram of the calculation process of an acceleration unit provided in an embodiment of the present invention. The control of the entire calculation process is completed by the software stack. The software stack analyzes the structure of the neural network model, converts various calculations in the neural network model into various operator calls, analyzes the memory resources, computing power resources, bandwidth resources, etc. of the entire AI chip in real time, and reasonably plans and allocates memory resources and computing power resources for various operators to complete the reasoning calculation task with maximum efficiency. The principle structure of the software stack is as follows: the top layer is the actual application business of AI. The host (host) end imports the neural network model, and the neural network model generates a neural network model and parameters that can be parsed by the firmware after the compiler is parsed, optimized, etc. The runtime initiates the reasoning task, calls the driver to write the compiled neural network model and parameters into the memory space of the firmware, generates a firmware interrupt, and starts the reasoning process of the hardware device. After receiving the interrupt from the host end, the firmware reads the neural network model parameters sent by the host end from the specified memory space, configures the neural network model parameters to the hardware device in the form of configuring registers, and then starts the hardware to complete the reasoning task. After the task is completed, the firmware triggers the host interrupt to notify the host end to read and process the reasoning results.
[0211] An embodiment of the present invention provides a data processing method, which is applied to an acceleration unit for executing a neural network model, determines a target memory computing core for executing the neural network model and a data transmission path between the target memory computing core; according to the data transmission path, loads the image data of the neural network model into the input memory of a first memory computing core through the memory read-write circuit and the high-speed digital interface; performs operations of the first memory computing core through the cross matrix of the first memory computing core and the vector operation unit of the first memory computing core to obtain activation data of the first memory computing core; caches the activation data of the first memory computing core through the output memory of the first memory computing core; the activation data of the first memory computing core is the operation result obtained after the operation of the first memory computing core is completed; according to the data transmission path, through The memory read-write circuit and the high-speed digital interface load the activation data of the first memory computing core into the input memory of the second memory computing core, and perform operations of the second memory computing core through the cross matrix of the second memory computing core and the vector operation unit of the second memory computing core to obtain the activation data of the second memory computing core, and cache it in the output memory of the second memory computing core; wherein, the first memory computing core and the second memory computing core belong to some memory computing cores in the target memory computing core, and the operations of the first memory computing core and the operations of the second memory computing core belong to the operations of the neural network model; the activation data of the second memory computing core is output to the neural network model through the memory read-write circuit and the high-speed digital interface, so that the neural network model completes the processing of the image data.
[0212] The embodiment of the present invention can perform the convolution layer operation of the neural network model through in-memory computing (IMC) through the data processing method. Since the calculation is performed in the memory, the weights and input images (or activation data obtained by intermediate calculation) of the neural network model are stored in the memory, eliminating the data transmission between the external memory and the processor, thereby greatly reducing the complexity of the calculation time. The operation of the neural network model is performed by the memory computing core (IMC core) inside the acceleration unit structure. During the execution of the operation, the intermediate results must be cached in the local memory of the memory computing core. By transferring the activation data obtained by the intermediate calculation to the next memory computing core, the data flow inside the acceleration unit structure is optimized, and the data is processed effectively. The acceleration unit can achieve high throughput and high efficiency execution of the neural network model, thereby accelerating the operation process of the neural network model.
[0213] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, 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 preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0214] In addition, an embodiment of the present invention further provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned data processing method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0215] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each process of the above-mentioned data processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0216] An embodiment of the present invention also provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned data processing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0217] Fig.17 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.
[0218] The electronic device 1700 includes but is not limited to: a radio frequency unit 1701, a network module 1702, an audio output unit 1703, an input unit 1704, a sensor 1705, a display unit 1706, a user input unit 1707, an interface unit 1708, a memory 1709, a processor 1710, and a power supply 1711. Those skilled in the art will appreciate that Fig.17 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.
[0219] It should be understood that in the embodiment of the present invention, the radio frequency unit 1701 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 1710 for processing; in addition, the uplink data is sent to the base station. Generally, the radio frequency unit 1701 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 1701 can also communicate with the network and other devices through a wireless communication system.
[0220] The electronic device provides users with wireless broadband Internet access through the network module 1702, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0221] The audio output unit 1703 can convert the audio data received by the RF unit 1701 or the network module 1702 or stored in the memory 1709 into an audio signal and output it as sound. Moreover, the audio output unit 1703 can also provide audio output related to a specific function performed by the electronic device 1700 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 1703 includes a speaker, a buzzer, a receiver, etc.
[0222] The input unit 1704 is used to receive audio or video signals. The input unit 1704 may include a graphics processor (GPU) 17041 and a microphone 17042. The graphics processor 17041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 1706. The image frame processed by the graphics processor 17041 can be stored in the memory 1709 (or other storage medium) or sent via the radio frequency unit 1701 or the network module 1702. The microphone 17042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 1701 in the case of a telephone call mode.
[0223] The electronic device 1700 also includes at least one sensor 1705, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 17061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 17061 and / or the backlight when the electronic device 1700 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 1705 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0224] The display unit 1706 is used to display information input by the user or information provided to the user. The display unit 1706 may include a display panel 17061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0225] The user input unit 1707 can be used to receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 1707 includes a touch panel 17071 and other input devices 17072. The touch panel 17071, also known as a touch screen, can collect user touch operations on or near it (such as operations performed by the user using any suitable object or accessory such as a finger, stylus, etc. on or near the touch panel 17071). The touch panel 17071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 1710, receives the command sent by the processor 1710 and executes it. In addition, the touch panel 17071 can be implemented in various types such as resistive, capacitive, infrared and surface acoustic wave. In addition to the touch panel 17071, the user input unit 1707 may also include other input devices 17072. Specifically, other input devices 17072 may include but are not limited to physical keyboards, function keys (such as volume control keys, switch keys, etc.), trackballs, mice, and joysticks, which will not be repeated here.
[0226] Furthermore, the touch panel 17071 may be overlaid on the display panel 17061. When the touch panel 17071 detects a touch operation on or near it, it transmits the information to the processor 1710 to determine the type of the touch event. Then, the processor 1710 provides a corresponding visual output on the display panel 17061 according to the type of the touch event. Fig.17 In the figure, the touch panel 17071 and the display panel 17061 are two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 17071 and the display panel 17061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.
[0227] The interface unit 1708 is an interface for connecting an external device to the electronic device 1700. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 1708 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 1700 or may be used to transmit data between the electronic device 1700 and an external device.
[0228] The memory 1709 can be used to store software programs and various data. The memory 1709 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 1709 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0229] The processor 1710 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 1709 and calling data stored in the memory 1709, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 1710 may include one or more processing units; preferably, the processor 1710 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1710.
[0230] The electronic device 1700 may also include a power supply 1711 (such as a battery) for supplying power to various components. Preferably, the power supply 1711 may be logically connected to the processor 1710 via a power management system, thereby managing functions such as charging, discharging, and power consumption through the power management system.
[0231] In addition, the electronic device 1700 includes some functional modules not shown, which will not be described here.
[0232] like Fig.18 As shown, in another embodiment provided by the present invention, a computer-readable storage medium 1801 is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the data processing method described in the above embodiment.
[0233] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0234] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the relevant technology, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, computer, server, air conditioner, or network equipment, etc.) to execute the methods described in each embodiment of the present invention.
[0235] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
[0236] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0237] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0238] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units 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, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0239] 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.
[0240] In addition, each functional unit in each embodiment of the present invention 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.
[0241] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for 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 invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0242] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A data processing device, characterized in that: The data processing device comprises at least a first memory computing core and a second memory computing core, wherein the first memory computing core and the second memory computing core respectively comprise: a cross matrix, an input memory, a vector operation unit, an output memory and a microcontroller; The input memory is used to store data that the data processing device needs to perform calculation operations; The cross matrix and the vector operation unit are used to implement the operation of the data processing device; The output memory is used to store the data obtained after the data processing device completes the calculation operation; The microcontroller is used to implement the logic functions of the data processing device; The activation data obtained after the cross matrix and vector operation unit of the first memory computing core completes the operation is loaded into the input memory of the second memory computing core to implement the operation of the second memory computing core through the cross matrix and vector operation unit of the second memory computing core.
2. A data processing method, characterized in that: Applied to a data processing device, the data processing device includes at least a first memory computing core and a second memory computing core, the first memory computing core and the second memory computing core respectively include: a cross matrix, an input memory, a vector operation unit, an output memory and a microcontroller, the method includes: The data that the data processing device needs to perform calculation operations on is stored in the input memory; Execute the computing operation of the data processing device by means of the cross matrix and the vector computing unit; The output memory stores the data obtained after the data processing device completes the calculation operation; Loading activation data obtained after the cross matrix and vector operation unit of the first memory computing core performs the operation into the input memory of the second memory computing core, so as to perform the operation of the second memory computing core through the cross matrix and vector operation unit of the second memory computing core; The data in the input memory is stored by the microcontroller, the data in the input memory is sent to the cross matrix and the vector operation unit to perform the operation, and the data obtained after the operation is completed is sent to the output memory for data storage.
3. An acceleration unit for executing a neural network model, characterized in that: The acceleration unit includes: a plurality of memory computing cores, an on-chip interconnect bus, a memory read-write circuit, and a high-speed digital interface, wherein the plurality of memory computing cores include at least a first memory computing core and a second memory computing core, wherein the first memory computing core and the second memory computing core respectively include a cross matrix, an input memory, a vector operation unit, an output memory, and a microcontroller; The multiple memory computing cores communicate with each other via the on-chip interconnect bus; The memory read / write circuit and the high-speed digital interface are used to load input data into the input memory of the memory computing core; The cross matrix and the vector operation unit are used to perform operations of the neural network model; The output memory is used to cache the output data obtained after the cross matrix and the vector operation unit perform the operation of the neural network model; The on-chip interconnect bus is used to load the activation data obtained after the cross matrix and vector operation unit of the first memory computing core executes the operation of the neural network model as the input data into the input memory of the second memory computing core, so as to execute the operation of the neural network model through the cross matrix and vector operation unit of the second memory computing core; The microcontroller is used to implement the logical functions of the memory computing core.
4. A data processing method, characterized in that: An acceleration unit for executing a neural network model, the acceleration unit comprising: a plurality of memory computing cores, an on-chip interconnect bus, a memory read-write circuit and a high-speed digital interface, the memory computing core comprising a cross matrix, an input memory, a vector operation unit, an output memory and a microcontroller, the plurality of memory computing cores communicating with each other through the on-chip interconnect bus, the method comprising: Determine a target memory computing core for executing the neural network model and a data transmission path between the target memory computing cores; According to the data transmission path, the image data of the neural network model is loaded into the input memory of the first memory computing core through the memory read-write circuit and the high-speed digital interface; Execute operations of the first memory computing core through the cross matrix of the first memory computing core and the vector operation unit of the first memory computing core to obtain activation data of the first memory computing core; caching activation data of the first memory computing core through the output memory of the first memory computing core; the activation data of the first memory computing core is a calculation result obtained after the calculation of the first memory computing core is completed; According to the data transmission path, the activation data of the first memory computing core is loaded into the input memory of the second memory computing core through the memory read-write circuit and the high-speed digital interface, and the operation of the second memory computing core is performed through the cross matrix of the second memory computing core and the vector operation unit of the second memory computing core to obtain the activation data of the second memory computing core, and cache it in the output memory of the second memory computing core; wherein, the first memory computing core and the second memory computing core belong to some memory computing cores in the target memory computing core, and the operation of the first memory computing core and the operation of the second memory computing core belong to the operation of the neural network model; The activation data of the second memory computing core is output to the neural network model through the memory read and write circuit and the high-speed digital interface, so that the neural network model completes the processing of the image data.
5. The method according to claim 4, characterized in that The performing operation of the first memory computing core through the cross matrix of the first memory computing core and the vector operation unit of the first memory computing core to obtain activation data of the first memory computing core includes: The kernel matrix of the neural network model is mapped to the cross matrix of the first memory computing core through an intra-layer parallel method, a convolution operation is performed through the cross matrix of the first memory computing core and the image data to obtain the convolution result of the first memory computing core, and the convolution result is activated and pooled by the vector operation unit of the first memory computing core to obtain the activation data of the first memory computing core.
6. The method according to claim 5, characterized in that The kernel matrix includes multiple weight matrices, and the intra-layer parallel method includes input channel parallelism, output channel parallelism, input feature map parallelism, and output feature map parallelism.
7. The method according to claim 6, characterized in that The method of mapping the kernel matrix of the neural network model to the cross matrix of the first memory computing core by the intra-layer parallel method, performing convolution operation on the cross matrix of the first memory computing core and the picture data to obtain the convolution result of the first memory computing core, and performing activation and pooling operation on the convolution result by the vector operation unit of the first memory computing core to obtain the activation data of the first memory computing core includes: When the intra-layer parallel method is the input channel parallelism, the image data and the input channel of the kernel matrix are split to obtain a plurality of first split matrices, the plurality of first split matrices are respectively mapped to the cross matrix of the first memory computing kernel, the convolution operation, the activation and pooling operation are performed to obtain a plurality of first output results, and the plurality of first output results are added to obtain first activation data; When the intra-layer parallel method is the output channel parallelism, the multiple weight matrices are respectively mapped to the cross matrix of the first memory computing core, the convolution operation, the activation and pooling operation are performed to obtain multiple second output results, and the multiple second output results are spliced to obtain second activation data; When the intra-layer parallel method is the input feature map parallelism, the kernel matrices of the plurality of neural network models are respectively mapped to the cross matrix of the first memory computing kernel, and the convolution operation, the activation and pooling operation are performed to obtain a plurality of third activation data; When the intra-layer parallel method is the output feature map parallelism, the activation data is dimensionally split to obtain a plurality of second split matrices, the plurality of second split matrices are respectively mapped to the cross matrix of the first memory computing core, the convolution operation, the activation and pooling operation are performed to obtain a plurality of fourth output results, and the plurality of fourth output results are spliced to obtain fourth activation data; The first activation data, the second activation data, the third activation data and the fourth activation data are used as activation data of the first memory computing core.
8. The method according to claim 5, characterized in that Mapping the kernel matrix of the neural network model to the cross matrix of the first memory computing kernel includes: According to the number of output channels of the kernel matrix, the kernel matrix is mapped to adjacent columns of the cross matrix of the first memory computing kernel.
9. The method according to claim 6, characterized in that The kernel matrix includes a plurality of weight matrices. After mapping the kernel matrix of the neural network model to the cross matrix of the first memory computing kernel, the method further includes: The mapped multiple weight matrices are positionally shifted on the cross matrix of the first memory computing core.
10. The method according to claim 4, characterized in that The step of loading the image data of the neural network model into the input memory of the first memory computing core includes: Loading adjacent pixels in the image data into the input memory of the first memory computing core; Or, different pixels in the picture data are loaded into a storage basic unit in the input memory of the first memory computing core, and the remaining bits of the storage basic unit containing the last pixel of the picture data are left blank; the different pixels in the picture data belong to the same row of pixels; Or, load the same pixels in the image data into two storage basic units in the input memory of the first memory computing core, and leave the remaining bits of the last pixel storage basic unit containing the image data empty.
11. The method according to claim 4, characterized in that Before loading the activation data of the first memory computing core into the input memory of the second memory computing core through the memory read / write circuit and the high-speed digital interface according to the data transmission path, the method further includes: The logical functions of the first memory computing core are implemented by the microcontroller of the first memory computing core.
12. The method according to claim 11, characterized in that The microcontroller is a core of an open source instruction set architecture based on the reduced instruction set principle, and the microcontroller includes an on-chip interconnect bus control module, a direct memory access module, a matrix operation control module, a vector operation control module, an external bus module core and an internal bus module.
13. The method according to claim 12, characterized in that The implementing the logic function of the first memory computing core by the microcontroller of the first memory computing core includes: The on-chip interconnect bus is configured through the on-chip interconnect bus control module of the first memory computing core, data packets are received and parsed, data packets are sent and packaged, data is cached, and the direct memory access module of the first memory computing core is interacted with to load the image data into the input memory of the first memory computing core; Implementing data interaction of the first memory computing core through a direct memory access module of the first memory computing core; The loading, storage and calculation of the picture data are realized by the matrix operation control module of the first memory computing core; The operator of the first memory computing core is expanded through the vector operation control module of the first memory computing core.
14. The method according to claim 13, characterized in that The direct memory access module includes a first memory access module and a second memory access module, and the data interaction of the first memory computing core is realized through the direct memory access module of the first memory computing core, including: Data interaction between the first memory computing core and the remaining memory computing cores is realized through the first memory access module of the first memory computing core; the remaining memory computing cores are the memory computing cores in the target memory computing cores except the first memory computing core; Data interaction in the first memory computing core is achieved through the second memory access module of the first memory computing core.
15. The method according to claim 13, characterized in that The method of extending the operator of the first memory computing core through the vector operation control module of the first memory computing core includes: The vector operation control module of the first memory computing core adopts the instruction set of the open source instruction set architecture based on the reduced instruction set principle to write an extended operator to expand the operator of the first memory computing core; the extended operator is the operator required for the neural network model operation and is an operator that cannot be implemented by the first memory computing core.
16. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor, when used to execute a program stored in the memory, implements the method as described in any one of claims 2 or 4-15.
17. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 2 or 4-15.
