Data processing method, computer device and chip
Through the transmission device performing data transmission and editing between the memory device and the processing device, the problem of low processing efficiency after data transfer is solved, and pre-processing is realized before the processing device acquires the target tensor, reducing the computing power requirements and processing time, and improving processing efficiency.
Patent Information
- Application Number
- PCT/CN2024/090519
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-08-30
- Filing Date
- 2024-04-29
- Publication Date
- 2025-03-06
AI Technical Summary
During the data transfer process, the processor or processing core on the chip is relatively inefficient in processing data, and data processing needs to be performed after the data transfer.
Through the transmission device, the tensor acquisition request is obtained, and the initial tensor is read in the memory device based on the command descriptor and editing is performed to obtain the target tensor, and the target tensor is sent directly to the processing device.
Preprocessing of the initial tensor before the processor acquires the target tensor is realized, reducing the computing power requirements for the processor device, saving the processing time of the processor device, and improving processing efficiency.
Smart Images

Figure CN2024090519_06032025_PF_FP_ABST
Abstract
Description
Data processing method, computer device and chip
[0001] This application claims priority to Chinese patent application number 202311105673.9, filed on August 30, 2023, entitled “Data processing method, computer device and chip”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of computer technology, and in particular to a data processing method, computer equipment, and chip. Background Art
[0003] Direct Memory Access (DMA) is a function provided by the computer bus architecture, which is used to send data from devices such as disk drives and hard drives directly to the memory of the computer motherboard.
[0004] In related technologies, data is acquired serially through direct memory access, and the data stored on the hard disk is moved to the on-chip memory for the on-chip processor or processing core to perform data processing, thereby realizing data reading and use.
[0005] However, in the related art, during the data migration process, the data on the on-chip memory is consistent with the data stored on the hard disk, and data processing needs to be performed after the data migration, resulting in relatively low data processing efficiency of the processor or processing core on the chip.
[0006] Summary of the Invention
[0007] This application provides a data processing method, computer device, and chip. The technical solutions are as follows:
[0008] According to one aspect of the present application, a data processing method is provided. The method is performed by a transmission device, wherein a bus connection is established between the transmission device and a storage device. The method includes:
[0009] Obtaining a tensor acquisition request, where the tensor acquisition request is used to instruct the transmission device to provide a target tensor to the processing device;
[0010] Acquire a command descriptor according to the address information carried in the tensor acquisition request, where the command descriptor is used to indicate a method for acquiring the target tensor in the storage device;
[0011] Based on the command descriptor, an initial tensor is read from the storage device, and based on the command descriptor, the initial tensor is edited to obtain the target tensor, wherein the initial tensor includes the target tensor;
[0012] The target tensor is sent to the processing device.
[0013] According to another aspect of the present application, a computer device is provided, comprising: a processing device, a transmission device, and a storage device, wherein the processing device and the transmission device are connected to each other, and a bus connection is established between the transmission device and the storage device;
[0014] The transmission device is configured to obtain a tensor acquisition request sent by the processing device, where the tensor acquisition request is configured to instruct the transmission device to provide a target tensor to the processing device;
[0015] The transmission device is further configured to obtain a command descriptor from the storage device according to the address information carried in the tensor acquisition request, wherein the command descriptor is used to indicate a method for obtaining the target tensor in the storage device;
[0016] The transmission device is further configured to read an initial tensor from the storage device based on the command descriptor, and edit the initial tensor based on the command descriptor to obtain the target tensor, wherein the initial tensor includes the target tensor;
[0017] The transmission device is further configured to send the target tensor to the processing device.
[0018] According to another aspect of an embodiment of the present application, a chip is provided, which includes at least one of a programmable logic circuit and a program instruction, and when the chip is running, is used to implement the above-mentioned data processing method.
[0019] The beneficial effects of the technical solution provided by this application include at least:
[0020] By performing data transmission between the storage device and the processing device through the transmission device, it is possible to avoid occupying the bus process of the processing device. By editing the initial tensor in the storage device through the transmission device to obtain the target tensor, and sending the target tensor directly to the processing device, it is possible to perform pre-processing of the initial tensor before the processing device obtains the target tensor, thereby reducing the computing power requirements for the processing device and saving the processing time of the processing device; performing editing of the initial tensor based on the transmission device saves the memory usage of the processing device and improves processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] FIG1 is a schematic diagram of a computer system provided by an exemplary embodiment of the present application;
[0022] FIG2 is another schematic diagram of a computer system provided by an exemplary embodiment of the present application;
[0023] FIG3 is a schematic diagram of a data processing method provided by an exemplary embodiment of the present application;
[0024] FIG4 is a flow chart of a data processing method provided by an exemplary embodiment of the present application;
[0025] FIG5 is another flow chart of a data processing method provided by an exemplary embodiment of the present application;
[0026] FIG6 is a schematic diagram of an initial tensor and a target tensor provided by an exemplary embodiment of the present application;
[0027] FIG7 is a schematic diagram of an initial tensor provided by an exemplary embodiment of the present application;
[0028] FIG8 is another flow chart of a data processing method provided by an exemplary embodiment of the present application;
[0029] FIG9 is a structural block diagram of a transmission device provided by an exemplary embodiment of the present application;
[0030] FIG10 is another structural block diagram of a transmission device provided by an exemplary embodiment of the present application;
[0031] FIG11 is another flow chart of a data processing method provided by an exemplary embodiment of the present application;
[0032] FIG12 is a structural block diagram of a transmission device provided by an exemplary embodiment of the present application;
[0033] FIG13 is a structural block diagram of a computer device provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0034] FIG1 shows a schematic diagram of a computer system provided by one embodiment of the present application. The computer system can be implemented as a system architecture of a data processing method. The computer system may include: a processing device 110, a transmission device 120, and a storage device 130.
[0035] The processing device 110 may be a processor including one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor may be implemented in at least one hardware form of a digital signal processing (DSP), a field programmable gate array (FPGA), or a programmable logic array (PLA). Exemplarily, the processing device 110 may be at least one of a central processing unit (CPU), a graphics processing unit (GPU), and an artificial intelligence (AI) processor, or may be other devices with data processing capabilities, which are not limited in this application.
[0036] The transmission device 120 may be a processor including one or more processing cores. Furthermore, the processing device 110 and the transmission device 120 may be separate devices or different components of the same device. For example, the processing device 110 and the transmission device 120 may be different components of a single image processor, for example, corresponding to different processing cores. In one example, the processing device 110 and the transmission device 120 have independent memory spaces.
[0037] The storage device 130 is an electronic device with data storage capabilities. The storage device 130 can be a high-speed random access memory or a non-volatile memory, such as one or more magnetic disk storage devices or flash memory storage devices. The storage device 130 can be a storage device independent of the processor or a memory integrated within the processor, such as a high-speed cache. A bus connection is established between the storage device 130 and the transmission device 120.
[0038] Figure 2 shows another schematic diagram of a computer system provided by one embodiment of the present application. In one implementation, the processing device includes a level 1 L1 cache (L1MEM) 112, a matrix calculation engine 114, a vector calculation engine 116, and a control unit 118; the transmission device can be implemented as a data transfer engine (DTE) 120a; the storage device can be implemented as a level 2 / level 3 L2 / L3 cache 130a; and a bus connection is established between the data transfer engine 120a and the L2 / L3 cache 130a via a bus interface unit 122.
[0039] The data transfer engine 120a moves tensors from the off-chip L2 / L3 cache 130a to the on-chip L1 cache 112 or the shared memory (SMEM) 118a within the control unit 118. For example, the matrix calculation engine 114 deployed on the chip is used to perform matrix calculations, and the vector calculation engine 116 is used to perform vector calculations. Data processing is performed on the obtained tensors by the matrix calculation engine 114 and the vector calculation engine 116.
[0040] 3 is a schematic diagram of a data processing method provided by an exemplary embodiment of the present application. The method can be executed by a transmission device, and a bus connection is established between the transmission device and the storage device.
[0041] In this embodiment, the transmission device obtains a tensor acquisition request 310 , which is used to instruct the transmission device to provide a target tensor to the processing device. The target tensor is a tensor that requires the processing device to perform data processing. The tensor acquisition request 310 carries address information 312 .
[0042] The transfer device retrieves a command descriptor 320 based on the address information 312 carried in the tensor retrieval request 310. Command descriptor 320 indicates how to retrieve the target tensor from the storage device. Specifically, command descriptor 320 includes various types of information, such as at least one of an operation type, data location, data size, operation location, and transformation information.
[0043] In some embodiments, the command descriptor 320 includes a read subcommand 322 and an operation subcommand 324. For example, the read subcommand 322 carries a data location and a data size, and the operation subcommand 324 carries an operation type and an operation location.
[0044] The transmission device reads the initial tensor 332 from the storage device 130 according to the data position and data size carried by the read sub-command 322. The data position is used to indicate the storage position of the initial tensor 332 in the storage device 130, and the data size is used to indicate the data size of the initial tensor 332.
[0045] The transmission device performs editing on the initial tensor according to the operation type and operation position carried by the operation sub-command 324 to obtain the target tensor 334. The operation type is used to indicate the method of performing editing on the initial tensor, and the operation position is used to indicate the position where the editing is performed in the initial tensor.
[0046] In one implementation, the operation type carried by the operation subcommand 324 includes a slicing operation 324a. The operation subcommand 324 also carries the number of operations and the operation position. The number of operations is used to indicate the number of times the slicing is performed. Specifically, in response to the operation type being a slicing operation, the transmission device performs n slicing on the initial tensor, and determines the n sub-tensors corresponding to the n slices as the target tensor 334. The operation position indicates the position where the first slicing is performed on the initial tensor, and the number of processing times is used to indicate the number of times continuous slicing is performed in at least one dimension. Taking a three-dimensional tensor as an example, the number of processing times is indicated by a vector representation of (1, 3, 1), which specifically indicates that only one slice is performed in the first dimension, three consecutive slices of the same size are performed in the second dimension, and only one slice is performed in the third dimension. The transmission device sends the target tensor 334 to the processing device.
[0047] In another implementation, the operation type carried by the operation subcommand 324 includes an inverse slicing operation 324b. The operation subcommand 324 also carries transformation information and an operation position, where the transformation information is used to indicate how the dimensions of the tensor are swapped. Specifically, in response to the operation type being an inverse slicing operation and a layout transformation operation, the transmission device performs a swap on at least two dimensions of the first tensor in the initial tensor according to the transformation information to obtain a transformed tensor, such as converting the dimensional order of the first tensor from a height-width-channel (HWC) format to a channel-height-width (CHW) format. The transformed tensor is filled into the operation position in the second tensor to obtain a target tensor 334. The transmission device sends the target tensor 334 to the processing device.
[0048] Next, the data processing method in this application is introduced.
[0049] FIG4 shows a flow chart of a data processing method provided by an exemplary embodiment of the present application. The method may be performed by a transmission device, wherein a bus connection is established between the transmission device and the storage device. The method includes at least a portion of steps 510, 520, 530, and 540:
[0050] Step 510: Get a tensor get request.
[0051] A tensor can be viewed as a multi-dimensional array. For example, a one-dimensional tensor can be represented as a vector, and a two-dimensional tensor can be represented as a matrix. In a high-dimensional tensor, each dimension can represent a data attribute or feature.
[0052] Exemplarily, a tensor acquisition request is request information instructing a transmission device to provide a target tensor to a processing device, that is, a tensor acquisition request is used to instruct the transmission device to provide a target tensor to the processing device. The target tensor is a tensor that the processing device needs to perform data processing on.
[0053] Exemplarily, the tensor acquisition request may be sent by other devices to the transmission device, or may be generated by the transmission device; specifically, the processing device sends a tensor acquisition request to the transmission device; or the storage device sends a tensor acquisition request to the transmission device according to a preset period; or the transmission device generates a tensor acquisition request according to a preset period. Furthermore, the preset period is determined by any one of the transmission device, the processing device, and the storage device, or is determined by negotiation between at least two of the above devices, and this application does not impose any restrictions on this. Exemplarily, a tensor is a one-dimensional or multi-dimensional array; exemplarily, the dimension of a tensor is the same as the number of indices of the elements in the tensor. For example, a two-dimensional tensor can be represented as a matrix, and the elements in the two-dimensional tensor have two indices (for example, rows and columns) to determine the position of the elements in the two-dimensional tensor.
[0054] Step 520: Obtain the command descriptor according to the address information carried in the tensor acquisition request.
[0055] The command descriptor contains various types of information, such as at least one of the operation type, data location, data size, operation location, and transformation information. The command descriptor has corresponding address information. Generally, the address information of the command descriptor corresponds one-to-one with the command descriptor. For example, the tensor acquisition request carries the address information of the command descriptor, and the address information of the command descriptor is added to the command descriptor based on the target tensor on which the processing device needs to perform data processing.
[0056] Exemplarily, when generating a tensor acquisition request, the target tensor has a corresponding command descriptor, and the address information of the command descriptor corresponding to the target tensor is added to the tensor acquisition request. The address information is used to indicate the storage location of the command descriptor. The command descriptor is usually stored in the processing device. Accordingly, the storage location indicated by the address information corresponds to the memory space of the processing device; however, it does not rule out the case where the command descriptor is stored in a storage device or a transmission device. Accordingly, the storage location indicated by the address information corresponds to the memory space of the storage device or the transmission device. Exemplarily, the command descriptor is used to indicate the acquisition of the target tensor in the storage device; optionally, the command descriptor is also used to indicate at least one of a read operation and an edit operation. Specifically, the target tensor required by the processing device is obtained in the storage device through the read operation and the edit operation indicated by the command descriptor.
[0057] Step 530: Based on the command descriptor, read the initial tensor from the storage device, and perform editing on the initial tensor based on the command descriptor to obtain the target tensor.
[0058] The initial tensor is a tensor read directly from the storage device. The target tensor is obtained after the initial tensor is edited by the storage device. In this embodiment, the initial tensor and the target tensor can be one-dimensional tensors, or high-dimensional tensors with more than one dimension, such as two-dimensional tensors, four-dimensional tensors, etc., and this application does not limit this. The dimensions of the initial tensor and the target tensor can be the same or different. For example, the initial tensor is a four-dimensional tensor, and the target tensor is a two-dimensional tensor. Exemplarily, the initial tensor includes a target tensor; specifically, the target tensor can be a sub-tensor in the initial tensor, and the target tensor can also be obtained by performing combination, layout transformation, etc. on the initial tensor, and this application does not limit this.
[0059] Step 540: Send the target tensor to the processing device.
[0060] Exemplarily, the transmission device sends the edited target tensor to the processing device.
[0061] For example, the processing device can send the target tensor to the processing device via a data transmission connection, and the processing device can receive and write the target tensor into the memory space. Alternatively, the transmission device can directly write the target tensor into the memory space of the processing device. In one implementation, the transmission device and the processing device have independent memory spaces. This application does not impose any restrictions on the size of the memory spaces of the transmission device and the processing device.
[0062] To sum up, the method provided in this embodiment performs data transmission between the storage device and the processing device through the transmission device, avoiding occupying the bus process of the processing device to directly perform data acquisition, and edits the initial tensor in the storage device through the transmission device to obtain the target tensor, and directly sends the target tensor to the processing device. It can realize pre-processing of the initial tensor before the processing device obtains the target tensor, reducing the computing power requirements of the processing device and saving the processing time of the processing device; performing editing of the initial tensor based on the transmission device saves the memory occupation of the processing device and improves processing efficiency.
[0063] FIG5 shows another flow chart of a data processing method provided by an exemplary embodiment of the present application. The method can be executed by a transmission device. That is, in the embodiment shown in FIG4 , step 530 can be implemented as at least a portion of steps 532 and 534:
[0064] Step 532: According to the data location and data size carried by the read subcommand, read the initial tensor from the storage device.
[0065] In this embodiment, the command descriptor includes an operation subcommand and a read subcommand, which will be introduced below through two steps in this embodiment.
[0066] Exemplarily, for a read subcommand in a command descriptor, the read subcommand carries a data location and a data size. The data location carried by the operation subcommand indicates the storage location of the initial tensor in the storage device. The data location can be a storage address in the storage device or a relative position in the storage device. The data size indicates the data size of the initial tensor. Exemplarily, taking a three-dimensional tensor as an example, the data size includes information about the width, height, and depth of the tensor. Exemplarily, the data size can be indicated by the number of elements in the tensor or by the bit length occupied by the tensor.
[0067] Exemplarily, by reading the data position and data size carried in the sub-command, the starting position of the initial tensor to be read in the storage device and the data size of the initial tensor to be read are indicated, thereby realizing the determination and reading of the initial tensor in the storage device.
[0068] It should be noted that this embodiment only shows an example of the combined implementation of step 532 and step 534; in one implementation, the command descriptor includes a read sub-command, and step 532 can be implemented as: reading the initial tensor in the storage device according to the data position and data size carried by the read sub-command; and performing editing on the initial tensor based on the command descriptor to obtain the target tensor; the above steps can be combined with step 510, step 520 and step 540 in the embodiment of Figure 4 to form a new embodiment and be implemented separately, and this application does not limit this.
[0069] Step 534: Edit the initial tensor according to the operation type and operation position carried by the operation sub-command to obtain the target tensor.
[0070] Exemplarily, for the operation subcommand in the command descriptor, the operation subcommand carries an operation type and an operation position; wherein the operation type carried by the operation subcommand is used to indicate the method of performing editing on the initial tensor; exemplary, the method of performing editing on the initial tensor includes but is not limited to at least one of cropping clips, modifying element content, and performing layout transformation. Exemplarily, the operation position is used to indicate the position where the editing is performed in the initial tensor. The operation position can directly indicate the position in the initial tensor, such as: the nth element in a one-dimensional initial tensor; or it can indicate a relative position in the initial tensor, such as: the last column of tensors from left to right in a two-dimensional tensor.
[0071] For example, the operation type and operation position carried in the operation sub-command indicate the location of editing the initial tensor and the method of editing the initial tensor, which can realize editing of the initial tensor such as cropping slices, modifying element content, and performing layout transformation.
[0072] It should be noted that this embodiment only shows an example of the combined implementation of step 532 and step 534; in one implementation, the command descriptor includes an operation sub-command, and step 534 can be implemented as: based on the command descriptor, reading the initial tensor in the storage device; and performing editing on the initial tensor according to the operation type and operation position carried by the operation sub-command to obtain the target tensor; the above steps can be combined with step 510, step 520 and step 540 in the embodiment of Figure 4 to form a new embodiment and be implemented separately, and this application does not limit this.
[0073] To sum up, the method provided in this embodiment performs data transmission between the storage device and the processing device through the transmission device, avoiding occupying the bus process of the processing device to directly perform data acquisition. The data position and data size carried by the read sub-command indicate the method of reading the initial tensor in the storage device, and the operation type and operation position carried by the operation sub-command indicate the method of editing the initial tensor. It can realize the pre-processing of the tensor before the processing device obtains the tensor, reduce the computing power requirements of the processing device and save the processing time of the processing device; based on the transmission device, the editing of the initial tensor is performed to obtain the target tensor required by the processing device, save the memory occupation of the processing device and improve the processing efficiency.
[0074] In an optional implementation, the method may be performed by a transmission device, and step 532 in FIG5 may be implemented as sub-step 32, and step 534 may be implemented as sub-step 34:
[0075] Sub-step 32: Based on the data position and data size carried by the read sub-command, call the second execution engine deployed in the transmission device to perform data reading on the storage device to obtain an initial tensor.
[0076] Exemplarily, the second execution engine includes a read interface (Read Interface) connecting the transmission device to the storage device. The read interface can be used to read data in the local memory (Local Memory) or to read data through the bus (Bus); in one example, the read interface includes a local memory read request engine (Local Memory Read Request Engine) and a bus read request engine (Bus Read Request Engine) arranged in parallel.
[0077] Sub-step 34: Based on the operation type and operation position carried by the operation sub-command, call the first execution engine deployed in the transmission device to perform editing on the initial tensor to obtain the target tensor.
[0078] Exemplarily, the transmission device includes at least one processing unit, and the first execution engine includes a processing unit in the transmission device, which may be one or more processing units, and the processing unit is capable of editing the read initial tensor. In one example, the first execution engine is used to perform a layout transformation operation on the initial tensor, and the first execution engine is a tensor layout transformation engine (Tensor Layout Trans Engine).
[0079] In this embodiment, a first execution engine and a second execution engine are deployed in the transmission device; in another implementation method, sub-step 32 and sub-step 34 can be split and implemented separately. The specific implementation method can refer to the splitting method of step 532 and step 534 above. This application does not limit the implementation method of sub-step 32 and sub-step 34 separately.
[0080] To sum up, the method provided in this embodiment performs data transmission between the storage device and the processing device through the transmission device, avoiding occupying the bus process of the processing device to directly execute data acquisition, calling the second execution engine to perform reading of the initial tensor based on the read sub-command, and calling the first execution engine to edit and obtain the target tensor based on the operation sub-command, which can realize the pre-processing of the initial tensor before the processing device obtains the target tensor, reducing the computing power requirements of the processing device and saving processing time; based on the transmission device, the editing of the initial tensor is performed to obtain the target tensor required by the processing device, saving the memory occupation of the processing device and improving processing efficiency.
[0081] Next, the operation sub-commands in this application are further introduced. The operation type carried in the operation sub-command can be implemented in at least one of the following two implementation methods.
[0082] Implementation method 1: The operation type carried by the operation sub-command is a slice operation.
[0083] Implementation method 2: The operation type carried by the operation sub-command is a deslice operation.
[0084] The following will introduce the two implementation methods respectively.
[0085] Implementation method 1: The operation type carried by the operation sub-command is a slicing operation.
[0086] Accordingly, the method can be executed by a transmission device, and step 534 in FIG. 5 above can be implemented as sub-step 36:
[0087] Sub-step 36: In response to the operation type being a slicing operation, slicing is performed on the initial tensor according to the operation position to obtain a target tensor.
[0088] Exemplarily, a slicing operation is used to instruct the extraction of a sub-tensor from an initial tensor, and the operation position indicates the starting and ending positions of the slicing operation on the initial tensor. The operation position indicates the location information of the target tensor within the initial tensor. In this embodiment, the target tensor is a sub-tensor within the initial tensor. Specifically, in response to the operation type being a slicing operation, the transmission device slices the initial tensor according to the operation position to obtain the target tensor.
[0089] Figure 6 shows a schematic diagram of an initial tensor and a target tensor provided by an exemplary embodiment of the present application. For example, initial tensor 412 is a three-dimensional tensor, and the ratio of the number of elements in the first dimension 402 (Dimensionality 1, dim1), the second dimension 404 (Dimensionality 2, dim2), and the third dimension 406 (Dimensionality 3, dim3) of initial tensor 412 is 4:3:3.
[0090] In one example, an initial tensor 412 is described with 4, 3, and 3 elements in the first dimension 402 to the third dimension 406, respectively. The operation position in the operation subcommand indicates the starting and ending positions of slicing the initial tensor 412. The target tensor obtained by slicing can be a single element or a tensor composed of multiple elements. It is understood that the dimension of the target tensor does not exceed the dimension of the initial tensor 412.
[0091] Illustratively, the first target tensor 416 is an element in the initial tensor 412 , the first element from top to bottom in the first dimension 402 , the first element from front to back in the second dimension 404 , and the third element from left to right in the third dimension 406 .
[0092] The second target tensor 417 is a one-dimensional tensor consisting of two elements in the initial tensor 412, including the first element from top to bottom in the first dimension 402, the first element and the second element from front to back in the second dimension 404, and the first element from left to right in the third dimension 406.
[0093] The third target tensor 418 is a two-dimensional tensor consisting of six elements in the initial tensor 412, including the second and third elements from top to bottom in the first dimension 402, the first element from front to back in the second dimension 404, and the first to third elements from left to right in the third dimension 406.
[0094] The fourth target tensor 419 is a three-dimensional tensor consisting of eight elements in the initial tensor 412, including the first element and the second element from top to bottom in the first dimension 402, the third element and the fourth element from front to back in the second dimension 404, and the second element and the third element from left to right in the third dimension 406.
[0095] Furthermore, in an optional implementation, the operation subcommand also carries an operation number, which is used to indicate the number of times the slice is processed.
[0096] Sub-step 36 can be implemented as follows: in response to the operation type being a slicing operation, the transmission device performs n slicing on the initial tensor, and determines n sub-tensors corresponding to the n slices one-to-one as the target tensor.
[0097] The operation subcommand also carries an operation number, which indicates the number of times to perform the slicing process. The operation number indicates the number of times to perform consecutive slicing in at least one dimension. The operation position indicates the location where the first slicing is performed on the initial tensor. The operation number is also referred to as a repeat parameter.
[0098] In one implementation, the number of operations is represented by a vector information. For example, the number of operations is (1, 3, 1), and the number of operations is used to indicate the number of slices in three dimensions; specifically, the number of operations (1, 3, 1) means slicing only once in the first dimension, slicing three times continuously with the same size in the second dimension, and slicing only once in the third dimension. Taking the first target tensor 416 in Figure 6 as an example, the number of operations is (1, 3, 1), and the three sub-tensors obtained by the slicing operation include the first element from top to bottom in the first dimension 402, the first element to the third element from front to back in the second dimension 404, and the third element from left to right in the third dimension 406. The sizes of the three sub-tensors are the same as those of the first target tensor 416.
[0099] Furthermore, in an optional implementation, the operation subcommand also carries transformation information, and the transformation information is used to indicate how to swap the dimensions of the tensor.
[0100] Sub-step 36 can be implemented as follows: the transmission device responds to the operation type being a slicing operation and a layout transformation operation, slices the initial tensor according to the operation position to obtain a sub-tensor; and swaps at least two dimensions of the sub-tensor according to the transformation information to obtain a target tensor.
[0101] Exemplarily, the transformation information is used to indicate that at least two dimensions of the sub-tensor are to be swapped. Exemplarily, the layout transformation of the sub-tensor is achieved by rearranging the elements in the sub-tensor by adjusting the positions of the elements in the sub-tensor.
[0102] Taking the initial tensor 412 in FIG. 6 as an example, in one example, the first dimension 402 of the initial tensor 412 represents the product model information, the second dimension 404 represents the product price, and the third dimension 406 represents the product's origin. The sub-tensor obtained by slicing corresponds to the position of the second target tensor 417 in the initial tensor 412. The transformation information is used to indicate that the second dimension 404 and the third dimension 406 of the sub-tensor are swapped. That is, the second dimension 404 of the swapped target tensor represents the product's origin, and the third dimension 406 represents the product's price. Accordingly, the elements in the sub-tensor are rearranged, transforming from a sub-tensor of size (1, 2, 1) to a target tensor of size (1, 1, 2).
[0103] In summary, the method provided in this embodiment performs data transmission between the storage device and the processing device through the transmission device, avoiding occupying the bus process of the processing device to directly perform data acquisition, and can perform at least one of single slicing, continuous slicing and layout transformation of the initial tensor before the processing device obtains the target tensor, thereby reducing the computing power requirements of the processing device and saving processing time; performing editing of the initial tensor based on the transmission device saves the memory occupation of the processing device and improves processing efficiency.
[0104] Implementation method 2: The operation type carried by the operation sub-command is the anti-slicing operation.
[0105] Accordingly, the method can be executed by a transmission device, and step 534 in FIG. 5 above can be implemented as sub-step 37:
[0106] Sub-step 37: In response to the operation type being a deslicing operation, fill the first tensor in the initial tensor into the operation position in the second tensor to obtain a target tensor.
[0107] Exemplarily, the initial tensor includes at least two tensors, specifically, the at least two tensors include a first tensor and a second tensor. The reverse slicing operation is used to indicate the replacement of part of the content in the second tensor according to the first tensor, and the operation position indicates the position information when the content in the second tensor is replaced. In this embodiment, the target tensor obtained after editing is a combined tensor of at least two tensors in the initial tensor. Specifically, in response to the operation type being a reverse slicing operation, the transmission device fills the first tensor in the initial tensor into the operation position in the second tensor to obtain the target tensor.
[0108] 7 shows a schematic diagram of an initial tensor provided by an exemplary embodiment of the present application. Exemplarily, the second tensor 424 is a three-dimensional tensor, and the ratio of the number of elements in the first dimension 402, the second dimension 404, and the third dimension 406 of the second tensor 424 is 4:3:3.
[0109] In this embodiment, the first tensor 422 is described as one element, using the example where the number of elements in the first dimension 402 to the third dimension 406 of the second tensor 424 is 4, 3, and 3, respectively. In another implementation, the first tensor 422 is a three-dimensional tensor where the number of elements in the first dimension 402 to the third dimension 406 of the second tensor 424 is 4, 3, and n times 3, respectively. The first tensor 422 is a three-dimensional tensor where the number of elements in each of the three dimensions is n, where n is an integer greater than 1.
[0110] Exemplarily, the operation position indicates the filling position of the first tensor in the second tensor. In Figure 7, the filling position of the first tensor 422 in the second tensor 424 is the first element of the second tensor 424 from top to bottom in the first dimension 402, the second element from front to back in the second dimension 404, and the third element from left to right in the third dimension 406.
[0111] Furthermore, in an optional implementation, the operation subcommand also carries transformation information, and the transformation information is used to indicate how to swap the dimensions of the tensor.
[0112] Sub-step 37 can be implemented as follows: the transmission device responds to the operation type being an inverse slicing operation and a layout transformation operation, performs a swap on at least two dimensions of the first tensor according to the transformation information, and obtains a transformed tensor; and fills the transformed tensor into the operation position in the second tensor to obtain a target tensor.
[0113] For example, a layout transformation operation is first performed on the first tensor, and then an unslicing operation is performed to fill the transformed tensor obtained after the layout transformation into the operation position in the second tensor to obtain the target tensor. For an introduction to performing layout transformations on the first tensor, please refer to the introduction to performing layout transformations on sub-tensors above, and will not be repeated here.
[0114] To sum up, the method provided in this embodiment performs data transmission between the storage device and the processing device through the transmission device, avoiding occupying the bus process of the processing device to directly perform data acquisition, and can perform deslicing and / or layout transformation on the initial tensor before the processing device obtains the target tensor, thereby reducing the computing power requirements of the processing device and saving the processing time of the processing device; performing editing of the initial tensor based on the transmission device saves the memory occupation of the processing device and improves processing efficiency.
[0115] FIG8 shows another flow chart of a data processing method provided by an exemplary embodiment of the present application. The method can be executed by a transmission device. That is, in the embodiment shown in FIG4 , step 540 can be implemented as step 542, further including step 525:
[0116] Step 525: Decode the command descriptor to obtain a command decode.
[0117] Exemplarily, the command decoding is obtained by the transmission device decoding the command descriptor. Specifically, the command decoding obtained by the transmission device decoding the command descriptor is an internal command of the transmission device. Furthermore, the engine deployed in the transmission device is controlled based on the command decoding. Exemplarily, the initial tensor and the target tensor in this embodiment are obtained based on the command decoding. The command decoding is decoding information used to indicate the method for extracting the initial tensor and the method for editing the initial tensor, that is, the command decoding is used to indicate the method for extracting the initial tensor and the method for editing the initial tensor.
[0118] Furthermore, decoding of the command descriptor is performed by a third execution engine deployed in the transmission device, and the third execution engine includes a command decoder (CMD Decoder) in the transmission device, which can receive the command descriptor and decode the command descriptor to convert the command descriptor into an internal command suitable for the transmission device. Optionally, the third execution engine also includes a micro-operation engine (Uop Engine) for decomposing the decoded command code into a series of micro-operations for execution in the subsequent data transmission process, and for assigning the decoded command code to other execution engines deployed in the transmission device, such as the first execution engine and the second execution engine. For the introduction of the first execution engine and the second execution engine, please refer to sub-steps 32 and 34 above, which will not be repeated here.
[0119] It should be noted that this embodiment can be combined with the above embodiment to form a new embodiment. In one implementation, the command decoding includes a first subcode and a second subcode; the first subcode corresponds to the operation subcode in the command descriptor, and the first subcode is the decoding information of the operation subcode; specifically, according to the decoding information of the operation type and operation position included in the first subcode, the first execution engine deployed in the transmission device is instructed to perform editing on the initial tensor. The second subcode corresponds to the read subcommand in the command descriptor. The second subcode is the decoding information of the read subcommand; specifically, according to the decoding information of the data position and data size included in the first subcode, the second execution engine deployed in the transmission device is instructed to perform data reading on the storage device.
[0120] Step 542: Write the target tensor into the memory space of the processing device according to the write location indicated by the write subcommand.
[0121] Exemplarily, the command descriptor includes a write subcommand; the write location carried by the write subcommand indicates the location in the memory space of the processing device where the target tensor is written. Exemplarily, the write subcommand may also carry the data size of the target tensor; exemplarily, taking a three-dimensional tensor as an example, the data size includes information about the width, height, and depth of the tensor; exemplarily, the data size may be indicated by the number of elements in the tensor or by the bit length occupied by the tensor.
[0122] Furthermore, writing the target tensor to the memory space of the processing device is executed by calling the fourth execution engine in the transmission device; for example: based on the write position carried by the write sub-command, calling the fourth execution engine deployed in the transmission device to write the target tensor to the memory space of the processing device.
[0123] Exemplarily, the fourth execution engine includes a write interface (Write Interface) in the transmission device, which can be used to write data to the local memory (Local Memory) or to write data through the bus (Bus); in one example, the write interface includes a local memory write request engine (Local Memory Write Request Engine) and a bus write request engine (Bus Write Request Engine) set in parallel.
[0124] It should be noted that step 525 in this embodiment can be combined with steps 510 to 540 in Figure 4 to form a new embodiment and implemented separately; step 542 in this embodiment can be combined with steps 510 to 530 in Figure 4 to form a new embodiment and implemented separately; this application does not impose any restrictions on this.
[0125] To sum up, the method provided in this embodiment performs data transmission between the storage device and the processing device through the transmission device, avoiding occupying the bus process of the processing device to directly perform data acquisition, and can realize the pre-processing of the initial tensor before the processing device obtains the target tensor; by performing unified decoding of the command descriptor in the transmission device, the splitting and allocation of the command descriptor is avoided, and the decoding complexity of the command descriptor is reduced; the transmission device directly writes the target tensor to the memory space of the processing device, reducing the computing power requirements of the processing device and improving processing efficiency.
[0126] FIG9 shows a structural block diagram of a transmission device provided by an exemplary embodiment of the present application.
[0127] Exemplarily, a command decoder (CMD Decoder) 460 , a micro-operations engine (uop Engine) 465 , a read interface (Read Interface) 470 , a layout conversion engine (Tensor Layout Trans Engine) 475 , and a write interface (Write Interface) 480 are deployed in the transmission device.
[0128] The request buffer 462 in the command decoder 460 stores received tensor acquisition requests 461. Tensor acquisition requests 461 are used to instruct the transmission device to provide the target tensor to the processing device. Request buffer 462 caches these requests in a first-in, first-out (FIFO) manner. The tensor acquisition request 461 carries the storage address of a command descriptor, which is stored in descriptor memory (desc mem) 462a. The command description (CMD desp) 464 parses the command descriptor to obtain the corresponding command decode, which is then transmitted to the microinstruction engine 465. The microinstruction engine 465 includes a 1D engine 466a, a 2D engine 466b, and a 4D engine 466c according to the dimensions of the tensor. It is understood that more engines can be deployed in the microinstruction engine 465 to decode and split the commands corresponding to tensors of different dimensions, obtain microinstructions, and cache them in the microinstruction buffer 468. The microinstruction buffer 468 sends the corresponding microinstructions to be executed to the read interface 470, the layout conversion engine 475, and the write interface 480 in the transmission device.
[0129] Exemplarily, the read interface 470 includes a local memory read request engine 472 and a bus read request engine 474; the local memory read request engine 472 is used to process read requests corresponding to local storage 471a, and the bus read request engine 474 is used to process read requests corresponding to bus 471b. The initial tensor is read from local storage 471a or bus 471b, and the initial tensor is stored in the data write buffer (Data in FIFO) 475a. The layout conversion engine 475 performs layout conversion on the tensor in the data write buffer 475a to obtain the target tensor, and stores the target tensor in the data write buffer 475b. The write interface 480 writes the target tensor in the data write buffer (Data out FIFO) 475b; specifically, the target tensor can be written to the local memory through the local memory write request engine 482, or the target tensor can be written to the memory space of the processing device through the bus through the bus write request engine 484.
[0130] For example, the command decoder 460, microinstruction engine 465, read interface 470, layout conversion engine 475, and write interface 480 in this embodiment can be described with reference to the first to fourth execution engines described above. It should be noted that the read interface 470, layout conversion engine 475, and write interface 480 in this embodiment can be combined into an engine group, and multiple engine groups arranged in parallel can be deployed in the transmission device.
[0131] For example, FIG10 shows another structural block diagram of a transmission device provided by an exemplary embodiment of the present application. The command description 464 obtains the command descriptor corresponding to the tensor acquisition request 461 from the request buffer 462 and performs parsing on the command descriptor. In this embodiment, the transmission device is deployed with three parallel engine groups: a first execution engine group 490a, a second execution engine group 490b, and a third execution engine group 490c. Each engine group includes a read interface, a layout conversion engine, and a write interface. A microinstruction engine may also be included, which is not limited by the present application. It is understandable that in another example, a larger number of parallel engine groups may be deployed in the transmission device.
[0132] In a specific example, the processing device corresponds to an electronic device with data processing capabilities such as a digital signal processing (DSP) or a graphics processing unit (GPU), and is used to perform data processing on the training process or application process of an artificial neural network (ANN). Exemplarily, the target tensor is a tensor that needs to be used in the process of the electronic device performing data processing on the artificial neural network, such as the target tensor including but not limited to at least one of the model parameters of the artificial neural network, the training samples of the artificial neural network model, and the input parameters of the artificial neural network model; it can be understood that the tensor can be a one-dimensional vector or a high-dimensional matrix composed of numbers, corresponding to the model parameters of the artificial neural network or multimedia information such as audio data, video data, and image data; the tensor can also be a one-dimensional or high-dimensional tensor composed of characters, which can include at least one of information such as numbers, letters, symbols, and Chinese characters.
[0133] Exemplarily, the transmission device is a partial processing core in a digital signal processing or image processor, referred to as a data transmission core; the data transmission core receives a tensor acquisition request sent by a data processing core in the digital signal processing or image processor for performing data processing on a target tensor.
[0134] In one implementation, the target tensor is a network parameter and / or a training sample used in an artificial neural network training process. According to the address information carried in the tensor acquisition request, a command descriptor corresponding to the network parameter and / or the training sample is acquired.
[0135] The data transmission core reads the initial tensor from the hard disk based on the command descriptor, and edits the initial tensor based on the command descriptor to obtain network parameters and / or training samples used in the artificial neural network training process; the data transmission core sends the network parameters and / or training samples to the data processing core.
[0136] For example, if the target tensor is a network parameter, the ANN model consists of multiple sub-models deployed in parallel and / or serially. The target tensor is the network parameters corresponding to some of these sub-models. The initial tensor includes all the network parameters in the ANN model. By slicing all the network parameters in the ANN model, the target tensor, i.e., the network parameters corresponding to some of the sub-models, is obtained.
[0137] For example, a target tensor is a training sample. A single training run of an artificial neural network model requires both sample images and sample labels. For example, a sample image is fed into the artificial neural network model, and a predicted label is obtained. The artificial neural network model is trained by comparing the predicted label with the sample label. The initial tensor includes an image group consisting of multiple sample images and a label group consisting of multiple sample labels. By performing unslicing on the label group, the labels are added to the end of the corresponding sample images, forming a sample group tensor (i.e., the target tensor) consisting of the sample images and the corresponding sample labels.
[0138] In another implementation, the target tensor is an input parameter used in the artificial neural network application process. A command descriptor corresponding to the transmitted input parameter is obtained based on the address information carried in the tensor acquisition request. For example, in the case of an artificial neural network model used to predict the type of object contained in an image, the initial tensor is the input image to the artificial neural network model. Slicing is performed on the input image to extract subregions within the input image, thereby providing different image regions to the submodels within the artificial neural network model. In other words, the target tensor is the multiple subregions within the sliced input image.
[0139] For example, by executing the acquisition and transmission of the target tensor during the training process or application process of the artificial neural network model, the processing efficiency of the training process or application process of the artificial neural network model can be improved, and the data processing time of calling the artificial neural network model can be saved.
[0140] FIG11 shows another flow chart of a data processing method provided by an exemplary embodiment of the present application. This method can be executed by a transmission device. That is, based on the embodiment shown in FIG4 , after step 520 and before step 530, the method further includes step 526:
[0141] Step 526: Determine the element arrangement position according to the tensor dimension information.
[0142] Exemplarily, the element arrangement position is used to indicate the arrangement of at least two elements obtained by a single read of the storage device in the initial tensor. Exemplarily, the number of elements that the transmission device reads from the storage device in a single read is determined based on the bus width. Specifically, the number of elements that the transmission device reads from the storage device in a single read is positively correlated with the bus width. For example, the larger the bus width, the greater the number of elements that the transmission device reads from the storage device in a single read. The tensor dimension information is used to indicate the number of data dimensions of the initial tensor to be read.
[0143] Exemplarily, the arrangement of the at least two elements can be a one-dimensional tensor or a multi-dimensional tensor; it is understood that the number of dimensions indicated by the element arrangement position is less than or equal to the number of data dimensions in the tensor dimension information. Exemplarily, the initial tensor is constructed by at least one read operation on the storage device.
[0144] In an optional implementation, the transmission device in step 526 of this embodiment can be implemented as follows:
[0145] A factor of the number of elements in at least one dimension carried by the tensor dimension information is determined as a dimension arrangement position.
[0146] The element arrangement position is constructed based on the dimension arrangement position.
[0147] Exemplarily, the tensor dimension information carries the number of data dimensions of the initial tensor and the number of elements in at least one dimension. Taking Figure 6 as an example, the tensor dimension information carries the number of data dimensions of the initial tensor, that is, the initial tensor is a three-dimensional tensor; the tensor dimension information also carries the number of elements in at least one dimension, for example, the number of elements of the initial tensor in the first dimension to the third dimension are 4, 3, and 3 respectively.
[0148] Exemplarily, determining the dimension arrangement position as a factor of the number of elements enables obtaining an initial tensor through an integer number of read processes, with the same number of elements in each tensor read and the same relative positions of multiple elements read each time, thereby simplifying the complexity of combining and obtaining the initial tensor after reading. Exemplarily, the dimension arrangement position is used to indicate the number of elements in at least one dimension of at least two elements obtained from a single read of the storage device.
[0149] To sum up, the method provided in this embodiment performs data transmission between the storage device and the processing device through the transmission device, avoiding occupying the bus process of the processing device to directly execute data acquisition; determines the element arrangement position according to the tensor dimension information, and determines the element arrangement method of a single read for tensors of different dimensions, thereby reducing the complexity of splicing to obtain the initial tensor and reducing the computing power requirements of the transmission device.
[0150] Those skilled in the art will appreciate that the above embodiments may be implemented independently, or the above embodiments may be freely combined to form new embodiments to implement the data processing method of the present application.
[0151] FIG12 shows a block diagram of a transmission device provided by an exemplary embodiment of the present application. A bus connection is established between the transmission device and the storage device, and the transmission device includes:
[0152] An acquisition module 810 is configured to acquire a tensor acquisition request, wherein the tensor acquisition request is used to instruct the transmission device to provide a target tensor to the processing device;
[0153] The acquisition module 810 is further configured to acquire a command descriptor according to the address information carried in the tensor acquisition request, wherein the command descriptor is configured to indicate a method for acquiring the target tensor in the storage device;
[0154] a processing module 820 configured to read an initial tensor from the storage device based on the command descriptor, and edit the initial tensor based on the command descriptor to obtain the target tensor, wherein the initial tensor includes the target tensor;
[0155] The sending module 830 is configured to send the target tensor to the processing device.
[0156] In an optional implementation of this embodiment, the command descriptor includes an operation sub-command; the processing module 820 is further configured to:
[0157] According to the operation type and operation position carried by the operation sub-command, the initial tensor is edited to obtain the target tensor, the operation type is used to indicate the manner in which the editing is performed on the initial tensor, and the operation position is used to indicate the location in the initial tensor where the editing is performed.
[0158] In an optional implementation of this embodiment, the processing module 820 is further configured to:
[0159] Based on the operation type and the operation position carried by the operation sub-command, a first execution engine deployed in the transmission device is called to edit the initial tensor to obtain the target tensor, and the first execution engine includes a processing unit in the transmission device.
[0160] In an optional implementation of this embodiment, the processing module 820 is further configured to:
[0161] In response to the operation type being a slicing operation, slicing is performed on the initial tensor according to the operation position to obtain the target tensor, where the target tensor is a sub-tensor in the initial tensor.
[0162] In an optional implementation of this embodiment, the operation subcommand further carries an operation number, and the operation number is used to indicate the number of times the slice processing is performed;
[0163] The processing module 820 is further used to: in response to the operation type being a slicing operation, perform n slicing on the initial tensor, determine the n sub-tensors corresponding one-to-one to the n slices as the target tensor, the operation position indicates the position where the first slicing is performed on the initial tensor, and the number of processing times is used to indicate the number of times continuous slicing is performed in at least one dimension.
[0164] In an optional implementation of this embodiment, the operation subcommand further carries transformation information, where the transformation information is used to indicate a method for swapping the dimensions of the tensor.
[0165] The processing module 820 is further configured to: in response to the operation type being a slicing operation and a layout transformation operation, slice the initial tensor according to the operation position to obtain the sub-tensor;
[0166] At least two dimensions of the sub-tensor are swapped according to the transformation information to obtain the target tensor.
[0167] In an optional implementation of this embodiment, the processing module 820 is further configured to:
[0168] In response to the operation type being an inverse slicing operation, the first tensor in the initial tensor is filled into the operation position in the second tensor to obtain the target tensor, where the target tensor is a combination tensor of at least two tensors in the initial tensor, and the at least two tensors include the first tensor and the second tensor.
[0169] In an optional implementation of this embodiment, the operation subcommand further carries transformation information, where the transformation information is used to indicate a method for swapping the dimensions of the tensor.
[0170] The processing module 820 is also used to: in response to the operation type being an inverse slicing operation and a layout transformation operation, perform a swap on at least two dimensions of the first tensor according to the transformation information to obtain a transformed tensor; and fill the transformed tensor into the operation position in the second tensor to obtain the target tensor.
[0171] In an optional implementation of this embodiment, the command descriptor includes a read subcommand; the processing module 820 is further configured to:
[0172] According to the data position and data size carried by the read subcommand, the initial tensor is read from the storage device, the data position is used to indicate the storage position of the initial tensor in the storage device, and the data size is used to indicate the data size of the initial tensor.
[0173] In an optional implementation of this embodiment, the processing module 820 is further configured to:
[0174] Based on the data position and the data size carried by the read subcommand, a second execution engine deployed in the transmission device is called to perform data reading on the storage device to obtain the initial tensor, and the second execution engine includes a read interface connecting the transmission device to the storage device.
[0175] In an optional implementation of this embodiment, the processing module 820 is further configured to:
[0176] The command descriptor is decoded to obtain a command decoding code, wherein the initial tensor and the target tensor are obtained based on the command decoding code, and the command decoding code is used to indicate a method for extracting the initial tensor and a method for editing the initial tensor.
[0177] In an optional implementation of this embodiment, the command descriptor includes a write sub-command; the sending module 830 is further used to: write the target tensor to the memory space of the processing device according to the write position indicated by the write sub-command.
[0178] In an optional implementation of this embodiment, the command descriptor includes tensor dimension information, and the tensor dimension information is used to indicate the number of data dimensions of the initial tensor that needs to be read; the processing module 820 is also used to: determine the element arrangement position according to the tensor dimension information, and the element arrangement position is used to indicate the arrangement of at least two elements obtained by a single reading of the storage device in the initial tensor, and the initial tensor is constructed by at least one reading process of the storage device, and the number of dimensions indicated by the element arrangement position is less than or equal to the number of data dimensions in the tensor dimension information.
[0179] In an optional implementation of this embodiment, the tensor dimension information carries the number of elements of the initial tensor in at least one dimension;
[0180] The processing module 820 is further configured to: determine a factor of the number of elements on the at least one dimension carried by the tensor dimension information as a dimension arrangement position;
[0181] The element arrangement position is constructed based on the dimensional arrangement position, and the dimensional arrangement position is used to indicate the number of elements in the at least one dimension of the at least two elements obtained by reading the storage device in a single time.
[0182] It should be noted that the device provided in the above embodiment only uses the division of the above-mentioned functional modules as an example to implement its functions. In actual applications, the above-mentioned functions can be assigned to different functional modules according to actual needs, that is, the content structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0183] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method; the technical effects achieved by each module performing operations are the same as the technical effects in the embodiment of the method, and will not be elaborated here.
[0184] The present application also provides a computer device. FIG13 is a block diagram of the structure of a computer device provided by an exemplary embodiment of the present application. The computer device includes: a processing device 110, a transmission device 120, and a storage device 130. The processing device 110 and the transmission device 120 are connected, and a bus connection is established between the transmission device 120 and the storage device 130.
[0185] The transmission device 120 is configured to obtain the tensor acquisition request sent by the processing device 110;
[0186] Exemplarily, the tensor acquisition request is used to instruct the transmission device 120 to provide the target tensor to the processing device 110; for a detailed introduction to the tensor acquisition request, please refer to step 510 above.
[0187] The transmission device 120 is further configured to obtain a command descriptor from the storage device 130 according to the address information carried in the tensor acquisition request;
[0188] Exemplarily, the command descriptor is used to indicate how to obtain the target tensor in the storage device 130; for a detailed description of the command descriptor, please refer to step 520 above. Exemplarily, a bus connection is established between the transmission device 120 and the storage device 130 via a bus interface unit. Exemplarily, a data bus connection is established between the transmission device 120 and the storage device 130.
[0189] The transmission device 120 is further configured to read the initial tensor from the storage device 130 based on the command descriptor, and perform editing on the initial tensor based on the command descriptor to obtain a target tensor;
[0190] Exemplarily, the initial tensor includes a target tensor; for a detailed introduction to the initial tensor and the target tensor, please refer to step 530 above.
[0191] The transmission device 120 is further configured to send the target tensor to the processing device 110 ;
[0192] For example, please refer to step 540 above for an introduction to sending the target tensor.
[0193] In an optional implementation, the processing device 110 includes a control unit 110 c , a cache unit 110 a , and a tensor calculation unit 110 b ;
[0194] The control unit 110c is configured to send a tensor acquisition request to the transmission device 120;
[0195] a cache unit 110 a , configured to store target tensors sent by the processing device 110 ;
[0196] The tensor computing unit 110b is configured to perform data processing on the target tensor.
[0197] Exemplarily, the data processing performed on the target tensor includes but is not limited to matrix calculations and vector calculations; exemplary, the first subunit in the tensor calculation unit 110b is deployed with a matrix calculation engine for performing matrix calculations on the target tensor; the second subunit in the tensor calculation unit 110b is deployed with a vector calculation engine for performing vector calculations on the target tensor.
[0198] Regarding the processing device 110 and the transmission device 120, in an optional implementation, the processing device 110 and the transmission device 120 are different processing cores on a processor; illustratively, the processor can be at least one of a central processing unit (CPU), a graphics processing unit (GPU), an artificial intelligence (AI) processor, or other devices with data processing capabilities.
[0199] In another optional implementation, the processing device 110 is a main processor, the transmission device 120 is a coprocessor, and a control transmission connection is established between the main processor and the coprocessor. Exemplarily, the main processor and the coprocessor transmit command words via a control bus to implement control transmission between the main processor and the coprocessor.
[0200] Regarding the cache unit in the memory device 130 and the processing device 110 , in an optional implementation, the cache unit is a first-level cache memory (L1 / L1MEM);
[0201] The memory device 130 is a second-level cache memory (L2 / L2MEM) or a third-level cache memory (L3 / L3MEM).
[0202] In one example, the memory device 130 is a random access memory (RAM).
[0203] Regarding the computer device in the above embodiment, the specific manner in which each part performs operations has been described in detail in the embodiment of the method; the technical effects achieved are the same as those in the embodiment of the method, and will not be elaborated here.
[0204] In an exemplary embodiment, a chip is also provided, which includes at least one of a programmable logic circuit and a program instruction (also referred to as a programmable logic circuit and / or program instruction). When the chip runs on a computer device, it is used to implement the data processing method described in the above aspects.
[0205] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, which may be a read-only memory, a disk, or an optical disk, etc.
[0206] The above description is merely an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A data processing method, the method being executed by a transmission device, wherein a bus connection is established between the transmission device and a storage device, the method comprising: Obtain a tensor acquisition request, where the tensor acquisition request is used to instruct the transmission device to provide a target tensor to the processing device; Acquire a command descriptor according to the address information carried by the tensor acquisition request, wherein the command descriptor is used to indicate a method for acquiring the target tensor in the storage device; Based on the command descriptor, an initial tensor is read from the storage device, and based on the command descriptor, the initial tensor is edited to obtain the target tensor, wherein the initial tensor includes the target tensor; The target tensor is sent to the processing device.
2. The method according to claim 1, wherein: The command descriptor includes an operation subcommand; The performing editing on the initial tensor based on the command descriptor to obtain the target tensor includes: According to the operation type and operation position carried by the operation subcommand, the initial tensor is edited to obtain the target tensor, the operation type is used to indicate the way to perform the edit on the initial tensor, and the operation position is used to indicate the position where the edit is performed in the initial tensor.
3. The method according to claim 2, wherein: The editing of the initial tensor according to the operation type and the operation position carried by the operation subcommand to obtain the target tensor includes: Based on the operation type and the operation position carried by the operation subcommand, a first execution engine deployed in the transmission device is called to edit the initial tensor to obtain the target tensor, and the first execution engine includes a processing unit in the transmission device.
4. The method according to claim 2, wherein: The editing of the initial tensor according to the operation type and the operation position carried by the operation subcommand to obtain the target tensor includes: In response to the operation type being a slicing operation, slicing is performed on the initial tensor according to the operation position to obtain the target tensor, where the target tensor is a sub-tensor in the initial tensor.
5. The method according to claim 4, wherein: The operation subcommand also carries an operation number, which is used to indicate the number of times the slice is processed; In response to the operation type being a slicing operation, slicing the initial tensor according to the operation position to obtain the target tensor includes: In response to the operation type being a slicing operation, n slicing is performed on the initial tensor, and n sub-tensors corresponding to the n slices are determined as the target tensor. The operation position indicates the position where the first slicing is performed on the initial tensor, and the processing number is used to indicate the number of times continuous slicing is performed in at least one dimension.
6. The method according to claim 4, wherein: The operation subcommand also carries transformation information, and the transformation information is used to indicate the way to swap the dimension of the tensor; In response to the operation type being a slicing operation, slicing the initial tensor according to the operation position to obtain the target tensor includes: In response to the operation type being a slicing operation and a layout transformation operation, slicing the initial tensor according to the operation position to obtain the sub-tensor; At least two dimensions of the sub-tensor are swapped according to the transformation information to obtain the target tensor.
7. The method according to claim 2, wherein: The editing of the initial tensor according to the operation type and the operation position carried by the operation subcommand to obtain the target tensor includes: In response to the operation type being an anti-slicing operation, the first tensor in the initial tensor is filled into the operation position in the second tensor to obtain the target tensor, wherein the target tensor is a combined tensor of at least two tensors in the initial tensor, and the at least two tensors include the first tensor and the second tensor.
8. The method according to claim 7, wherein: The operation subcommand also carries transformation information, and the transformation information is used to indicate the way to swap the dimension of the tensor; In response to the operation type being a deslicing operation, filling the first tensor in the initial tensor into the operation position in the second tensor to obtain the target tensor includes: In response to the operation type being a deslicing operation and a layout transformation operation, performing a swap on at least two dimensions of the first tensor according to the transformation information to obtain a transformed tensor; Fill the transformed tensor into the operation position in the second tensor to obtain the target tensor.
9. The method according to any one of claims 1 to 8, wherein: The command descriptor includes a read subcommand; The step of reading an initial tensor from the storage device based on the command descriptor comprises: According to the data position and data size carried by the read subcommand, the initial tensor is read in the storage device, the data position is used to indicate the storage position of the initial tensor in the storage device, and the data size is used to indicate the data size of the initial tensor.
10. The method according to claim 9, wherein: The step of reading the initial tensor from the storage device according to the data position and the data size carried by the read subcommand includes: Based on the data position and the data size carried by the read subcommand, a second execution engine deployed in the transmission device is called to perform data reading on the storage device to obtain the initial tensor, and the second execution engine includes a read interface of the transmission device connected to the storage device.
11. The method according to any one of claims 1 to 10, wherein: The method further comprises: The command descriptor is decoded to obtain a command decoding code, wherein the initial tensor and the target tensor are obtained based on the command decoding code, and the command decoding code is used to indicate a method for extracting the initial tensor and a method for editing the initial tensor.
12. The method according to any one of claims 1 to 10, wherein: The command descriptor includes a write subcommand; The sending the target tensor to the processing device includes: The target tensor is written into the memory space of the processing device according to the write position indicated by the write subcommand.
13. The method according to any one of claims 1 to 10, wherein: The command descriptor includes tensor dimension information, where the tensor dimension information is used to indicate the number of data dimensions of the initial tensor that needs to be read; The method further comprises: An element arrangement position is determined according to the tensor dimension information, the element arrangement position is used to indicate an arrangement manner in the initial tensor of at least two elements obtained by a single read of the storage device, the initial tensor is constructed by at least one read process of the storage device, and the number of dimensions indicated by the element arrangement position is less than or equal to the number of data dimensions in the tensor dimension information.
14. The method according to claim 13, wherein: The tensor dimension information carries the number of elements of the initial tensor in at least one dimension; The determining the element arrangement position according to the tensor dimension information includes: Determine a factor of the number of elements on the at least one dimension carried by the tensor dimension information as a dimension arrangement position; The element arrangement position is constructed based on the dimensional arrangement position, and the dimensional arrangement position is used to indicate the number of elements of the at least two elements obtained by reading the storage device once in the at least one dimension.
15. A computer device, comprising: A processing device, a transmission device and a storage device, wherein the processing device and the transmission device are connected to each other, and a bus connection is established between the transmission device and the storage device; The transmission device is used to obtain a tensor acquisition request sent by the processing device, where the tensor acquisition request is used to instruct the transmission device to provide a target tensor to the processing device; The transmission device is further used to obtain a command descriptor from the storage device according to the address information carried by the tensor acquisition request, wherein the command descriptor is used to indicate a method for obtaining the target tensor in the storage device; The transmission device is further configured to read an initial tensor from the storage device based on the command descriptor, and Performing editing on the initial tensor based on the command descriptor to obtain the target tensor, wherein the initial tensor includes the target tensor; The transmission device is further used to send the target tensor to the processing device.
16. The device according to claim 15, wherein: The processing device includes a control unit, a cache unit and a calculation unit; The control unit is used to send the tensor acquisition request to the transmission device; The cache unit is used to store the target tensor sent by the processing device; The computing unit is used to perform data processing on the target tensor.
17. The apparatus according to claim 15, wherein: The processing device and the transmission device are different processing cores on a processor; Alternatively, the processing device is a main processor, the transmission device is a coprocessor, and a control transmission connection is established between the main processor and the coprocessor.
18. The apparatus according to claim 16, wherein: The cache unit is a level 1 cache L1; The storage device is a second-level cache L2 or a third-level cache L3.
19. A chip, wherein: The chip includes at least one of a programmable logic circuit and a program instruction, and when the chip is running, it is used to implement the data processing method described in any one of claims 1 to 14 above.
Citation Information
Patent Citations
Tensor operation method and device
CN110941789A
Processing unit, related device and method
CN113688982A
Data processing method and system and related equipment
CN114968612A
Data processing method, computer equipment and chip
CN116821019A
Method and apparatus for calculating tensor data based on computer, medium, and device
US20220374347A1