Data processing method, device and system
By dividing data blocks into sliced data in the deep learning model and performing operations in the processor buffer, the problem of frequent memory reads and writes in continuous matrix multiplication operations is solved, latency is reduced, and computing performance is improved.
Patent Information
- Application Number
- CN202410712348.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-09-03
AI Technical Summary
In deep learning models, continuous matrix multiplication operations lead to frequent memory reading and writing operations, which increases computing latency and affects the overall efficiency of the model.
By dividing the data block into multiple slices of data, and performing calculations and storage in the processor's buffer, the read and write operations on the memory are reduced, and the high bandwidth and speed of the buffer are used for data residence, thereby realizing the optimization of the operation results. Streamlined processing.
It effectively reduces model reasoning and training delays, improves computing performance, and especially improves the timeliness of system perception and decision-making in autonomous driving systems.
Smart Images

Figure CN118586464A
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and specifically to methods, devices and systems for data processing. Background Art
[0002] Matrix multiplication (MatMul) is the core computing unit in the current mainstream deep learning models. The computational efficiency of matrix multiplication seriously affects the training performance and reasoning performance of deep learning models.
[0003] In deep learning models, the structure of continuous matrix multiplication is very common. In the current operation process of continuous matrix multiplication, matrix multiplication is calculated as an independent operator, that is, after the independent operator is calculated, the result needs to be written to the memory. When the result is matrix multiplied with another matrix, the result needs to be loaded from the memory to the computing unit for the next matrix multiplication calculation. In the case of a large number of matrix multiplications, the operations of reading data from the memory and writing data to the memory need to be repeatedly performed, resulting in a large amount of additional non-computational overhead, which in turn affects the overall computational efficiency of the deep learning model. Summary of the invention
[0004] The embodiments of the present application provide a method, device and system for data processing, which can enable the results obtained after the calculation data as an independent operator is operated to reside inside the chip of the computing unit, thereby reducing the number of times the memory is written and read during the calculation process, thereby effectively reducing the latency of model reasoning and training.
[0005] In a first aspect, a data processing method is provided, which is applied to a processor, wherein the processor includes a first buffer, and the method includes: determining a data amount of a first data block and a storage capacity of the first buffer; dividing the first data block into a plurality of slice data according to the data amount of the first data block and the storage capacity of the first buffer; performing a first operation on first slice data and second slice data among the plurality of slice data to determine a first operation result, wherein the first operation is used to perform a mathematical operation on two data, and the data amount of the first slice data and the data amount of the second slice data are less than the storage capacity of the first buffer; performing a first operation on the first operation result and third slice data among the plurality of slice data to determine a second operation result, and the data amount of the third slice data is less than the storage capacity of the first buffer.
[0006] By way of example, the above-mentioned determination of the storage capacity of the first buffer may include the following two situations: when other data is already stored in the first buffer, the above-mentioned determination of the storage capacity of the first buffer refers to determining the capacity of the remaining storage space of the first buffer; when no other data is stored in the first buffer, the above-mentioned determination of the storage capacity of the first buffer refers to determining the capacity of the complete storage space of the first buffer.
[0007] It should be understood that, since the first slice data and the second slice data can be loaded into the first buffer at the same time, the storage capacity of the first buffer should be greater than or equal to the sum of the data volumes of the first slice data and the second slice data. Similarly, the storage capacity of the first buffer should also be greater than or equal to the sum of the data volumes of the first operation result and the third slice data.
[0008] For example, the first operation may be a matrix multiplication operation, and the first slice data and the second slice data are represented as matrices. After the matrix operation unit of the computing platform completes the matrix multiplication operation, it is also necessary to perform post-processing operations on the operation results of the matrix multiplication of the computing platform, such as using a rectified linear unit (ReLU) function to perform post-processing operations on the operation results.
[0009] Based on the above technical solution, the larger first data block is divided into multiple slices of data, so that the first buffer of the processor can directly load the complete slice data for mathematical operations, and directly store the mathematical operation results of the two slices of data, so that the mathematical operation results can reside inside the chip of the computing unit, so that they can be directly taken out and used for mathematical operations in the subsequent mathematical operation process, instead of storing the mathematical operation results in the memory and reading them from the memory in the subsequent mathematical operation process, thereby reducing the data read and write operations on the memory and reducing the overhead of the memory read and write operations. Moreover, because the bandwidth of the buffer is greater than the bandwidth of the memory, and the data read and write speed of the buffer is faster than the data read and write speed of the memory, the model inference delay can be effectively reduced, and the model training delay will be reduced accordingly, improving the overall computing performance of the system, especially when applied to autonomous driving systems, it can effectively improve the timeliness of system perception decisions.
[0010] In combination with the first aspect, in some implementations of the first aspect, before performing a first operation on first slice data and second slice data among the plurality of slice data, the first slice data and the second slice data are loaded into a first buffer; before performing a first operation on a first operation result and third slice data among the plurality of slice data, the first operation result and the third slice data are loaded into the first buffer.
[0011] Based on the above technical solution, the first buffer is used as a storage medium for loading slice data and slice data, and the mathematical operation results between slice data can also be directly stored, so that the mathematical operation results can reside inside the chip of the computing unit, so that they can be directly taken out and used for mathematical operations in subsequent mathematical operations, instead of storing the mathematical operation results in the memory, so as to reduce the overhead of memory read and write operations. Moreover, compared with the memory, the buffer has a faster data read and write speed, so it can effectively reduce the model inference delay and model training delay, so it can significantly improve the computing performance of the computing unit, thereby effectively reducing the model inference and training delays.
[0012] In combination with the first aspect, in some implementations of the first aspect, during the first operation on the first slice data and the second slice data, the third slice data is loaded into the first buffer.
[0013] Based on the above technical solution, the buffer can load slice data, the computing unit can perform calculation operations, and the process of outputting calculation results can be streamlined, which helps the overall operation efficiency of the computing platform. Especially when applied to autonomous driving systems, it can effectively improve the timeliness of system perception decisions.
[0014] In combination with the first aspect, in certain implementations of the first aspect, before determining the data volume of the first data block and the storage capacity of the first buffer, the overall buffer of the processor is divided to determine multiple buffer partitions, and the first buffer belongs to multiple buffer partitions.
[0015] For example, the multiple buffer partitions obtained through segmentation may be independent of each other, and may be used to load slice data under the same service or slice data under different services.
[0016] Based on the above technical solution, by dividing the overall buffer of the processor and making each buffer partition independent of each other and able to operate in parallel with the computing unit, the utilization rate of the processor buffer is effectively improved, which helps to fully utilize the computing performance of the processor and further helps to increase the computing efficiency of the computing platform.
[0017] In combination with the first aspect, in certain implementations of the first aspect, the first buffer is divided into a first buffer sub-area and a second buffer sub-area, the first slice data is loaded into the first buffer sub-area, and the second slice data is loaded into the first buffer sub-area; the first operation result is loaded into the first buffer sub-area, and the third slice data is loaded into the second buffer sub-area.
[0018] Based on the above technical solution, the overall processor buffer is divided, which helps to make data processing more flexible. In addition, different buffer sub-areas can independently load different slice data or operation results, which helps to better manage the buffer space, and the buffer sub-area only needs to load one slice data or operation result, which helps to simplify data management.
[0019] In combination with the first aspect, in some implementations of the first aspect, during the first operation on the first slice data and the second slice data, the third slice data is loaded into the second buffer sub-area.
[0020] Based on the above technical solution, the buffer can load slice data, the computing unit can perform calculation operations, and the process of outputting calculation results can be streamlined, which helps the overall operation efficiency of the computing platform.
[0021] In combination with the first aspect, in some implementations of the first aspect, the first operation result overwrites the first slice data, and the third slice data overwrites the second slice data.
[0022] Alternatively, before loading the first operation result and the third slice data among the multiple slice data into the first buffer, the first slice data and the second slice data previously loaded into the first buffer can be released first, so as to ensure that the first buffer has sufficient storage space for loading the first operation result and the third slice data, wherein the meaning of "release" can be understood as "discard", "delete", "erase", etc.
[0023] Based on the above technical solution, the slice data that has participated in the calculation can be released, and the released storage space can be used for the subsequent first computing operation, thereby effectively improving the utilization rate of the storage space of the first buffer.
[0024] In combination with the first aspect, in some implementations of the first aspect, the plurality of slice data of the first data block are matrices, and the first operation is a matrix multiplication operation.
[0025] Based on the above technical solution, during the derivation or training of a deep learning model, since a large number of matrix multiplications are involved, the pre-sliced slice data is loaded into the processor's buffer during the matrix multiplication process, and the intermediate results of the matrix multiplication can also reside in the processor's buffer. There is no need to repeatedly write the intermediate results to the memory and read the intermediate results from the memory, thereby avoiding a large amount of memory read and write operation overhead.
[0026] In combination with the first aspect, in certain implementations of the first aspect, the first data block includes a first data sub-block, a second data sub-block, and a third data sub-block, the first data sub-block, the second data sub-block, and the third data sub-block are used to execute the same service, the first slice data belongs to the first data sub-block, the second slice data belongs to the second data sub-block, and the third slice data belongs to the third data sub-block.
[0027] In combination with the first aspect, in some implementations of the first aspect, the second data sub-block and the third data sub-block are used to process the first data sub-block.
[0028] In a second aspect, a data processing device is provided, which is applied to a processor, the processor including a first buffer, and the device including: a determination unit, used to determine the data amount of a first data block and the storage capacity of the first buffer; a first processing unit, used to divide the first data block into a plurality of slice data according to the data amount of the first data block and the storage capacity of the first buffer; an operation unit, used to perform a first operation operation on first slice data and second slice data among the plurality of slice data to determine a first operation result, the first operation operation is used to perform a mathematical operation on the two data, the data amount of the first slice data and the second slice data is less than the storage capacity of the first buffer; and perform a first operation operation on the first operation result and third slice data among the plurality of slice data to determine a second operation result, the data amount of the third slice data is less than the storage capacity of the first buffer.
[0029] In combination with the second aspect, in some implementations of the second aspect, the above-mentioned device also includes: a data reading and writing unit, which is used to load the first slice data and the second slice data among the multiple slice data into the first buffer before the operation unit performs the first operation operation on the first slice data and the second slice data; and is also used to load the first operation result and the third slice data among the multiple slice data into the first buffer before the operation unit performs the first operation operation on the first operation result and the third slice data.
[0030] In combination with the second aspect, in some implementations of the second aspect, the data reading and writing unit is specifically used to: load the third slice data into the first buffer during the period when the computing unit performs the first computing operation on the first slice data and the second slice data.
[0031] In combination with the second aspect, in certain implementations of the second aspect, the above-mentioned device also includes: a second processing unit, used to divide the overall buffer of the processor and determine multiple buffer partitions before the determination unit determines the data amount of the first data block and the storage capacity of the first buffer, and the first buffer belongs to multiple buffer partitions.
[0032] In combination with the second aspect, in some implementations of the second aspect, functions of the first processing unit and the second processing unit may be integrated into one processing unit.
[0033] In combination with the second aspect, in certain implementations of the second aspect, the first buffer is divided into a first buffer sub-area and a second buffer sub-area, and the data reading and writing unit is specifically used to: load the first slice data into the first buffer sub-area, and load the second slice data into the first buffer sub-area; or, load the first operation result into the first buffer sub-area, and load the third slice data into the second buffer sub-area.
[0034] In combination with the second aspect, in some implementations of the second aspect, the data reading and writing unit is specifically used to: load the third slice data into the second buffer sub-area while the computing unit performs the first computing operation on the first slice data and the second slice data.
[0035] In combination with the second aspect, in some implementations of the second aspect, the data reading and writing unit is specifically used to: overwrite the first slice data with the first operation result, and overwrite the second slice data with the third slice data.
[0036] In combination with the second aspect, in some implementations of the second aspect, the plurality of slice data of the first data block are matrices, and the first operation is a matrix multiplication operation.
[0037] In combination with the second aspect, in certain implementations of the second aspect, the first data block includes a first data sub-block, a second data sub-block and a third data sub-block, wherein the first data sub-block, the second data sub-block and the third data sub-block are used to execute the same service, the first slice data belongs to the first data sub-block, the second slice data belongs to the second data sub-block, and the third slice data belongs to the third data sub-block.
[0038] In combination with the second aspect, in some implementations of the second aspect, the second data sub-block and the third data sub-block are used to process the first data sub-block.
[0039] In a third aspect, a data processing device is provided, comprising a processor and a memory, wherein the processor and the memory are connected, wherein the memory is used to store program code, and the processor is used to call the program code to execute a method in any possible implementation of the method design of the first aspect mentioned above.
[0040] In a fourth aspect, a data processing system is provided, comprising an advanced driver assistance systems (ADAS) module and a first functional module, wherein the ADAS module is connected to the first functional module via a bus, the first functional module comprises a device in any possible implementation method of the device design of the third aspect, and the output of the first functional module is used to implement the function of the ADAS module.
[0041] In a fifth aspect, a vehicle is provided, comprising a device in any possible implementation of the device design of the second aspect or the third aspect, or a system in any possible implementation of the system design of the fourth aspect.
[0042] In a sixth aspect, a chip system is provided, which is applied to an electronic device; the chip system includes one or more interface circuits and one or more processors; the interface circuit and the processor are interconnected through lines; the interface circuit is used to receive signals from a memory of the electronic device and send signals to the processor, and the signals include computer instructions stored in the memory; when the processor executes the computer instructions, the electronic device executes a method in any possible implementation of the method design of the first aspect above.
[0043] In a seventh aspect, a computer-readable storage medium is provided, storing a computer program or instructions, wherein the computer program or instructions are used to implement the method in any possible implementation manner in the method design of the first aspect.
[0044] In an eighth aspect, a computer program product is provided. When the computer program code or instructions are executed on a computer, the computer executes a method in any possible implementation of the method design of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 is a schematic diagram of the architecture of a data processing system 100 proposed in an embodiment of the present application;
[0046] Figure 2 It is a schematic diagram of a continuous matrix multiplication calculation;
[0047] Figure 3 is a flowchart of a data processing method 300 proposed in an embodiment of the present application;
[0048] Figure 4 is a schematic diagram of a continuous matrix multiplication calculation proposed in an embodiment of the present application;
[0049] Figure 5 is a flowchart of another data processing method 500 proposed in an embodiment of the present application;
[0050] Figure 6 is a flowchart of another data processing method 600 proposed in an embodiment of the present application;
[0051] Figure 7 is a schematic diagram of the architecture of an Ascend platform proposed in an embodiment of the present application;
[0052] Figure 8 is a schematic diagram of performing continuous matrix multiplication calculation based on the Ascend platform proposed in an embodiment of the present application;
[0053] Fig. 9 It is a schematic block diagram of a data processing device 900 provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0055] The technical solution of the embodiment of the present application can be applied to a deep learning model, which can be installed on a vehicle-mounted computing platform, or a model training service platform, etc. These platforms all need to perform a large amount of data calculation operations through the computing unit in the deep learning model.
[0056] For example, the above-mentioned vehicle-mounted computing platform or the above-mentioned model training platform, etc., can be built based on the Ascend platform. In other words, the deep learning model used in the technical solution of the embodiment of the present application can be built based on the Ascend platform.
[0057] Figure 1 It is a schematic diagram of the architecture of a data processing system 100 proposed in an embodiment of the present application.
[0058] The system 100 can be based on software integration, and the software includes a model compilation module, which is used to perform model parsing, operator fusion and operator compilation operations on a preset business model to form a tool chain and finally determine an executable model file. In the process of operator fusion, more complex mathematical operations on data will be involved, such as continuous matrix multiplication operations based on continuous matrix multiplication structure fusion. It should be understood that matrix multiplication refers to the multiplication of two matrices, while continuous matrix multiplication refers to the multiplication of three or more matrices in sequence.
[0059] In some possible embodiments, the model file finally output by the model compilation module of the above system 100 can be applied to a variety of hardware scenarios, such as reference Figure 1As shown, the model file can be applied to the vehicle-mounted mobile data center (MDC) platform. The vehicle-mounted MDC platform includes a variety of functional modules that require data calculations, such as a perception module, a prediction module, etc. Each functional module in the vehicle-mounted MDC can realize corresponding functions based on the model file.
[0060] refer to Figure 1 As shown, the perception module or prediction module of the vehicle-mounted MDC platform is taken as an example, and the basic operation process of the perception module or prediction module of the vehicle-mounted MDC platform generally includes model input, input processing, model reasoning, output processing and result output. The executable model file output by the model compilation module of the above system 100 can be installed in the above perception module or prediction module to analyze and reason the model input to the perception module or prediction module. In the process of analyzing and reasoning the model, more complex mathematical operations on the data will also be involved, such as operator fusion of continuous matrix multiplication.
[0061] In some possible embodiments, for some data processing systems of other architectures, the system may also include an ADAS module. The ADAS module is an important component of intelligent networked vehicles. It uses sensors, communications, decision-making and control devices installed on the vehicle to monitor the driver, vehicle and the driving environment of the vehicle, and assists the driver to perform driving tasks or actively avoid and reduce collision hazards through images, lights, sounds, touch, prompts, warnings or controls. The ADAS module can share and transmit data with other functional modules through a bus, such as a CAN bus, etc. Other functional modules can process and analyze the data accordingly based on the data processing method proposed in the embodiment of the present application. The output results of data processing and analysis may include data, signals or control instructions. The output results are used to support decision-making, control or other functions in the ADAS module. These outputs can be the processing results of sensor data, environmental perception information after feature extraction, decision suggestions, etc., which are used by the ADAS module to perform driving assistance functions such as automatic braking, lane keeping, and adaptive cruise. In the process of the above-mentioned data processing and analysis, more complex mathematical operations on data are also involved, such as operator fusion of continuous matrix multiplication.
[0062] Since convolution operations are usually involved in the process of deep learning models processing data, and convolution operations are an independent operation, the processor can convert convolution operations into matrix multiplication operations through corresponding data processing methods, such as img2col. Based on this, the matrix multiplication unit has been called the core computing unit in the current mainstream deep learning model, and its computing efficiency can seriously affect the training and reasoning performance of the deep learning model. It can be seen that the efficiency of the matrix multiplication unit in performing continuous matrix multiplication operations directly affects the training and reasoning performance of the deep learning model. Similarly, the computing efficiency of the computing units used for other types of operations in the neural network model can also directly affect the training and reasoning performance of the deep learning model.
[0063] For the convenience of description, the embodiment of the present application takes the operation scenario of the matrix multiplication unit of the deep learning model as an example to illustrate the problems existing in the deep learning model.
[0064] In deep learning models, continuous matrix multiplication operations are very common, and this operation is usually performed by the matrix operation unit (cube unit) in the deep learning model. Continuous matrix multiplication operations are a way to implement convolution operations in deep learning models.
[0065] Figure 2 It is a schematic diagram of a continuous matrix multiplication calculation.
[0066] Figure 2 The continuous matrix multiplication shown includes the continuous multiplication of three matrices. The amount of data involved in the matrix multiplication operation is generally large. The matrix data involved in the matrix multiplication will be stored in the memory, where the memory can be a double data rate (DDR) synchronous dynamic random-access memory (SDRAM), referred to as DDR. That is, matrix 1 is read from the DDR and loaded into the calculation unit, and then matrix 2 is read from the DDR and loaded into the calculation unit.
[0067] After the computing unit is loaded into the above-mentioned matrix 1 and matrix 2, the matrix 1 and matrix 2 are multiplied by the matrix operation unit of the computing unit. Considering that the matrix multiplication operation is applied to the deep learning model, the computing unit usually also performs post-processing operations on the product of matrix 1 and matrix 2 to determine matrix A. In the process of continuous matrix multiplication, each group of matrix multiplication calculation processes is usually encapsulated as an independent operator. Of course, the operator encapsulated by each group of matrix multiplication can also be fused with other operators to form a new operator. The embodiment of the present application refers to the process of fusing two operators together as operator fusion. Then, the continuous matrix multiplication operation involved in the embodiment of the present application can also be understood as a calculation operation based on operator fusion. In this process, multiple matrix multiplication operators need to be fused into a new matrix multiplication operator in turn, and then fused with the subsequent matrix multiplication operators participating in the continuous matrix multiplication operation. It can be seen that the new matrix multiplication operator determined by operator fusion includes at least two matrix multiplication calculations.
[0068] However, considering that the chip resources of the computing unit are limited, if the calculation result is directly stored in the computing unit after the computing unit completes the operation of an operator, there may be the following two problems: First, the amount of data of the calculation result is large and difficult to store in the computing unit; second, even if the amount of data of the calculation result is relatively small and can be stored in the computing unit, when the next operator is operated, due to the limited chip resources of the computing unit, the calculation result has occupied a part of the resources, and it is also possible that the computing unit cannot obtain the complete data of the next operator, resulting in calculation anomalies, not to mention that there may be no calculation dependency between the next operator and the current operator, and there is no need to directly store the calculation result of the current operator in the computing unit. In view of this, the task scheduling mechanism of the processor is designed so that the computing unit obtains the data for the current operation before executing the operation, performs the operation, obtains the calculation result, and then writes the calculation result to the storage medium outside the processor, such as DDR.
[0069] Based on the above task scheduling mechanism, we know that matrix 3, as an independent matrix multiplication operator, needs to perform matrix multiplication operation with matrix A (equivalent to performing an operator fusion). At this time, matrix A needs to be read out from DDR and then loaded into the computing unit. Then repeat the above matrix multiplication operation, multiply matrix A with matrix 3, and then perform post-processing operation on the product result to determine matrix B, and finally write matrix B into DDR again, and repeat this process until the fusion of the last matrix multiplication operator is completed.
[0070] based on Figure 2From the continuous matrix multiplication calculation process shown, it can be seen that due to the relatively low bandwidth of DDR, the speed of reading or writing data from DDR is relatively slow. Especially when the number of matrices involved in the continuous matrix multiplication is large, it will be necessary to repeatedly write and read data from DDR, which will bring a lot of additional non-computational overhead, thereby seriously affecting the overall computational efficiency of the deep learning model.
[0071] For example, the "post-processing operation" mentioned in the above description refers to processing the calculation results based on the activation function of the deep learning model so that the calculation results can be used for nonlinear modeling of the deep learning model. Common activation functions include step function, logistic / sigmoid function, hyperbolic tangent function (tanh) function and ReLU function.
[0072] In view of this, the embodiments of the present application propose a method, device and system for data processing. In the operation of the deep learning model, the concept of sliced data is introduced, so that the results obtained after the operation of the calculation data as an independent operator can reside inside the chip of the computing unit, thereby reducing the number of times the memory is written and read during the calculation process, thereby effectively reducing the delay of model reasoning and training. In addition, considering the chip storage level of the computing unit, the chip storage space is divided and made independent of each other, so as to realize the pipeline of cache read and write operations and operation operations, and reduce the overall computing delay.
[0073] It should be understood that the data processing method proposed in the embodiment of the present application is applicable to the application field of deep learning models, and further, can be applied to the field of ADAS technology, etc.
[0074] Figure 3 It is a flowchart of a data processing method 300 proposed in an embodiment of the present application.
[0075] The method 300 may be applied to a processor that is used to run a deep learning model and perform corresponding mathematical operations based on the deep learning model.
[0076] S310: Determine the data amount of the first data block and the storage capacity of the first buffer.
[0077] The data in the first data block is used to participate in mathematical operations in the deep learning model. The first buffer is a buffer in the above processor.
[0078] In some possible embodiments, the above determination of the storage capacity of the first buffer may include the following two situations: when other data is already stored in the first buffer, the above determination of the storage capacity of the first buffer refers to determining the capacity of the remaining storage space of the first buffer; when no other data is stored in the first buffer, the above determination of the storage capacity of the first buffer refers to determining the capacity of the complete storage space of the first buffer. For ease of understanding, the embodiment of the present application will be described by taking the case where no other data is stored in the buffer as an example, that is, before executing the above S310, the processor's buffer is empty.
[0079] It should be understood that the above-mentioned first data block may be data for executing a first service, wherein the first service may be a perception service, a prediction service, a planning service or a control service, etc.
[0080] In addition, it is usually difficult for the processor buffer to load all the data of the first data block at one time. In order to enable the first buffer to load the data of the first data block normally, the following operation needs to be performed.
[0081] S320: Divide the first data block into a plurality of slice data according to the data amount of the first data block and the storage capacity of the first buffer.
[0082] In some possible embodiments, the data volumes of the above-mentioned multiple slice data may be the same or different, which is not limited in this embodiment of the present application.
[0083] S330: performing a first operation on first slice data and second slice data among the plurality of slice data to determine a first operation result, wherein the first operation is used to perform a mathematical operation on two data, and the data volume of the first slice data and the data volume of the second slice data are smaller than the storage capacity of the first buffer.
[0084] In some possible embodiments, before the above S330, the following operations may be performed:
[0085] S325: Load the first slice data and the second slice data into the first buffer. When S330 is executed, the first slice data and the second slice data may be read from the first buffer to perform the first operation.
[0086] It should be noted that, since the first slice data and the second slice data can be loaded into the first buffer at the same time, the storage capacity of the first buffer should be greater than or equal to the sum of the data amounts of the first slice data and the second slice data. However, the storage capacity of the processor buffer is much smaller than that of the DDR. If the first data block is directly loaded into the buffer, it will cause the buffer data to overflow. Therefore, in order to avoid this problem, the first data block needs to be divided through S310 and S320. However, if the first data block is stored in the DDR, this problem does not need to be considered, because the storage capacity of the DDR is large enough to store the complete first data block.
[0087] In some possible embodiments, the first operation may be a matrix multiplication operation, and the first slice data and the second slice data are represented as matrices. After the matrix operation unit of the computing platform completes the matrix multiplication operation, it is necessary to perform a post-processing operation on the operation result of the matrix multiplication of the computing platform, such as using a ReLU function to perform a post-processing operation on the operation result, and the post-processing operation can be completed by the vector operation unit of the computing platform.
[0088] It should be understood that the above-mentioned first operation result may be an operation result obtained through a post-processing operation.
[0089] S340: performing a first operation on the first operation result and third slice data among the plurality of slice data to determine a second operation result, wherein the data volume of the third slice data is smaller than the storage capacity of the first buffer.
[0090] In some possible embodiments, before the above S340, the following operations may be performed:
[0091] S335: Load the first operation result and the third slice data into the first buffer. When S340 is executed, the first operation result and the third slice data may be read from the first buffer to perform the first operation.
[0092] In some possible embodiments, the first slice data and the second slice data may also be used as an independent operator. Then, after the independent operator completes the calculation, the calculation result needs to be stored. Based on the aforementioned steps of method 300, since the first buffer can completely load the pre-divided slice data, the intermediate result after the two slice data are operated can be directly stored in the first buffer. The first buffer belongs to the processor and is not a memory device independent of the processor, so the intermediate result can reside in the processor.
[0093] Similar to the above embodiment, when the first operation is a matrix multiplication operation, the third slice data is correspondingly represented as a matrix.
[0094] In some possible embodiments, after executing the above S340, if there is no slice data and the second operation result to perform the first operation, it means that the third slice data is the last slice data of the first data block, and the continuous first operation is completed, then the second operation result is the final calculation result to be output, and the calculation result can be stored in the memory.
[0095] In some possible embodiments, after executing the above S340, if there are slice data belonging to the first data block that have not participated in the continuous first operation, it means that the continuous first operation has not been completed, and the second operation result needs to be loaded into the first buffer for performing the first operation with the next slice data loaded into the first buffer, which is equivalent to transferring the above process to S335, except that the operation object is different from the above S335. This cycle is repeated until the first operation is completed.
[0096] In some possible embodiments, the continuous computing operations of the computing platform usually exist as independent operators, so the two consecutive first computing operations in method 300 can be completed by two computing units in the processor respectively, for example, S330 is executed by computing unit 1 of the processor, and S340 is executed by computing unit 2 of the processor.
[0097] In some possible embodiments, considering that different computing platforms for running deep learning models have different storage architectures, the DDR of some computing platforms is indirectly connected to the computing unit. For example, the DDR of the computing platform is only connected to the buffer of the computing unit. Then, after completing the first continuous operation, the final operation result needs to be loaded into the buffer first and then written into the DDR; while the DDR of some computing platforms is directly connected to the computing unit. Then, after completing the first continuous operation, the final operation result can be directly written into the DDR; there are even multiple layers of storage media between the DDR of some computing platforms and the computing unit. Then, after completing the first continuous operation, the final operation result needs to be written into the DDR through the multiple layers of storage media.
[0098] It should be noted that in a computing platform based on a deep learning model, the storage medium with higher bandwidth than DDR and faster data reading and writing speed has not only a buffer but also a cache. The operation of the cache is uncontrollable, and the management of the cache is mainly completed automatically by the hardware, that is, the cache is invisible to the program, and generally cannot be explicitly read and written. Developers usually cannot directly control the behavior of the cache. In contrast, the controllability of the buffer is higher, that is, the buffer is visible to the program, and can be explicitly read and written. Developers can control when to write data to the buffer and when to read data from the buffer through programming. For example, when processing network communications or file reading and writing, developers can set the size of the buffer and when to refresh the data in the buffer to the target device or storage medium. This controllability enables developers to manage the data transmission process more finely to adapt to different application scenarios and requirements. Therefore, it can be said that the operation of the cache is uncontrollable, and the controllability of the buffer is higher. So based on the above comparison, the embodiment of the present application uses a buffer as a storage medium for loading slice data. Of course, in some special computing platform architectures, using cache as a storage medium for loading slice data may improve the overall performance more. In this case, cache can also be used as a storage medium for loading slice data in method 300 proposed in an embodiment of the present application.
[0099] For ease of understanding, the method 300 process proposed in the embodiment of the present application is further described in detail below by taking the first operation as a matrix multiplication operation as an example.
[0100] Figure 4 1 is a schematic diagram of a continuous matrix multiplication calculation proposed in an embodiment of the present application. In this example, it is necessary to perform a continuous multiplication operation on the matrix included in the first data block, and the computing platform for completing the continuous matrix multiplication operation may include: DDR, a first buffer, a matrix operation unit, and a vector operation unit. The detailed operation is as follows.
[0101] First, the data amount of the first data block and the storage capacity of the first buffer are determined, and then the first data block is divided into a plurality of slice data. The slice data can be stored in the DDR first, and each slice data corresponds to a matrix.
[0102] Then, when starting the continuous matrix multiplication calculation process, matrix 1 and matrix 2 in the first data block are loaded into the first buffer; matrix operation unit 1 reads matrix 1 and matrix 2 from the first buffer, multiplies the two matrices, obtains intermediate result 1, and inputs intermediate result 1 to vector operation unit 1.
[0103] It should be understood that matrix 1 is equivalent to the first slice data in the aforementioned embodiment, and matrix 1 belongs to the first data sub-block; matrix 2 is equivalent to the second slice data in the aforementioned embodiment, and matrix 2 belongs to the second data sub-block; matrix 3 is equivalent to the third slice data in the aforementioned embodiment, and matrix 3 belongs to the third data sub-block.
[0104] Then the vector operation unit 1 performs post-processing operations on the intermediate result 1 (based on ReLU function processing), determines the matrix A, writes the matrix A into the first buffer, and also loads the matrix 3 in the first data block into the first buffer.
[0105] Then the matrix operation unit 2 reads the matrix A and the matrix 3 from the first buffer, performs multiplication operation on the two matrices to obtain the intermediate result 2, and inputs the intermediate result to the vector operation unit 2.
[0106] Finally, the vector operation unit 2 performs post-processing operations on the intermediate result 2 to determine the matrix B, and then writes the matrix B into the first buffer. If there is no subsequent matrix multiplication operation, the matrix B can be moved from the first buffer to the DDR for subsequent operations of the computing platform.
[0107] In some possible embodiments, the matrix operation unit 1 and the matrix operation unit 2 can be integrated into one matrix operation unit, that is, the above-mentioned continuous matrix multiplication operations are sequentially completed by one matrix operation unit. Similarly, the vector operation unit 1 and the vector operation unit 2 can be integrated into one vector operation unit, that is, the post-processing operations in the above-mentioned continuous matrix multiplication are sequentially completed by one vector operation unit.
[0108] Based on the above technical solution, the larger first data block is divided into multiple slices of data, so that the first buffer of the processor can directly load the complete slice data for mathematical operations, and directly store the mathematical operation results of the two slices of data, so that the mathematical operation results can reside inside the chip of the computing unit, so that they can be directly taken out and used for mathematical operations in the subsequent mathematical operation process, instead of storing the mathematical operation results in the memory and reading them from the memory in the subsequent mathematical operation process, thereby reducing the data read and write operations on the memory and reducing the overhead of the memory read and write operations. Moreover, because the bandwidth of the buffer is greater than the bandwidth of the memory, and the data read and write speed of the buffer is faster than the data read and write speed of the memory, the model inference delay can be effectively reduced, and the model training delay will be reduced accordingly, improving the overall computing performance of the system, especially when applied to autonomous driving systems, it can effectively improve the timeliness of system perception decisions.
[0109] In some possible embodiments, considering that the capacity of the first buffer is limited, in the process of loading the first operation result and the third slice data among the multiple slice data into the first buffer, the first operation result can cover the first slice data, and the third slice data can cover the second slice data. Alternatively, before loading the first operation result and the third slice data among the multiple slice data into the first buffer, the first slice data and the second slice data previously loaded into the first buffer can be released. This ensures that the first buffer has enough storage space for loading the first operation result and the third slice data, where the meaning of "release" can be understood as "discard", "delete", "erase", etc.
[0110] Based on the above technical solution, the slice data that has participated in the calculation can be released, and the released storage space can be used for the subsequent first computing operation, thereby effectively improving the utilization rate of the storage space of the first buffer.
[0111] In some possible embodiments, when the storage space of the first buffer is sufficient, in the operation of loading slice data in the first buffer in method 300, more than three slice data may be loaded at one time, for example, the first slice data, the second slice data and the third slice data are loaded at the same time. After the first operation is performed on the first slice data and the second slice data, since the storage space of the first buffer is sufficient, it is not necessary to release the first slice data and the second slice data, and the first operation result is directly loaded into the first buffer, and then the first operation is directly performed on the first operation result and the third slice data to determine the second operation result. In particular, when the first operation is performed many times in succession, the number of times the first buffer is instructed to release slice data can be reduced, because each time the first buffer is instructed to release slice data, the computing unit needs to consume corresponding control signaling overhead.
[0112] Based on the above technical solution, when the storage space of the first buffer is sufficient, the signaling overhead for controlling the first buffer to release slice data can be effectively reduced.
[0113] In some possible embodiments, during the process of loading slice data in the first buffer, the storage space occupancy rate of the first buffer can be continuously monitored. When the storage space occupancy rate is higher than a preset threshold, the operation of releasing the slice data in the first buffer will be automatically triggered, thereby further reducing the signaling overhead for controlling the first buffer to release the slice data.
[0114] In some possible embodiments, the first data block includes a first data sub-block, a second data sub-block and a third data sub-block, wherein the first data sub-block, the second data sub-block and the third data sub-block are used to execute the same service, the first slice data belongs to the first data sub-block, the second slice data belongs to the second data sub-block, and the third slice data belongs to the third data sub-block.
[0115] It can be seen that the first slice data, the second slice data and the third slice data may belong to different types of data. However, the three slice data, or the three data sub-blocks to which the three slice data belong, are of the same source and are used to perform the same service, that is, the service performed by the first data block, such as the perception service, prediction service, planning service or control service of the autonomous driving system.
[0116] In some possible embodiments, the second data sub-block and the third data sub-block may be used to process the first data sub-block.
[0117] For example, the first slice data may be image data, the second slice data may be a calculation factor for extracting a first feature of an image, and after a first operation is performed on the first slice data and the second slice data, a first operation result outputted may be an image from which the first feature is extracted. The third slice data may be a calculation factor for extracting a second feature of an image, and after a first operation is performed on the first operation result and the third slice data, a second operation result outputted may be an image from which the first feature and the second feature are extracted.
[0118] In some possible embodiments, the storage capacity of the overall buffer of the processor may be greater than the storage capacity of the first buffer. If, in the process of performing continuous first operation on the data of the first data block, the slice data of the first data block is loaded only through the first buffer of the processor, especially when the storage capacity of the overall buffer of the processor is much greater than the storage capacity of the first buffer, the overall buffer utilization of the processor is relatively low. In view of this, the embodiment of the present application adds the following operation on the basis of the above method 300:
[0119] Before S310 of the method 300 , the overall buffer of the processor is divided to determine a plurality of buffer partitions, to which the first buffer belongs.
[0120] It should be understood that any buffer partition among the above-mentioned multiple buffer partitions can be used to perform corresponding calculation operations on slice data, and the slice data on which the calculation operation is performed can be other slice data in the first data block, or slice data in other data blocks.
[0121] Based on the above technical solution, multiple buffer partitions are determined through reasonable planning of the processor's overall buffer, and multiple buffer partitions can be used to load data so that the loaded data can participate in data calculation operations, thereby helping to improve the utilization rate of the processor's overall buffer.
[0122] Taking the second buffer in the multiple buffer partitions as an example, when the second buffer is used to perform the first operation on the data of the second data block, similar to the method 300 performed by the first buffer, the following operations may be performed.
[0123] Figure 5 It is a flowchart of another data processing method 500 proposed in an embodiment of the present application.
[0124] S510: Determine the data amount of the second data block and the storage capacity of the second buffer.
[0125] S520: Divide the second data block into a plurality of slice data according to the data amount of the second data block and the storage capacity of the second buffer, and load the fourth slice data and the fifth slice data of the second data block into the second buffer.
[0126] It should be understood that the fourth slice data and the fifth slice data of the second data block belong to the plurality of slice data into which the second data block is divided. In addition, the data volume of the fourth slice data and the fifth slice data is smaller than the storage capacity of the second buffer.
[0127] S530: Perform a first operation on the fourth slice data and the fifth slice data of the second data block to determine a third operation result, wherein the first operation is used to perform a mathematical operation on two data.
[0128] S540: Load the third operation result and the sixth slice data of the second data block into the second buffer.
[0129] S550: Perform the first operation on the third operation result and the sixth slice data of the second data block to determine a fourth operation result.
[0130] Of course, the above-mentioned first operation can be replaced by other operation operations different from the first operation, such as a second operation operation, wherein the first operation operation is a matrix multiplication operation and the second operation operation is a matrix addition operation, and the embodiment of the present application does not limit this.
[0131] In some possible embodiments, the above-mentioned slicing of the overall buffer of the processor may be to equally divide the overall buffer, so that the cache capacities of the multiple buffer partitions are equal. Similarly, taking the second buffer in the multiple buffer partitions as an example, the storage capacity of the second buffer should be equal to the storage capacity of the first buffer. Then, when the second buffer is used to perform the first operation on other sliced data of the first data block, the following operation may be performed.
[0132] Figure 6 6 is a flow chart of another data processing method 600 proposed in an embodiment of the present application. The method 600 may be executed after S320 of the method 300.
[0133] S610: Load the seventh slice data and the eighth slice data of the first data block into the second buffer.
[0134] It should be understood that the seventh slice data and the eighth slice data of the first data block belong to the multiple slice data into which the first data block is divided. Since the storage capacity of the second buffer is the same as the storage capacity of the first buffer, and the data size of the slice data obtained by dividing the first data block is compatible with the storage capacity of the first buffer, then the data size of the slice data obtained by dividing the first data block is also compatible with the capacity of the second buffer. In other words, the data size of the seventh slice data and the eighth slice data should be compatible with the second buffer, that is, the seventh slice data and the eighth slice data are smaller than the storage capacity of the second buffer. Therefore, there is no need to determine whether the storage capacity of the second buffer is compatible with the slice data of the first data block before this.
[0135] S620: Perform the first operation on the seventh slice data and the eighth slice data of the first data block to determine a fifth operation result.
[0136] S630: Load the fifth operation result and the eighth slice data of the first data block into the second buffer.
[0137] S640: Perform a first operation on the fifth operation result and the eighth slice data of the first data block to determine a sixth operation result.
[0138] Based on the above technical solution, by dividing the overall buffer of the processor and making each buffer partition independent of each other and able to operate in parallel with the computing unit, the utilization rate of the processor buffer is effectively improved, which helps to fully utilize the computing performance of the processor and further helps to increase the computing efficiency of the computing platform.
[0139] In some possible embodiments, since the task scheduling mechanism of the computing platform can be multi-threaded and parallel, each thread is dedicated to different data operations, such as thread 1 for data loading, thread 2 for data calculation, etc., taking thread 1 as an example, after completing S325 in the above method 300 in thread 1, thread 2 starts to execute S330 in the above method 300. From the perspective of executing method 300 alone, thread 1 can be idle in the process of thread 2 starting to execute S330 in the above method 300, but in order to avoid making thread 1 idle for a long time, it is necessary to fill other data loading tasks into thread 1. Take the second buffer in the multiple buffer partitions of the processor as an example, and the second buffer is used to perform the first operation on other slice data of the first data block, that is, the operation flow of executing method 600. Then, during the execution of S330 in the above method 300 by the processor, S610 of the above method 600 can be executed, so that thread 1 directly cuts into executing S610 of the above method 600 after completing S325 in the above method 300, so as to avoid thread 1 being idle. Similarly, during the period when the processor executes S335 in the method 300, S620 of the method 600 may be executed; and so on, thereby at least the pipelining of the thread 1 and the thread 2 is achieved.
[0140] In some possible embodiments, when the second buffer in the plurality of buffer partitions of the processor is used to perform the first operation on the plurality of slice data of the second data block, the method 500 is executed. During the execution of S330 in the method 300 by the computing platform, S520 in the method 500 may also be executed.
[0141] Based on the above technical solution, the buffer can load slice data, the computing unit can perform calculation operations, and the process of outputting calculation results can be streamlined, which helps the overall operation efficiency of the computing platform. Especially when applied to autonomous driving systems, it can effectively improve the timeliness of system perception decisions.
[0142] In some possible embodiments, only in method 300, parallelism between data loading and data operation can be achieved, that is, parallelism between S330 and S335 can be achieved. For example, during the execution of S330, the third slice data among the multiple slice data of the first data block can be pre-loaded into the first buffer in S335, so that the operation of loading the third slice data into the first buffer can be advanced. After S330 is executed, only the first operation result needs to be loaded into the first buffer, thereby speeding up the execution speed of method 300 as a whole.
[0143] In some possible embodiments, in the process of dividing the overall buffer of the processor, the first buffer of the processor may be divided, that is, the first buffer may be divided into a first buffer sub-area and a second buffer sub-area, then the "loading the first slice data and the second slice data of the plurality of slice data into the first buffer" in S325 of the method 300 proposed in the embodiment of the present application may be further implemented by the following operations:
[0144] The first slice data is loaded into the first buffer sub-area, and the second slice data is loaded into the second buffer sub-area.
[0145] Similarly, the step of “loading the first operation result and the third slice data among the plurality of slice data into the first buffer” in S335 of the method 300 proposed in the embodiment of the present application can be further implemented by the following operations:
[0146] The first operation result is loaded into the first buffer sub-area, and the third slice data is loaded into the second buffer sub-area.
[0147] It should be understood that since the first slice data can be loaded into the first buffer sub-area, it means that the data volume of the first slice data is less than or equal to the storage capacity of the first buffer sub-area, and the same is true for the second slice data and the third slice data.
[0148] In some possible embodiments, the processor may further include a second buffer, which may be used to transfer the above-mentioned multiple slice data or operation results.
[0149] Based on the above technical solution, the overall processor buffer is divided, which helps to make data processing more flexible. In addition, different buffer sub-areas can independently load different slice data or operation results, which helps to better manage the buffer space, and the buffer sub-area only needs to load one slice data or operation result, which helps to simplify data management.
[0150] Based on the above embodiments, it can be known that the task scheduling mechanism of the computing platform is multi-threaded and parallel. In order to realize the streamlining of the computing platform computing operations and data storage processes and minimize the long-term idle state of a certain thread of the computing platform, the above-mentioned "loading the first computing result and the third slice data of the plurality of slice data into the second buffer sub-area" can be further realized by the following operations:
[0151] During the period in which the computing unit of the processor executes S330 in the method 300 , the third slice data is loaded into the second buffer sub-area.
[0152] Based on the above technical solution, in the process of performing two consecutive first operation operations on the slice data of the first data block, during the previous first operation, the third slice data used for the next first operation can be loaded into the second buffer sub-area, and the process of loading the slice data into the second buffer sub-area is advanced, thereby realizing the pipelining of the computing platform computing operation and data loading, which helps to avoid long idle times of threads such as processor computing operation and data loading, thereby improving the overall operation efficiency of the computing platform, especially when applied to autonomous driving systems, it can effectively improve the timeliness of system perception decisions.
[0153] Based on the above description, it can be known that different computing platforms have different platform architectures, and the technical solutions of the embodiments of the present application can be applied to computing platforms with different architectures. For ease of understanding, the technical solutions of the embodiments of the present application will be described in detail below using the Ascend platform as an example.
[0154] Figure 7 It is a schematic diagram of the architecture of an Ascend platform proposed in an embodiment of the present application.
[0155] refer to Figure 7 As shown, the Ascend platform includes multiple buffers, matrix operation units and vector operation units. Moreover, in order to improve the storage capacity of the Ascend platform, cache L2 and DDR are also provided outside the Ascend platform. The cache L2 is the middle layer between the Ascend platform and DDR, which is used to transfer the data exchanged between the Ascend platform and DDR.
[0156] Since the Ascend platform integrates multi-level storage space, corresponding storage media are deployed as the intermediate layer between each functional component in the Ascend platform.
[0157] The buffers of the Ascend platform include buffer L1, buffer L0A, buffer L0B, buffer L0C, and buffer UB.
[0158] Among them, buffer L0A and buffer L0B are set between buffer L1 and the matrix operation unit, wherein buffer L1 is used to load slice data, which can be expressed as a matrix, buffer L0A and buffer L0B are respectively used to load the left matrix and the right matrix for matrix multiplication operation, so when the matrix operation unit performs matrix multiplication operation, it can directly obtain the left matrix and the right matrix from buffer L0A and buffer L0B.
[0159] The buffer L0C is arranged between the matrix operation unit and the vector operation unit, and is used to transfer the intermediate result output by the matrix operation unit after performing the matrix multiplication operation, so that the vector operation unit reads the intermediate result from the buffer L0C for post-operation processing to determine the result matrix.
[0160] Buffer UB is set between the vector operation unit and buffer L1, and is used to redirect the result matrix output by the vector operation unit so that the result matrix can be finally transferred to buffer L1. If the result matrix is the final result of continuous matrix multiplication operations, buffer L1 can transfer the result matrix to cache L2, so that the result matrix can finally be transferred to DDR; if the result matrix is not the final result of continuous matrix multiplication operations, buffer L1 can transfer the result matrix to L0A buffer as the left matrix in the next matrix multiplication operation, and L0B buffer can continue to load matrices from buffer L1 as the right matrix in the next matrix multiplication operation, and then the matrix calculation unit performs matrix multiplication based on the matrices in the current L0A buffer and L0B buffer, and so on.
[0161] Figure 8 It is a schematic diagram of performing continuous matrix multiplication calculation based on the Ascend platform proposed in an embodiment of the present application.
[0162] First, the data volume of the first data block and the storage capacity of each buffer of the Ascend platform are determined, and then the first data block is divided into a plurality of slice data. The slice data can be stored in DDR first, and each slice data corresponds to a matrix.
[0163] Then, when starting the continuous matrix multiplication calculation process, based on the special platform architecture of the Ascend platform, it is necessary to first load matrix 1 and matrix 2 in the first data block into cache L2, and then move matrix 1 and matrix 2 from cache L2 to buffer L1. Buffer L1 then allocates matrix 1 to buffer L0A and matrix 2 to buffer L0B. The matrix operation unit reads matrix 1 and matrix 2 from buffer L0A and buffer L0B respectively, multiplies the two matrices, obtains intermediate result 1, and inputs intermediate result 1 into buffer L0C.
[0164] It should be understood that matrix 1 is equivalent to the first slice data in the aforementioned embodiment, and matrix 1 belongs to the first data sub-block; matrix 2 is equivalent to the second slice data in the aforementioned embodiment, and matrix 2 belongs to the second data sub-block; matrix 3 is equivalent to the third slice data in the aforementioned embodiment, and matrix 3 belongs to the third data sub-block.
[0165] If post-processing operations are required on the intermediate result 1, the vector operation unit is required to read the intermediate result 1 from the buffer L0C, perform post-processing operations on the intermediate result 1 (for example, based on the ReLU function, bias_add processing), determine the matrix A, and then write the matrix A into the buffer UB, and finally move the matrix A to the buffer L1.
[0166] If there is no need to perform post-processing operations on the intermediate result 1, the intermediate result 1 can be directly transferred as the matrix A from the buffer L0C to the buffer UB, and then transferred from the buffer UB to the buffer L1.
[0167] It should be understood that after the matrix operation unit completes the matrix multiplication operation, the intermediate result can reside directly in the buffer L1, that is, inside the Ascend platform, rather than in the DDR. Therefore, the matrix A can be used for the next matrix multiplication operation.
[0168] In some possible embodiments, while the matrix operation unit performs matrix multiplication operation on matrix 1 and matrix 2, buffer L1 can load matrix 3 from DDR in advance and allocate matrix 3 to buffer L0B. When buffer L0A finishes loading matrix A, it can immediately perform the next matrix multiplication operation. This enables the pipeline of continuous matrix multiplication operations on the Ascend platform as a whole.
[0169] The matrix operation unit performs matrix multiplication operation on the matrix A and the matrix 3 respectively obtained from the buffers L0A and L0B to obtain an intermediate result 2, and inputs the intermediate result 2 to the buffer L0C.
[0170] Similar to the above operation flow, if post-processing operation is required on the intermediate result 2, the vector operation unit is required to read the intermediate result 2 from the buffer L0C, perform post-processing operation on the intermediate result 2, determine the matrix B, and then write the matrix B into the buffer UB, and finally move the matrix B to the buffer L1.
[0171] If there is no need to perform post-processing operations on the intermediate result 2, the intermediate result 2 can be directly transferred as the matrix B from the buffer L0C to the buffer UB, and then transferred from the buffer UB to the buffer L1.
[0172] Assuming that the above matrix B is determined and there is no matrix multiplication operation, the matrix B can be moved from the buffer L1 to the cache L2. The cache L2 writes the matrix B into the DDR for subsequent operations of the Ascend platform. At this point, the Ascend platform completes the continuous matrix multiplication operation through the technical solution proposed in the embodiment of the present application.
[0173] In addition, an embodiment of the present application also provides an apparatus for implementing any of the above methods. For example, a data processing apparatus is provided, which includes a unit (or means) for implementing any of the above data processing methods.
[0174] Fig. 9 It is a schematic block diagram of a data processing device 900 provided in an embodiment of the present application.
[0175] The device 900 is applied to a processor, the processor includes a first buffer, and the device 900 includes:
[0176] A determining unit 910, configured to determine the data volume of the first data block and the storage capacity of the first buffer;
[0177] A first processing unit 920, configured to divide the first data block into a plurality of slice data according to the data amount of the first data block and the storage capacity of the first buffer;
[0178] The operation unit 930 is configured to perform a first operation on first slice data and second slice data among the plurality of slice data to determine a first operation result, wherein the first operation is used to perform a mathematical operation on two data, and the data volume of the first slice data and the second slice data is smaller than the storage capacity of the first buffer; and perform the first operation on the first operation result and third slice data among the plurality of slice data to determine a second operation result, and the data volume of the third slice data is smaller than the storage capacity of the first buffer.
[0179] In some possible embodiments, the apparatus 900 further includes: a data reading and writing unit 940, which is used to load the first slice data and the second slice data among the multiple slice data into the first buffer before the operation unit 930 performs the first operation operation on the first slice data and the second slice data; and is also used to load the first operation result and the third slice data among the multiple slice data into the first buffer before the operation unit 930 performs the first operation operation on the first operation result and the third slice data.
[0180] In some possible embodiments, the data reading and writing unit 940 is specifically configured to: load the third slice data into the first buffer during the period in which the computing unit 930 performs the first computing operation on the first slice data and the second slice data.
[0181] In some possible embodiments, the above-mentioned device 900 also includes: a second processing unit 950, which is used to divide the overall buffer of the processor and determine multiple buffer partitions before the determination unit 910 determines the data amount of the first data block and the storage capacity of the first buffer, and the first buffer belongs to multiple buffer partitions.
[0182] In some possible embodiments, the functions of the first processing unit 920 and the second processing unit 950 may be integrated into one processing unit.
[0183] In some possible embodiments, the first buffer is divided into a first buffer sub-area and a second buffer sub-area, and the data reading and writing unit 940 is specifically used to: load the first slice data into the first buffer sub-area, and load the second slice data into the first buffer sub-area; or, load the first operation result into the first buffer sub-area, and load the third slice data into the second buffer sub-area.
[0184] In some possible embodiments, the data reading and writing unit 940 is specifically used to: load the third slice data into the second buffer sub-area during the period when the computing unit 930 performs the first computing operation on the first slice data and the second slice data.
[0185] In some possible embodiments, the data reading and writing unit 940 is specifically used to: overwrite the first slice data with the first operation result, and overwrite the second slice data with the third slice data.
[0186] In some possible embodiments, the plurality of slice data of the first data block are matrices, and the first operation is a matrix multiplication operation.
[0187] In some possible embodiments, the first data block includes a first data sub-block, a second data sub-block and a third data sub-block, wherein the first data sub-block, the second data sub-block and the third data sub-block are used to execute the same service, the first slice data belongs to the first data sub-block, the second slice data belongs to the second data sub-block, and the third slice data belongs to the third data sub-block.
[0188] In some possible embodiments, the second data sub-block and the third data sub-block are used to process the first data sub-block.
[0189] In some possible embodiments, the embodiments of the present application also provide a data processing device, which includes a processor and a memory, wherein the processor and the memory are connected, wherein the memory is used to store program code, and the processor is used to call the program code to execute any data processing method proposed in the embodiments of the present application.
[0190] In some possible embodiments, the embodiments of the present application also provide a vehicle, which includes any data processing device proposed in the embodiments of the present application, or any data processing system proposed in the embodiments of the present application.
[0191] 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 herein 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 this application.
[0192] 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.
[0193] In the several embodiments provided in the present application, it should be understood that the disclosed systems, 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.
[0194] 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.
[0195] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0196] 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 application, 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, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application.
[0197] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method of data processing, It is characterized in that Applied to a processor, the processor includes a first buffer, the method includes: Determining the data amount of the first data block and the storage capacity of the first buffer; Dividing the first data block into a plurality of slice data according to the data amount of the first data block and the storage capacity of the first buffer; Performing a first operation on first slice data and second slice data among the plurality of slice data to determine a first operation result, wherein the first operation is used to perform a mathematical operation on two data, and the data volume of the first slice data and the data volume of the second slice data are smaller than the storage capacity of the first buffer; The first operation is performed on the first operation result and third slice data among the plurality of slice data to determine a second operation result, wherein the data volume of the third slice data is smaller than the storage capacity of the first buffer.
2. The method according to claim 1, It is characterized in that Before performing the first operation on the first slice data and the second slice data among the plurality of slice data, the method further includes: loading the first slice data and the second slice data into the first buffer; Before performing the first operation on the first operation result and the third slice data among the plurality of slice data, the method further includes: loading the first operation result and the third slice data into the first buffer.
3. The method according to claim 2, It is characterized in that The loading the first operation result and the third slice data into the first buffer comprises: During the first operation on the first slice data and the second slice data, the third slice data is loaded into the first buffer.
4. The method according to any one of claims 1 to 3, It is characterized in that Before determining the data amount of the first data block and the storage capacity of the first buffer, the method further includes: The overall buffer of the processor is divided into multiple buffer partitions, and the first buffer belongs to the multiple buffer partitions.
5. The method according to claim 4, It is characterized in that The first buffer is divided into a first buffer sub-area and a second buffer sub-area, and loading the first slice data and the second slice data of the plurality of slice data into the first buffer comprises: loading the first slice data into the first buffer sub-area, and loading the second slice data into the first buffer sub-area; The loading of the first operation result and the third slice data among the plurality of slice data into the first buffer includes: loading the first operation result into the first buffer sub-area, and loading the third slice data into the second buffer sub-area.
6. The method according to claim 5, It is characterized in that The step of loading the third slice data among the plurality of slice data into the second buffer sub-area comprises: During the first operation on the first slice data and the second slice data, the third slice data is loaded into the second buffer sub-area.
7. The method according to any one of claims 1 to 6, It is characterized in that The step of loading the first operation result and the third slice data among the plurality of slice data into the first buffer comprises: The first operation result is used to overwrite the first slice data, and the third slice data is used to overwrite the second slice data.
8. The method according to any one of claims 1 to 7, It is characterized in that The plurality of slice data of the first data block are matrices, and the first operation is a matrix multiplication operation.
9. The method according to any one of claims 1 to 8, It is characterized in that The first data block includes a first data sub-block, a second data sub-block and a third data sub-block, the first data sub-block, the second data sub-block and the third data sub-block are used to execute the same service, the first slice data belongs to the first data sub-block, the second slice data belongs to the second data sub-block, and the third slice data belongs to the third data sub-block.
10. The method according to claim 9, It is characterized in that The second data sub-block and the third data sub-block are used to process the first data sub-block.
11. A data processing device, It is characterized in that Applied to a processor, the processor includes a first buffer, and the device includes: a determining unit, configured to determine the data volume of the first data block and the storage capacity of the first buffer; A first processing unit, configured to divide the first data block into a plurality of slice data according to the data amount of the first data block and the storage capacity of the first buffer; The operation unit is configured to perform a first operation on first slice data and second slice data among the plurality of slice data to determine a first operation result, wherein the first operation is used to perform a mathematical operation on two data, and the data amount of the first slice data and the second slice data is smaller than the storage capacity of the first buffer; and perform the first operation on the first operation result and third slice data among the plurality of slice data to determine a second operation result, and the data amount of the third slice data is smaller than the storage capacity of the first buffer.
12. The device according to claim 11, It is characterized in that The device also includes: a data reading and writing unit, configured to load the first slice data and the second slice data among the plurality of slice data into the first buffer before the operation unit performs the first operation on the first slice data and the second slice data; and configured to load the first operation result and the third slice data among the plurality of slice data into the first buffer before the operation unit performs the first operation on the first operation result and the third slice data.
13. The device according to claim 12, It is characterized in that The data reading and writing unit is specifically used for: During the period in which the computing unit performs a first computing operation on the first slice data and the second slice data, the third slice data is loaded into the first buffer.
14. The device according to any one of claims 11 to 13, It is characterized in that The device also includes: The second processing unit is used to divide the overall buffer of the processor to determine multiple buffer partitions before the determination unit determines the data amount of the first data block and the storage capacity of the first buffer, and the first buffer belongs to the multiple buffer partitions.
15. The device according to claim 14, It is characterized in that The first buffer area is divided into a first buffer sub-area and a second buffer sub-area, and the data reading and writing unit is specifically used for: Loading the first slice data into the first buffer sub-area, and loading the second slice data into the first buffer sub-area; or, The first operation result is loaded into the first buffer sub-area, and the third slice data is loaded into the second buffer sub-area.
16. The device according to claim 15, It is characterized in that The data reading and writing unit is specifically used for: During the period in which the computing unit performs a first computing operation on the first slice data and the second slice data, the third slice data is loaded into the second buffer sub-area.
17. The device according to any one of claims 11 to 16, It is characterized in that The data reading and writing unit is specifically used for: The first operation result is used to overwrite the first slice data, and the third slice data is used to overwrite the second slice data.
18. The device according to any one of claims 11 to 17, It is characterized in that The plurality of slice data of the first data block are matrices, and the first operation is a matrix multiplication operation.
19. The device according to any one of claims 11 to 18, It is characterized in that The first data block includes a first data sub-block, a second data sub-block and a third data sub-block, the first data sub-block, the second data sub-block and the third data sub-block are used to execute the same service, the first slice data belongs to the first data sub-block, the second slice data belongs to the second data sub-block, and the third slice data belongs to the third data sub-block.
20. The device according to claim 19, It is characterized in that The second data sub-block and the third data sub-block are used to process the first data sub-block.
21. A data processing device, It is characterized in that The system comprises a processor and a memory, wherein the processor and the memory are connected, wherein the memory is used to store program codes, and the processor is used to call the program codes to execute the method according to any one of claims 1 to 10.
22. A data processing system, It is characterized in that It includes an advanced driving assistance system (ADAS) module and a first functional module, the ADAS module is connected to the first functional module via a bus, the first functional module includes the device as claimed in claim 21, and the output of the first functional module is used to implement the function of the ADAS module.
23. A vehicle, It is characterized in that Comprising the apparatus as claimed in any one of claims 11 to 20, or comprising the apparatus as claimed in claim 21, or the system as claimed in claim 22.
24. A chip system, It is characterized in that The chip system is applied to an electronic device; the chip system includes one or more interface circuits and one or more processors; the interface circuit and the processor are interconnected through lines; the interface circuit is used to receive a signal from a memory of the electronic device and send the signal to the processor, the signal including a computer instruction stored in the memory; when the processor executes the computer instruction, the electronic device executes the method as described in any one of claims 1 to 10.
25. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 10.
26. A computer program product, It is characterized in that The method comprises instructions, which, when executed by a processor, cause the method according to any one of claims 1 to 10 to be executed.
