Data handling method and device and processor
By judging the superboundary area of the data to be transferred and generating an overall handling request, the problem of unreasonable splitting of data handling in the prior art is solved, and the hardware utilization rate and memory bandwidth efficiency of the computing unit are improved.
Patent Information
- Application Number
- CN202510743416.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2045-06-05
AI Technical Summary
The data handling method in the prior art is unreasonable, resulting in low hardware utilization of computing units, especially when data handling in high bandwidth memory, which affects the computing efficiency.
By obtaining the shape size and starting coordinates of the data to be transferred, we can judge whether it exceeds the original data boundary, generate a target superboundary transport request, and use the superboundary area as a whole for data transfer, simplify complex operations and reduce multiple requests.
It improves memory bandwidth utilization and computing unit hardware utilization, reduces the overhead of multiple requests, and improves data handling efficiency.
Smart Images

Figure CN120255825A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of artificial intelligence chips, and particularly to a data transfer method, apparatus, and processor. Background Art
[0002] In the field of general computing, especially in applications involving large-scale data processing (such as artificial intelligence inference, image processing, etc.), the computing unit needs to frequently load or store data from High Bandwidth Memory (HBM), and these data are usually organized in a multi-dimensional form. Different data transfer methods in the related art can affect the hardware utilization rate of the computing unit. Therefore, there is an urgent need to propose a new data transfer method. Summary of the Invention
[0003] This application provides a data transfer method, apparatus, and processor, which solves the technical problem of unreasonable splitting of transfer instructions during data transfer in the related art, and achieves the technical effect of improving the hardware utilization rate of the computing unit.
[0004] To achieve the above object, the main technical solutions adopted in this application include: In a first aspect, an embodiment of this application provides a data transfer method, and the method includes: Obtain the shape and size of the data to be transferred, the starting coordinates of the data to be transferred in a preset coordinate system, and the actual size corresponding to the original data in the data memory; wherein, the preset coordinate system is a coordinate system constructed based on the original data; If it is determined based on the shape and size, the starting coordinates, and the actual size that the data to be transferred exceeds the boundary of the original data in the first dimension, determine the target out-of-bounds area of the data to be transferred in the first dimension; wherein, the first dimension is the adjacent higher dimension of the second dimension with discontinuous addresses, and the target out-of-bounds area is the continuous area where the data to be transferred completely exceeds the boundary of the original data in the first dimension; Generate a corresponding target out-of-bounds transfer request according to the target out-of-bounds area, so as to transfer at least part of the target out-of-bounds area as a whole through the target out-of-bounds transfer request.
[0005] Optionally, the shape and size and the starting coordinates are attached to the transfer instruction for transferring the data to be transferred; the generating a corresponding target out-of-bounds transfer request according to the target out-of-bounds area includes: Combine the target out-of-bounds area and split the transfer instruction in the first dimension to obtain a target out-of-bounds transfer request for the target out-of-bounds area.
[0006] Optionally, in combination with the target out-of-bounds region, the handling instruction is split in the first dimension to obtain a target out-of-bounds handling request for the target out-of-bounds region, including: Determine the preset out-of-bounds form corresponding to the target out-of-bounds region; Using an instruction splitting method corresponding to the preset out-of-bounds form, split the handling instruction in the first dimension to obtain the target out-of-bounds handling request.
[0007] Optionally, the number of target out-of-bounds regions is one, and the target out-of-bounds region corresponds to a first out-of-bounds form; the using an instruction splitting method corresponding to the preset out-of-bounds form, splitting the handling instruction in the first dimension to obtain the target out-of-bounds handling request, including: Using a first instruction splitting method corresponding to the first out-of-bounds form, split the handling instruction in the first dimension to obtain a single target out-of-bounds handling request for the target out-of-bounds region; wherein, through this single target out-of-bounds handling request, the target out-of-bounds region is used as a whole for data handling.
[0008] Optionally, the data to be handled adopts a non-continuous handling method, and the size of the data to be handled in the second dimension is denoted as a second size; The size of the target out-of-bounds region in the first dimension is equal to the absolute value of the starting coordinate in the first dimension; The size of the target out-of-bounds region in the second dimension is equal to the second size.
[0009] Optionally, the data to be handled adopts a continuous handling method, and the size of the data to be handled in the second dimension is denoted as a second size; The number of pixels corresponding to the target out-of-bounds region is equal to the sum between a first product and a first difference; wherein, the first product is equal to the product of the second size and a second difference, the second difference is equal to the difference between the absolute value of the starting coordinate in the first dimension and 1, and the first difference is equal to the second size minus the value of the starting coordinate in the second dimension.
[0010] Optionally, the number of target out-of-bounds regions is multiple, and the multiple target out-of-bounds regions correspond to a second out-of-bounds form; the using an instruction splitting method corresponding to the preset out-of-bounds form, splitting the handling instruction in the first dimension to obtain the target out-of-bounds handling request, including: Adopt a second instruction splitting method corresponding to the second out-of-bounds form, and split the handling instruction in the first dimension to obtain a target out-of-bounds handling request corresponding to each of the multiple target out-of-bounds regions; wherein, each target out-of-bounds handling request corresponding to each target out-of-bounds region is used to perform data handling on the corresponding each target out-of-bounds region as a whole.
[0011] Optionally, the data to be handled adopts a discontinuous handling method, the multiple target out-of-bounds regions include a first out-of-bounds region and a second out-of-bounds region, the size of the data to be handled in the first dimension is denoted as a first size, and the size of the data to be handled in the second dimension is denoted as a second size; the size of the original data in the first dimension is denoted as a third size; The size of the first out-of-bounds region in the first dimension is equal to the absolute value of the starting coordinate in the first dimension, and the size of the first out-of-bounds region in the second dimension is equal to the second size; The size of the second out-of-bounds region in the first dimension is equal to a third difference obtained by adding the first size and the value of the starting coordinate in the first dimension and then subtracting the third size, and the size of the second out-of-bounds region in the second dimension is equal to the second size.
[0012] Optionally, the data to be handled adopts a continuous handling method, the multiple target out-of-bounds regions include a first out-of-bounds region and a second out-of-bounds region, the size of the data to be handled in the first dimension is denoted as a first size, and the size of the data to be handled in the second dimension is denoted as a second size; the size of the original data in the first dimension is denoted as a third size; The number of pixels corresponding to the first out-of-bounds region is equal to the sum between a first product and a first difference; wherein, the first product is equal to the product of the second size and a second difference, the second difference is equal to the difference between the absolute value of the starting coordinate in the first dimension and 1, and the first difference is equal to the second size minus the value of the starting coordinate in the second dimension; The number of pixels corresponding to the second out-of-bounds region is equal to the number of remaining pixels to be handled when the data is handled to the third size.
[0013] Optionally, the method further includes: if it is determined based on the shape size, the starting coordinate, and the actual size that the data to be handled exceeds the boundary of the original data in each data dimension, generate an overall handling request to perform data handling on the data to be handled as a whole through the overall handling request.
[0014] In a second aspect, an embodiment of the present application provides a data handling device, and the device includes: A size acquisition module, configured to acquire the shape size of the data to be transported, the starting coordinates of the data to be transported in a preset coordinate system, and the actual size corresponding to the original data in the data memory; wherein, the preset coordinate system is a coordinate system constructed based on the original data; An out-of-bounds determination module, configured to determine a target out-of-bounds area of the data to be transported in a first dimension if it is determined, based on the shape size, the starting coordinates, and the actual size, that the data to be transported exceeds the boundary of the original data in the first dimension; wherein, the first dimension is an adjacent higher dimension of a second dimension with discontinuous addresses, and the target out-of-bounds area is a continuous area where the data to be transported completely exceeds the boundary of the original data in the first dimension; A data transportation module, configured to generate a corresponding target out-of-bounds transportation request according to the target out-of-bounds area, so as to transport at least a part of the target out-of-bounds area as a whole through the target out-of-bounds transportation request.
[0015] In a third aspect, an embodiment of the present application provides a processor, which includes a logic circuit and a power supply circuit. The power supply circuit is configured to supply power to the logic circuit, and the logic circuit is configured to execute the steps of any one of the above methods.
[0016] In a fourth aspect, an embodiment of the present application provides a chip, which includes the processor as described above.
[0017] In the embodiments of the present application, based on the shape size of the data to be transported, the starting coordinates of the data to be transported in the preset coordinate system, and the actual size corresponding to the original data in the data memory, it is determined that if the data to be transported exceeds the boundary of the original data in the first dimension, the target out-of-bounds area of the data to be transported in the first dimension is determined, and a corresponding target out-of-bounds transportation request is generated according to the target out-of-bounds area, so as to perform an overall transportation on the target out-of-bounds area through the target out-of-bounds transportation request, realizing the simplification of complex out-of-bounds transportation operations into efficient overall operations, being able to reduce the overhead of multiple requests, thereby improving the memory bandwidth utilization rate, and further improving the hardware utilization rate of the computing unit. Description of the Drawings
[0018] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the description of the specific embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0019] Figure 1 It is a schematic diagram of the splitting of a transportation instruction in the related art provided by the embodiments of the present application; Figure 2 Schematic flowchart of the data transfer method provided by an embodiment of the present application; Figure 3 Schematic diagram of the size relationship between the data to be transferred and the original data provided by an embodiment of the present application; Figure 4 Schematic diagram of the tensor to be processed in the continuous transfer mode provided by an embodiment of the present application; Figure 5 Schematic diagram of the tensor to be processed in the discontinuous transfer mode provided by an embodiment of the present application; Figure 6 Schematic flowchart of the data transfer method provided by an embodiment of the present application; Figure 7 Schematic diagram of the upper out-of-bounds (OOB) provided by an embodiment of the present application; Figure 8 Schematic diagram of the lower out-of-bounds (OOB) provided by an embodiment of the present application; Figure 9 Schematic diagram of the bidirectional out-of-bounds (OOB) provided by an embodiment of the present application; Figure 10 Schematic diagram of the size relationship between the image to be transferred and the original image provided by an embodiment of the present application; Figure 11 Schematic framework diagram of the data transfer device provided by an embodiment of the present application. Detailed implementation manners
[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present application.
[0021] With the rapid development of fields such as artificial intelligence and high-performance computing, the requirement for the data transfer efficiency of high-bandwidth memory (HBM, High Bandwidth Memory) is increasing day by day. Loading (load) or storing (store) data can also be collectively referred to as copy data. For general computing operations (such as matrix computing operations), a large amount of data is usually required. These data are usually stored in a memory, for example, they can be stored in HBM. When performing general computing operations, it is necessary to load data (load operation) from the memory to the cache, and when obtaining the calculation result, it is necessary to store data from the cache to the memory (store operation). The data transfer method between the cache and the memory will affect the memory access bandwidth, and thus affect the hardware utilization rate of the computing unit.
[0022] In the data transfer operation in the related art, the transfer instruction (or copy instruction) is split into multiple different copy requests. The splitting principle is that the data corresponding to each copy request is either all located in the HBM or all not located in the HBM. Exemplarily, please refer to Figure 1 , taking the example of loading a two-dimensional image in the HBM into a buffer. The image to be transferred 102 exceeds the boundary of the original image 104. Since it is not continuous in the w dimension, the copy instruction is split in the w dimension based on the size relationship between the image to be transferred 102 and the original image 104. For example, the copy instruction is split into copy requests req1, req2, …… reqn-1, reqn. In this way, multiple copy requests (req1, req2, …… reqn-1, reqn) for loading the image to be transferred 102 are obtained by splitting the copy instruction in the w dimension. By sequentially sending multiple copy requests, the data returned by each copy request is written into the buffer.
[0023] It should be noted that for a certain data dimension (denoted as X) to be continuous, three conditions need to be met: 1) It is continuous in the adjacent lower dimension of the data dimension X; 2) Whether the starting coordinate of the data to be transferred in the preset coordinate system determined by the original data is equal to 0; 3) The size of the data to be transferred in the data dimension X is equal to the size of the original data in the data dimension X.
[0024] There is an out-of-bounds area 106 in the h dimension of the image to be transferred 102. If the related art is used to split the copy instruction in the w dimension for this out-of-bounds area 106, multiple requests are required for this out-of-bounds area 106.
[0025] After analysis, it is found that since this out-of-bounds area 106 is continuous in the h dimension, if multiple requests are used to process this out-of-bounds area 106, there is an unreasonable splitting of copy requests. Therefore, for this out-of-bounds area 106, out-of-bounds (OOB, Out Of Bounding) preprocessing can be performed, and this out-of-bounds area 106 is used as a whole with one copy request. By using one copy request to process the out-of-bounds area 106, the number of requests can be saved, and the hardware utilization rate of the computing unit can be improved.
[0026] The above is an exemplary description with a two-dimensional image as an example. It can be understood that tensor data can be stored in the HBM. In the embodiments of the present application, the data to be transferred or the original data can be tensor data in any data storage format, and the data storage format of the tensor data can be NDHWC or Among them, the data dimension N represents the batch size, that is, the number of data samples grabbed in one training. The data dimension D represents the depth, the data dimension H represents the height of the input data, the data dimension W represents the width of the input data, and the data dimension C represents the number of channels.
[0027] According to an embodiment of the present application, an embodiment of a data transfer method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0028] In this embodiment, a method for data to be transferred is provided, which can be used in a hardware accelerator. The hardware accelerator can be an integrated circuit module capable of accelerating multi-dimensional data calculation and transfer design. For example, the hardware accelerator can be a computing device such as a graphics processing unit (GPU), a general-purpose graphics processing unit (GPGPU), or a tensor memory accelerator TMA in a computing device. Figure 2 is a flowchart of the data transfer method according to an embodiment of the present application. Please refer to Figure 2 , the method includes the following steps: S110. Obtain the shape and size of the data to be transferred, the starting coordinates of the data to be transferred in a preset coordinate system, and the actual size corresponding to the original data in the data memory.
[0029] Among them, the preset coordinate system is a coordinate system constructed based on the original data. The preset coordinate system includes coordinate axes corresponding to each data dimension of the original data. The starting coordinates can be the starting position of the data to be transferred in the preset coordinate system. The data memory can be a memory unit for storing the original data; for example, the data memory can be a high-bandwidth memory (HBM). The shape and size of the data to be transferred can be the size of the data to be transferred in each data dimension. The actual size corresponding to the original data in the data memory can be the size of the original data in each data dimension in the data memory.
[0030] In one example, if the original data is a two-dimensional image (actual size is W0×H0), the shape and size of the data to be transferred can be W1×H1, where W0 represents the width of the two-dimensional image, H0 represents the height of the two-dimensional image, W1 represents the width of the rectangular area to be copied, and H1 represents the height of the rectangular area to be copied.
[0031] In another example, the original data can be tensor data. There may be multiple batches of the original data, and each batch may have multiple tensor data in the depth dimension. Please refer to Figure 3 , Figure 3The solid small cube in it represents an element. The original data can be tensor data composed of multiple solid cubes. C, W, and H respectively represent the three coordinate axes. row is the coordinate value on the data dimension H, col is the coordinate value on the data dimension W, and c is the coordinate value on the data dimension C. The data dimension H represents the height of the input data, the data dimension W represents the width of the input data, and the data dimension C represents the number of channels. Figure 3 The element 202 located at the upper left corner of the tensor data in it is the origin of the coordinate system determined based on the original tensor. The coordinates of the element 202 in the tensor data are: c = 0, row = 0, and col = 0. Figure 3 The dashed box 204 in it is the data to be transported. It includes not only some elements (solid small cubes) in the original data, but also the dashed small cubes outside the edge of the original data. The dashed small cubes can be obtained through a filling operation, and their values can be equal to 0.
[0032] In this embodiment, for subsequent out-of-bounds preprocessing operations, it is necessary to perform out-of-bounds judgment on the data to be transported and the original data. Therefore, by obtaining the shape and size of the data to be transported, the starting coordinates of the data to be transported in the preset coordinate system, and the actual size corresponding to the original data in the data memory, basic parameters are provided.
[0033] S120: If it is determined based on the shape and size, starting coordinates, and actual size that the data to be transported exceeds the boundary of the original data in the first dimension, determine the target out-of-bounds area of the data to be transported in the first dimension.
[0034] Among them, the first dimension is the adjacent higher dimension of the second dimension where the addresses are discontinuous. It can be understood that the addresses are continuous in the adjacent lower dimension of the second dimension. The target out-of-bounds area is the continuous area where the data to be transported completely exceeds the boundary of the original data in the first dimension. For example, if the first dimension is the data dimension H, the data to be transported exceeds the boundary in the data dimension H, and the starting coordinate h_corrd_b of the data to be transported in the data dimension H is equal to -10, then the target out-of-bounds area is the continuous area with coordinate values from -10 to 0 in the data dimension H.
[0035] In one example, the data storage format of the original data can be NDHWC. If the second dimension is the data dimension W and the first dimension is the data dimension H; or if the second dimension is the data dimension H and the first dimension is the data dimension D, it can be understood that if other data storage formats are adopted, the first dimension and the second dimension can be analogized accordingly. For example, if the second dimension is the data dimension W and the first dimension is the data dimension H, the addresses are continuous on the data dimension C (can be continuously loaded), and the addresses are not continuous on the data dimension W (cannot be continuously loaded). At this time, the adjacent higher dimension (data dimension H) of the data dimension W can be turned to perform out-of-bounds preprocessing. For another example, if the second dimension is the data dimension H and the first dimension is the data dimension D, the addresses are continuous on the data dimension W (can be continuously loaded), and the addresses are not continuous on the data dimension H (cannot be continuously loaded). At this time, the adjacent higher dimension (data dimension D) of the data dimension H can be turned to perform out-of-bounds preprocessing.
[0036] In this embodiment, the shape size, the starting coordinate, and the actual size can be compared to determine whether the data to be transported is out of bounds in a certain data dimension. If it is out of bounds in a certain data dimension, the target out-of-bounds area of the data to be transported in this data dimension is determined.
[0037] Specifically, if the value of the starting coordinate in the second dimension is less than zero, it can be determined that it is not continuous in this second dimension, and further, based on the shape size of the data to be transported and the actual size of the original data, it is determined whether it is out of bounds in the adjacent higher dimension (the first dimension) of this second dimension. If it is determined that the data to be transported is out of the boundary of the original data in this first dimension, the target out-of-bounds area of the data to be transported in this first dimension can be determined based on the starting coordinate of the data to be transported in this first dimension. It can also be calculated based on the starting coordinate of the data to be transported in this first dimension, the size of the data to be transported in this first dimension, and the size of the original data in this first dimension to obtain the target out-of-bounds area of the data to be transported in this adjacent higher dimension. Exemplarily, please continue to refer to Figure 3 , the target out-of-bounds area of the data to be transported in the data dimension H is the upper area that exceeds the boundary of the original data in the data dimension H in the dashed box 204.
[0038] S130. Generate a corresponding target out-of-bounds transport request according to the target out-of-bounds area, so as to transport at least part of the target out-of-bounds area as a whole through the target out-of-bounds transport request.
[0039] Specifically, the amount of data to be moved corresponding to the target out-of-bounds transfer request is determined according to the coordinates and size of the target out-of-bounds area, so as to generate the target out-of-bounds transfer request. In one example, the target out-of-bounds area is regarded as a whole. For example, if the target out-of-bounds area spans 10 rows in the data dimension H, then a target out-of-bounds transfer request is generated to move these 10 rows of data. Another example is that if the number of pixels corresponding to the target out-of-bounds area is N, then a target out-of-bounds transfer request is generated to move these N pixels. In yet another example, the target out-of-bounds area is divided. For example, if the target out-of-bounds area spans 10 rows in the data dimension H, the target out-of-bounds area is divided into two sub-areas (the first sub-area and the second sub-area) in the data dimension H. A target out-of-bounds transfer request is generated for the first sub-area to move the row data corresponding to the first sub-area, and a target out-of-bounds transfer request is generated for the second sub-area to move the row data corresponding to the second sub-area.
[0040] In the above embodiments, based on the shape and size of the data to be moved, the starting coordinates of the data to be moved in the preset coordinate system, and the actual size corresponding to the original data in the data memory, it is determined that if the data to be moved exceeds the boundary of the original data in the first dimension, the target out-of-bounds area of the data to be moved in the first dimension is determined, and the corresponding target out-of-bounds transfer request is generated according to the target out-of-bounds area, so as to perform an overall transfer of the target out-of-bounds area through the target out-of-bounds transfer request, realizing the simplification of complex out-of-bounds transfer operations into efficient overall operations, reducing the overhead of multiple requests, thereby improving the memory bandwidth utilization rate, and further improving the hardware utilization rate of the computing unit.
[0041] In some embodiments, the shape size and starting coordinates are attached to the transfer instruction for moving the data to be moved. In step S130, generating the corresponding target out-of-bounds transfer request according to the target out-of-bounds area may include: combining the target out-of-bounds area and splitting the transfer instruction in the first dimension to obtain the target out-of-bounds transfer request for the target out-of-bounds area.
[0042] Among them, the transfer instruction can be a load instruction for loading the data to be transferred from the HBM into the cache, or a store instruction for storing the data to be transferred from the cache into the HBM. The transfer instruction is attached with the shape and size of the data to be transferred and the starting coordinates of the data to be transferred. Taking a two-dimensional image as an example, the shape and size of the data to be transferred can be expressed as (w_copy, h_copy); where w_copy is the size of the data to be transferred in the data dimension W, and h_copy is the size of the data to be transferred in the data dimension H. The shape and size of the data to be transferred can be expressed as (left_bound, right_bound, up_bound, down_bound); where left_bound and right_bound are the two boundaries of the data to be transferred in the data dimension W, and up_bound and down_bound are the two boundaries of the data to be transferred in the data dimension H.
[0043] In some cases, since it is necessary to generate corresponding target out-of-bounds transfer requests for different target out-of-bounds regions, after determining the target out-of-bounds region, the transfer instruction is split according to the characteristics of the target out-of-bounds region to obtain multiple requests, and multiple requests include target out-of-bounds transfer requests for the target out-of-bounds region. For example, the transfer instruction can be split according to the spatial position relationship between the target out-of-bounds region and the original data to obtain the target out-of-bounds transfer request corresponding to the target out-of-bounds region and the normal transfer request corresponding to the normal region. For another example, the transfer instruction is split according to the number of target out-of-bounds regions to obtain the target out-of-bounds transfer request corresponding to each target out-of-bounds region and the normal transfer request corresponding to the normal region. For yet another example, it is determined whether the data to be transferred adopts a consecutive transfer mode (ConsecutiveCopy) or a non-consecutive transfer mode (NonconsecutiveCopy), and the transfer instruction is split in combination with the judgment result and the out-of-bounds form corresponding to the target out-of-bounds region to obtain the target out-of-bounds transfer request corresponding to the target out-of-bounds region and the normal transfer request corresponding to the normal region.
[0044] It should be noted that the consecutive transfer mode refers to a mode of transferring multiple consecutive pixels in the original data according to the number of pixels included in the data to be transferred. Exemplarily, in the first type of computing scenario, the number of pixels is specified in the transfer instruction to transfer the corresponding multiple pixels in a consecutive manner. The first type of computing scenario can be at least one of natural language processing, signal processing, image processing, etc. that adopt convolutional operations. Among them, the original data and the data to be transferred can be tensor data. The original data is denoted as the original tensor, and the data to be transferred is denoted as the tensor to be processed. Such as Figure 4As shown, the starting point of the original tensor is represented as (C = 0, W = 0, H = 0), for example, to indicate the position of the original tensor in the storage space. For example, the starting point determined by the starting coordinates of the tensor to be processed in the coordinate system determined by the original tensor is represented as (C = 0, W = 3, H = 0), that is, the tensor to be processed is obtained starting from the 3rd pixel in the first row of the original tensor. For example, the number of pixels copy_pixel_num included in the tensor to be processed is determined in the transfer instruction; according to Figure 4 As shown by the dashed arrow in, starting from the starting point (C = 0, W = 3, H = 0), pixels are loaded from the storage space where the original tensor is located until the number of obtained pixels reaches the number of pixels copy_pixel_num included in the tensor to be processed.
[0045] The non - continuous transfer method refers to a method of transferring data blocks in the original data as a whole according to the sizes of the data to be transferred in each dimension. Exemplarily, in the second - type calculation scenario, the sizes in each dimension are specified in the transfer instruction to transfer the corresponding data blocks as a whole. The second - type calculation scenario can be at least one of computer graphics using matrix multiplication, encryption algorithms, linear system solving, etc. Among them, the original data and the data to be transferred can be tensor data. The original data is denoted as the original tensor, and the data to be transferred is denoted as the tensor to be processed. As Figure 5 shown, taking the tensor to be processed as a whole, it is transferred block - by - block from the original tensor. The transfer instruction can indicate the starting point (C = 0, W = 0, H = 0) of the original tensor that needs to be loaded, the starting point (C = 0, W = 3, H = 0) of the tensor to be processed in the coordinate system of the original tensor, and the sizes of the tensor to be processed in each dimension. Figure 5 The tensor to be processed shown is a cuboid determined by the above - mentioned starting point and the sizes in each dimension.
[0046] In the above - mentioned embodiments, the target out - of - bounds transfer request can be understood as a request specifically used to transfer the target out - of - bounds area obtained by splitting the transfer instruction. By splitting the transfer instruction, a target out - of - bounds transfer request for the target out - of - bounds area is obtained. This target out - of - bounds transfer request corresponds to the continuous data block corresponding to the out - of - bounds area in the first dimension. Taking it as a whole, so as to achieve the overall transfer of the target out - of - bounds area through a single request, reduce the number of fragmented access requests, and improve the memory bandwidth utilization rate and hardware computing efficiency.
[0047] In some embodiments, please refer to Figure 6 , in combination with the target out - of - bounds area, split the transfer instruction in the first dimension to obtain a target out - of - bounds transfer request for the target out - of - bounds area, including: S310. Determine the preset out - of - bounds form corresponding to the target out - of - bounds area.
[0048] Among them, the preset out-of-bounds form can be a predefined out-of-bounds region type, which is used to describe the specific situation where the data to be transported exceeds the original data boundary in a certain data dimension. Specifically, by analyzing the coordinate range of the target out-of-bounds region and the position relationship with the original data boundary, it is classified into a certain preset out-of-bounds form. For example, taking a two-dimensional image as an example, the preset out-of-bounds form can be Figure 7 the upper out-of-bounds shown in Figure 8 or the lower out-of-bounds shown in Figure 9 or the bidirectional out-of-bounds shown in . The bidirectional out-of-bounds can be understood as the data to be transported exceeding both the upper and lower boundaries of the original data at the same time. By providing the preset out-of-bounds form in advance, it provides a clear rule selection basis for subsequent splitting, so as to improve the splitting efficiency of the transfer instruction.
[0049] S320. Adopt an instruction splitting method corresponding to the preset out-of-bounds form to split the transfer instruction in the first dimension to obtain a target out-of-bounds transfer request.
[0050] Among them, the instruction splitting method can be a method of splitting the transfer instruction into multiple requests according to the type of the preset out-of-bounds form by using corresponding rules. Specifically, since it has been clearly defined in advance that different preset out-of-bounds forms correspond to different instruction splitting methods, after determining the preset out-of-bounds form, the instruction splitting method corresponding to the preset out-of-bounds form can be determined, and this instruction splitting method is used to split the transfer instruction in the first dimension to obtain multiple requests, including the target out-of-bounds transfer request. Exemplarily, taking a two-dimensional image as an example, if the preset out-of-bounds form is the upper out-of-bounds, the image to be transported can be divided into an upper out-of-bounds region and a normal region. Adopt the instruction splitting method corresponding to the upper out-of-bounds to split the transfer instruction in the data dimension H to obtain the target out-of-bounds transfer request corresponding to the upper out-of-bounds region and the normal transfer request corresponding to the normal region. If the preset out-of-bounds form is the lower out-of-bounds, the image to be transported can be divided into a normal region and a lower out-of-bounds region. Adopt the instruction splitting method corresponding to the lower out-of-bounds to split the transfer instruction in the data dimension H to obtain the normal transfer request corresponding to the normal region and the target out-of-bounds transfer request corresponding to the lower out-of-bounds region. It should be noted that in the embodiment of the present application, the normal region is not continuous in the data dimension W and needs to be split in the data dimension W to obtain the normal transfer request corresponding to the normal region. This splitting method is the same as the copy instruction splitting method in the related art.
[0051] In some embodiments, the number of target out-of-bounds regions is one, and the target out-of-bounds region corresponds to a first out-of-bounds form. By using an instruction splitting method corresponding to the preset out-of-bounds form to split the transfer instruction in the first dimension, a target out-of-bounds transfer request can be obtained, which may include: using a first instruction splitting method corresponding to the first out-of-bounds form to split the transfer instruction in the first dimension to obtain a target out-of-bounds transfer request for the target out-of-bounds region; wherein, through this target out-of-bounds transfer request, the target out-of-bounds region is used as a whole for data transfer.
[0052] Specifically, a corresponding relationship is pre-established between the first out-of-bounds form and the first instruction splitting method. After determining the first out-of-bounds form, the transfer instruction can be split in the first dimension by using the first instruction splitting method to obtain multiple requests, and these requests include the target out-of-bounds transfer request.
[0053] In this embodiment, the number of target out-of-bounds regions is one. By combining the target out-of-bounds region to split the transfer instruction, a target out-of-bounds transfer request for the target out-of-bounds region is obtained, so that the continuous data block corresponding to the target out-of-bounds region can be used as a whole for data transfer. The overall transfer of the target out-of-bounds region is realized through a single request, reducing the number of fragmented access requests and improving the memory bandwidth utilization rate and hardware computing efficiency.
[0054] In some embodiments, the data to be transferred adopts a non-continuous transfer method, and the size of the data to be transferred in the second dimension is denoted as the second size; the size of the target out-of-bounds region in the first dimension is equal to the absolute value of the starting coordinate in the first dimension; the size of the target out-of-bounds region in the second dimension is equal to the second size.
[0055] Exemplarily, please continue to refer to Figure 7 , the second dimension may be the data dimension W, and the first dimension may be the data dimension H. The starting coordinate of the data to be transferred is denoted as (w_coord_b, h_coord_b). The size of the data to be transferred in the data dimension H is denoted as h_copy, the size of the data to be transferred in the data dimension W is denoted as w_copy, the actual size of the original data in the data dimension H is denoted as h_tensor, and the actual size of the original data in the data dimension W is denoted as w_tensor. There is an out-of-bounds (OOB) in the data dimension H. The region between row = 0 and row = h_coord_b in the data dimension H exceeds the boundary of the original data. The region between row = 0 and row = h_coord_b can be regarded as a whole and a target out-of-bounds transfer request is sent. The size of the target out-of-bounds region in the first dimension is equal to |h_coord_b|; the size of the target out-of-bounds region in the second dimension is equal to w_copy.
[0056] In this example, the size of the target out-of-bounds transfer request is the product of the size of the target out-of-bounds area in the first dimension and the size of the target out-of-bounds area in the second dimension, i.e., |h_coord_b| × w_copy.
[0057] It should be noted that the transfer instruction is split in the first dimension using the first instruction splitting method to obtain multiple requests, and these requests include the normal transfer requests corresponding to the normal part. After processing the target out-of-bounds transfer request, the normal transfer requests are processed, and h_coord_b in the normal transfer requests is updated to 0.
[0058] In some embodiments, the data to be transferred adopts a continuous transfer method, and the size of the data to be transferred in the second dimension is denoted as the second size; the number of pixels corresponding to the target out-of-bounds area is equal to the sum of the first product and the first difference; wherein, the first product is equal to the product of the second size and the second difference, the second difference is equal to the absolute value of the starting coordinate in the first dimension minus 1, and the first difference is equal to the second size minus the value of the starting coordinate in the second dimension.
[0059] Among them, regardless of whether the data to be transferred adopts a continuous transfer method or a non - continuous transfer method, the size of the target out-of-bounds area in the first dimension is equal to |h_coord_b|; the size of the target out-of-bounds area in the second dimension is equal to w_copy.
[0060] Exemplarily, please continue to refer to Figure 7 , in the continuous transfer method, for the target out-of-bounds area, the number of pixels in the first row of the data dimension H is equal to the size w_copy of the target out-of-bounds area in the data dimension W minus the value w_coord_b of the starting coordinate in the second dimension, i.e., w_copy - w_coord_b. The total number of pixels in the other rows except the first row in the data dimension H is equal to the first product between (|h_coord_b| - 1) and w_copy.
[0061] In this example, the size of the target out-of-bounds transfer request is the number of pixels corresponding to the target out-of-bounds area, equal to (|h_coord_b| - 1) × w_copy + (w_copy - w_coord_b).
[0062] It should be noted that the transfer instruction is split in the first dimension using the first instruction splitting method to obtain multiple requests, and these requests include the normal transfer requests corresponding to the normal part. After processing the target out-of-bounds transfer request, the normal transfer requests are processed, and copy_pixel_num in the normal transfer requests is updated to the difference between copy_pixel_num in the transfer instruction and the number of pixels corresponding to the target out-of-bounds area.
[0063] In some embodiments, the number of target out-of-bounds regions is multiple, and the multiple target out-of-bounds regions correspond to a second out-of-bounds form. Using an instruction splitting method corresponding to a preset out-of-bounds form to split the transfer instruction in the first dimension, a target out-of-bounds transfer request can be obtained, which may include: using a second instruction splitting method corresponding to the second out-of-bounds form to split the transfer instruction in the first dimension to obtain a target out-of-bounds transfer request corresponding to each of the multiple target out-of-bounds regions; wherein, each target out-of-bounds region corresponding to a target out-of-bounds transfer request is used to transfer data for each corresponding target out-of-bounds region as a whole.
[0064] Specifically, a correspondence relationship between the second out-of-bounds form and the second instruction splitting method is pre-established. After determining the second out-of-bounds form, the second instruction splitting method can be used to split the transfer instruction in the first dimension to obtain multiple requests, and these requests include a target out-of-bounds transfer request corresponding to each of the multiple target out-of-bounds regions.
[0065] In this embodiment, the number of target out-of-bounds regions is multiple. By combining multiple target out-of-bounds regions to split the transfer instruction, a target out-of-bounds transfer request for each target out-of-bounds region can be obtained, so that the continuous data block corresponding to each target out-of-bounds region can be transferred as a whole. The overall transfer of each target out-of-bounds region is achieved through a single request, reducing the number of fragmented access requests and improving the memory bandwidth utilization rate and hardware computing efficiency.
[0066] In some embodiments, the data to be transferred adopts a non-continuous transfer method. The multiple target out-of-bounds regions include a first out-of-bounds region and a second out-of-bounds region. The size of the data to be transferred in the first dimension is denoted as the first size, and the size of the data to be transferred in the second dimension is denoted as the second size; the size of the original data in the first dimension is denoted as the third size. The size of the first out-of-bounds region in the first dimension is equal to the absolute value of the starting coordinate in the first dimension, and the size of the first out-of-bounds region in the second dimension is equal to the second size. The size of the second out-of-bounds region in the first dimension is equal to the third difference obtained by subtracting the third size from the sum of the first size and the value of the starting coordinate in the first dimension, and the size of the second out-of-bounds region in the second dimension is equal to the second size.
[0067] Exemplarily, please continue to refer to Figure 9, the second dimension can be the data dimension W, and the first dimension can be the data dimension H. The starting coordinates of the data to be transferred are denoted as (w_coord_b, h_coord_b). The size of the data to be transferred in the data dimension H is denoted as h_copy, the size of the data to be transferred in the data dimension W is denoted as w_copy, the actual size of the original data in the data dimension H is denoted as h_tensor, and the actual size of the original data in the data dimension W is denoted as w_tensor. There are upper out-of-bounds OOB (the first out-of-bounds area) and lower out-of-bounds OOB (the second out-of-bounds area) in the data dimension H.
[0068] For the first out-of-bounds area, the first out-of-bounds area between row = 0 and row = h_coord_b in the data dimension H exceeds the boundary of the original data. The first out-of-bounds area can be regarded as a whole and a target out-of-bounds transfer request can be sent. The size of the first out-of-bounds area in the first dimension is equal to |h_coord_b|; the size of the first out-of-bounds area in the second dimension is equal to w_copy.
[0069] In this example, the size of the target out-of-bounds transfer request for the first out-of-bounds area is the product between the size of the first out-of-bounds area in the first dimension and the size of the first out-of-bounds area in the second dimension, that is, |h_coord_b| × w_copy.
[0070] It should be noted that the transfer instruction is split in the first dimension using the second instruction splitting method to obtain multiple requests, and these requests include the normal transfer requests corresponding to the normal part. After processing the target out-of-bounds transfer request for the first out-of-bounds area, the normal transfer requests are processed. In the normal transfer requests, h_coord_b is updated to 0, and the normal transfer requests are executed until h_tensor is reached. At this time, the second out-of-bounds area is processed.
[0071] For the second out-of-bounds area, after processing the normal transfer requests, the target out-of-bounds transfer request for the second out-of-bounds area is processed. The second out-of-bounds area between row = h_tensor and row = h_coord_b + h_copy in the data dimension H exceeds the boundary of the original data. The second out-of-bounds area can be regarded as a whole and a target out-of-bounds transfer request can be sent. The size of the second out-of-bounds area in the first dimension is equal to h_coord_b + h_copy - h_tensor; the size of the second out-of-bounds area in the second dimension is equal to w_copy.
[0072] In this example, the size of the target out-of-bounds transfer request for the second out-of-bounds area is the product between the size of the second out-of-bounds area in the first dimension and the size of the second out-of-bounds area in the second dimension, that is, (h_coord_b + h_copy - h_tensor) × w_copy.
[0073] In some embodiments, the data to be transferred is transferred in a continuous manner. The multiple target out-of-bounds regions include a first out-of-bounds region and a second out-of-bounds region. The size of the data to be transferred in the first dimension is denoted as the first size, and the size of the data to be transferred in the second dimension is denoted as the second size; the size of the original data in the first dimension is denoted as the third size. The number of pixels corresponding to the first out-of-bounds region is equal to the sum of a first product and a first difference; wherein, the first product is equal to the product of the second size and a second difference, the second difference is equal to the absolute value of the starting coordinate in the first dimension minus 1, and the first difference is equal to the second size minus the value of the starting coordinate in the second dimension; the number of pixels corresponding to the second out-of-bounds region is equal to the number of remaining pixels to be transferred when the data is transferred to the third size.
[0074] Wherein, regardless of whether the data to be transferred is transferred in a continuous manner or a non - continuous manner, the size of the first out-of-bounds region in the first dimension (data dimension H) is equal to |h_coord_b|; the size of the first out-of-bounds region in the second dimension (data dimension W) is equal to w_copy. The actual size of the original data in data dimension H is denoted as h_tensor, and the actual size of the original data in data dimension W is denoted as w_tensor. There are an upper out-of-bounds OOB (the first out-of-bounds region) and a lower out-of-bounds OOB (the second out-of-bounds region) in data dimension H.
[0075] Exemplarily, please continue to refer to Figure 9 , in the continuous transfer mode, for the first out-of-bounds region, the number of pixels in the first row of data dimension H is equal to the size w_copy of the first out-of-bounds region in data dimension W minus the value w_coord_b of the starting coordinate in the second dimension, that is, w_copy - w_coord_b. The total number of pixels in the rows other than the first row of data dimension H is equal to the first product between (|h_coord_b| - 1) and w_copy.
[0076] In this example, the size of the target out-of-bounds transfer request for the first out-of-bounds region is that the number of pixels corresponding to the first out-of-bounds region is equal to (|h_coord_b| - 1)×w_copy+(w_copy - w_coord_b).
[0077] It should be noted that the transfer instruction is split in the first dimension by using the second instruction splitting method to obtain multiple requests, and these requests include normal transfer requests corresponding to the normal part. After processing the target out-of-bounds transfer requests in the first out-of-bounds area, the normal transfer requests are processed. The copy_pixel_num in the normal transfer requests is updated to the difference between the copy_pixel_num in the transfer instruction and the number of pixels corresponding to the target out-of-bounds area. The normal transfer requests are executed until h_tensor is reached. At this time, the second out-of-bounds area is processed.
[0078] It should be noted that in the continuous transfer mode, the number of remaining pixels to be transferred, remain_copy_pixel_num, can be calculated.
[0079] For the second out-of-bounds area, since it is about to exceed h_tensor, the lower out-of-bounds OOB (second out-of-bounds area) is processed. Specifically, the number of pixels in the second out-of-bounds area is equal to the number of remaining pixels to be transferred when the data is transferred to h_tensor, that is, remain_copy_pixel_num.
[0080] In this example, the size of the target out-of-bounds transfer request for the second out-of-bounds area is equal to the number of pixels corresponding to the second out-of-bounds area, which is remain_copy_pixel_num.
[0081] It can be understood that if the number of target out-of-bounds areas is one and there is a lower out-of-bounds OOB in the data dimension H, the processing method of this lower out-of-bounds OOB is similar to the processing method of the second out-of-bounds area in the above embodiment, and will not be elaborated here.
[0082] In some embodiments, the data transfer method may further include: if it is determined based on the shape size, starting coordinates, and actual size that the data to be transferred exceeds the original data boundary in each data dimension, a single overall transfer request is generated to transfer the data to be transferred as a whole through the overall transfer request.
[0083] Among them, the overall transfer request may be a transfer request generated when the data to be transferred is out-of-bounds in all dimensions, and is used to transfer the entire data block to be transferred as a single whole. For example, if the data to be transferred exceeds the original data boundary in three dimensions of width, height, and depth, a single overall transfer request is generated to transfer the entire data to be transferred, rather than splitting into multiple requests.
[0084] Specifically, by comparing the starting coordinates, shape dimensions of the data to be transferred, and the actual dimensions of the original data dimension by dimension, it is determined whether the data to be transferred exceeds the boundary of the original data in all data dimensions. If all dimensions are out of bounds, a single overall transfer request is generated to cover the entire data to be transferred. Taking a two-dimensional image as an example, please refer to Figure 10 , the image 102 to be transferred exceeds the original image 104 in both the data dimension W and the data dimension H.
[0085] In the above embodiments, in the extreme scenario where all data dimensions are out of bounds, a single overall transfer request is generated for the data to be transferred, effectively simplifying the operation logic of this extreme scenario, reducing the complexity of data transfer operations, and improving the utilization rate of hardware resources.
[0086] Please refer to Figure 11 , this application embodiment also provides a data transfer device 500, which includes: A size acquisition module 510, configured to acquire the shape dimensions of the data to be transferred, the starting coordinates of the data to be transferred in a preset coordinate system, and the actual dimensions corresponding to the original data in the data memory; wherein, the preset coordinate system is a coordinate system constructed based on the original data; An out-of-bounds determination module 520, configured to determine the target out-of-bounds area of the data to be transferred in the first dimension if it is determined that the data to be transferred exceeds the boundary of the original data in the first dimension based on the shape dimensions, starting coordinates, and actual dimensions; wherein, the first dimension is the adjacent higher dimension of the second dimension with discontinuous addresses, and the target out-of-bounds area is the continuous area where the data to be transferred completely exceeds the boundary of the original data in the first dimension; A data transfer module 530, configured to generate a corresponding target out-of-bounds transfer request according to the target out-of-bounds area, so as to transfer at least part of the target out-of-bounds area as a whole through the target out-of-bounds transfer request.
[0087] This application embodiment also provides a processor, which includes a logic circuit and a power supply circuit. The power supply circuit is used to supply power to the logic circuit, and the logic circuit is used to execute the steps of the method in any of the above embodiments.
[0088] This application embodiment also provides a chip, which includes the processor in the above embodiment.
[0089] The further function descriptions of the above-mentioned various modules are the same as those in the corresponding embodiments above, and will not be elaborated here. The implementation device in this embodiment is presented in the form of functional units. Here, the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and a memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0090] The systems, devices, modules or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. For the convenience of description, the above devices are described by dividing them into various units according to their functions. Of course, when implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.
[0091] Those skilled in the art should understand that the embodiments of the present application can be provided as methods or devices. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects.
[0092] This application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems) according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of processes and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0093] It should also be noted that the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of another identical element in the process, method, commodity or device including the said element.
[0094] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other, and the key point of each embodiment is to illustrate the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for the relevant parts, reference can be made to the description of the method embodiment.
[0095] The above description is only for the embodiments of the present application and is not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
[0096] Although the embodiments of the present application are described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the present application, and such modifications and variations fall within the scope defined by the appended claims.
Claims
1. A data transfer method, characterized in that, The method includes: Obtaining the shape and size of the data to be transported, the starting coordinates of the data to be transported in a preset coordinate system, and the actual size corresponding to the original data in the data memory; wherein, the preset coordinate system is a coordinate system constructed based on the original data; If it is determined based on the shape and size, the starting coordinates, and the actual size that the data to be transported exceeds the boundary of the original data in the first dimension, determining the target out-of-bounds area of the data to be transported in the first dimension; wherein, the first dimension is the adjacent higher dimension of the second dimension with discontinuous addresses, and the target out-of-bounds area is the continuous area where the data to be transported completely exceeds the boundary of the original data in the first dimension; Generating a corresponding target out-of-bounds transport request according to the target out-of-bounds area, so as to transport at least part of the target out-of-bounds area as a whole through the target out-of-bounds transport request.
2. The method according to claim 1, wherein The shape and size and the starting coordinates are attached to the transport instruction for transporting the data to be transported; the generating a corresponding target out-of-bounds transport request according to the target out-of-bounds area includes: Combining the target out-of-bounds area and splitting the transport instruction in the first dimension to obtain a target out-of-bounds transport request for the target out-of-bounds area.
3. The method according to claim 2, wherein The combining the target out-of-bounds area and splitting the transport instruction in the first dimension to obtain a target out-of-bounds transport request for the target out-of-bounds area includes: Determining the preset out-of-bounds form corresponding to the target out-of-bounds area; Using an instruction splitting method corresponding to the preset out-of-bounds form to split the transport instruction in the first dimension to obtain the target out-of-bounds transport request.
4. The method according to claim 3, wherein The number of the target out-of-bounds areas is one, and the target out-of-bounds area corresponds to the first out-of-bounds form; the using an instruction splitting method corresponding to the preset out-of-bounds form to split the transport instruction in the first dimension to obtain the target out-of-bounds transport request includes: Using a first instruction splitting method corresponding to the first out-of-bounds form to split the transport instruction in the first dimension to obtain a target out-of-bounds transport request for the target out-of-bounds area; wherein, the target out-of-bounds area is transported as a whole through this target out-of-bounds transport request.
5. The method according to claim 4, wherein The data to be transported adopts a non-continuous transport mode, and the size of the data to be transported in the second dimension is denoted as the second size; The size of the target out-of-bounds area in the first dimension is equal to the absolute value of the starting coordinates in the first dimension; The size of the target out-of-bounds area in the second dimension is equal to the second size.
6. The method according to claim 4, wherein The data to be transported adopts a continuous transport mode, and the size of the data to be transported in the second dimension is denoted as the second size; The number of pixels corresponding to the target out-of-bounds region is equal to the sum between the first product and the first difference; wherein, the first product is equal to the product of the second dimension and the second difference, the second difference is equal to the difference between the absolute value of the starting coordinate in the first dimension and 1, and the first difference is equal to the second dimension minus the value of the starting coordinate in the second dimension.
7. The method according to claim 3, wherein The number of the target out-of-bounds regions is multiple, and the multiple target out-of-bounds regions correspond to a second out-of-bounds form; the step of splitting the handling instruction in the first dimension by using an instruction splitting method corresponding to the preset out-of-bounds form to obtain the target out-of-bounds handling request includes: Splitting the handling instruction in the first dimension by using a second instruction splitting method corresponding to the second out-of-bounds form to obtain a target out-of-bounds handling request for each of the multiple target out-of-bounds regions; wherein, each target out-of-bounds region corresponding to a target out-of-bounds handling request is used to perform data handling on the corresponding target out-of-bounds region as a whole.
8. The method according to claim 7, wherein The data to be handled adopts a non-continuous handling method, the multiple target out-of-bounds regions include a first out-of-bounds region and a second out-of-bounds region, the size of the data to be handled in the first dimension is denoted as a first dimension, and the size of the data to be handled in the second dimension is denoted as a second dimension; the size of the original data in the first dimension is denoted as a third dimension; The size of the first out-of-bounds region in the first dimension is equal to the absolute value of the starting coordinate in the first dimension, and the size of the first out-of-bounds region in the second dimension is equal to the second dimension; The size of the second out-of-bounds region in the first dimension is equal to a third difference obtained by subtracting the third dimension from the sum of the first dimension and the value of the starting coordinate in the first dimension, and the size of the second out-of-bounds region in the second dimension is equal to the second dimension.
9. The method according to claim 7, characterized in that, The data to be handled adopts a continuous handling method, the multiple target out-of-bounds regions include a first out-of-bounds region and a second out-of-bounds region, the size of the data to be handled in the first dimension is denoted as a first dimension, and the size of the data to be handled in the second dimension is denoted as a second dimension; the size of the original data in the first dimension is denoted as a third dimension; The number of pixels corresponding to the first out-of-bounds region is equal to the sum between the first product and the first difference; wherein, the first product is equal to the product of the second dimension and the second difference, the second difference is equal to the difference between the absolute value of the starting coordinate in the first dimension and 1, and the first difference is equal to the second dimension minus the value of the starting coordinate in the second dimension; The number of pixels corresponding to the second out-of-bounds region is equal to the number of remaining pixels to be handled when the data is handled to the third dimension.
10. The method according to any one of claims 1 to 9, characterized in that, The method further includes: If it is determined based on the shape dimension, the starting coordinate, and the actual dimension that the data to be handled exceeds the boundary of the original data in each data dimension, generating an overall handling request to perform data handling on the data to be handled as a whole through the overall handling request.
11. A data transfer device, characterized in that, The device includes: A size acquisition module, configured to acquire the shape size of the data to be transported, the starting coordinates of the data to be transported in a preset coordinate system, and the actual size corresponding to the original data in the data memory; wherein, the preset coordinate system is a coordinate system constructed based on the original data; An out-of-bounds determination module, configured to, if it is determined based on the shape size, the starting coordinates, and the actual size that the data to be transported exceeds the boundary of the original data in the first dimension, determine the target out-of-bounds area of the data to be transported in the first dimension; wherein, the first dimension is an adjacent higher dimension of a second dimension with discontinuous addresses, and the target out-of-bounds area is a continuous area where the data to be transported completely exceeds the boundary of the original data in the first dimension; A data transport module, configured to generate a corresponding target out-of-bounds transport request according to the target out-of-bounds area, so as to transport at least part of the target out-of-bounds area as a whole through the target out-of-bounds transport request.
12. A processor, characterized in that, The processor includes a logic circuit and a power supply circuit, the power supply circuit is configured to supply power to the logic circuit, and the logic circuit is configured to execute the steps of the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Multi-channel DMA method for tensor data handling
CN115495400A
Data processing method, computing device and related product
CN116185274A
Execution method and device for memory handling operator and storage medium
CN118193410A
Tensor memory carrying method and device, storage medium and program product
CN118567580A
Compilation optimization method and apparatus, computer device and storage medium
WO2023030507A1