Slice storage and indexing method, system and electronic device based on matrix data

Through the chip storage and indexing method based on matrix data, the problem of low computing resource utilization in the NVIDIA GPU architecture is solved, efficient data storage and access is achieved, and the computing performance of the Transformer model is improved.

CN120179607BActive Publication Date: 2025-08-26SHENZHEN ZHONGWEIDIAN TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510661250.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2025-08-26
Estimated Expiration
2045-05-22

AI Technical Summary

Technical Problem

During the computing process of the Transformer model, especially in the decoding stage, the existing NVIDIA GPU architecture has problems such as limited parallel computing capabilities, frequent memory access increases the bus burden, and on-chip storage capacity, resulting in low computing resource utilization and large space for data storage and call optimization.

Method used

The chip storage and indexing method based on matrix data is adopted. By setting the chip storage structure and indexing method, the data in the chip is continuously stored in rows or columns is preferred, the sub-matrix shape is set, and the data is accessed through rows or columns is indexed. Combined with physical address mapping tables and transpose tables, flexible storage and efficient access of data are achieved.

Benefits of technology

It improves the data reuse rate, reduces the memory access frequency, reduces the storage space requirement, reduces the number of memory accesses and the probability of data loss in calculations, reduces the waste of storage space, and improves computing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120179607B_ABST
    Figure CN120179607B_ABST
Patent Text Reader

Abstract

The present invention discloses a slice-based storage and indexing method, system, and electronic device based on matrix data. The method includes setting a slice-based storage structure: intra-slice data is stored continuously in a row- or column-priority manner, inter-slice data is stored continuously or discontinuously, slice indexes are numbered in a row-priority or column-priority manner, a submatrix is ​​configured with a starting slice ID, an ending slice ID, a starting row or column ID, an ending row or column ID, and the number of slices contained in each row or column; an indexing method is set: an access instruction describes the length and width dimensions of a slice, and data is accessed via an indexing method, wherein the indexing method includes a row indexing method and a column indexing method, wherein the row indexing method includes a slice ID, a row starting ID, and a row ending ID; the column indexing method includes a slice ID, a column starting ID, and a column ending ID; and the slice ID is calculated based on the starting slice ID of the mother matrix as the origin. The method of the present invention can improve data reuse and reduce memory access frequency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of data storage, and in particular relates to a slice storage and indexing method, system and electronic equipment based on matrix data. Background Art

[0002] Efficient computation of the Transformer model relies heavily on large-scale matrix multiplication operations, which imposes stringent requirements on real-time inference performance and leads to frequent memory accesses and significant bandwidth pressure. In existing NVIDIA GPU architectures, compute unit utilization remains low, making it difficult to fully utilize computing resources.

[0003] In the Ampere architecture, NVIDIA introduced the MMA instruction, which aims to improve matrix operation efficiency by loading batches of data into SRAM for calculation. However, this operation mode reduces the computational efficiency during the decoding phase due to insufficient reuse of large amounts of data, and may even increase bus bandwidth pressure.

[0004] Specifically, the Transformer's computation process is divided into two main phases: prefill and decode. In the prefill phase, multiple input data offers significant potential for parallel computation, and large amounts of data can be reused, effectively reducing bus pressure. In contrast, the decode phase processes only a single input at a time, significantly limiting parallel computation capabilities and significantly increasing bus burden due to frequent memory accesses. Furthermore, existing key / value cache mechanisms are limited by on-chip storage capacity, further exacerbating this problem.

[0005] To address these challenges, NVIDIA introduced a specialized Transformer engine into the Hopper architecture. Combined with fourth-generation Tensor Core technology, it supports FP8 precision and significantly improves the training and inference performance of large language models. While increasing on-chip storage capacity and bandwidth and increasing the number of parallel threads can significantly enhance high-density computing performance, there is still significant room for improvement in optimizing data storage and call processing. Summary of the Invention

[0006] In response to the above problems, the present invention provides a slice storage and indexing method, system and electronic device based on matrix data, which improves the data reuse rate and reduces the access frequency of memory.

[0007] According to a first aspect of an embodiment of the present disclosure, a slice-based storage and indexing method for matrix data is provided, the method comprising:

[0008] Set the slice storage structure: intra-slice data is stored continuously in row or column priority, inter-slice data is stored continuously or discontinuously, slice indexes are numbered in row or column priority, and the shape of the submatrix is ​​set to the starting slice ID, ending slice ID, starting row or column ID, ending row or column ID, and the number of slices in each row or column;

[0009] Set the indexing method: The access instruction describes the length and width dimensions of the slice, and accesses the data through the indexing method. The indexing method includes row indexing method and column indexing method. The row indexing method includes the slice ID, row start ID, and row end ID; the column indexing method includes the slice ID, column start ID, and column end ID. The calculation basis of the slice ID is positioned with the starting slice ID of the mother matrix as the origin.

[0010] In some embodiments, different mother matrix regions may be configured with different sheet shapes.

[0011] In some embodiments, the number of tiles contained in each row or column refers to the number of tiles that can be accommodated in a single row or column of the sub-matrix. When the size of the mother matrix is ​​insufficient, the excess area is automatically padded with zeros.

[0012] In some embodiments, each sub-matrix and / or mother matrix stores a physical address mapping table corresponding to a slice ID. When matrix splicing is performed, the physical storage location of the original data is not changed. Based on the physical address mapping table of the mother matrix, the target physical address corresponding to the slice ID and row ID is located. If the target slice ID already exists in the slice index table, the corresponding physical address is directly accessed; if not, a continuous blank physical address is dynamically requested and registered as a new slice ID, and the data is written into the corresponding storage space to achieve logical matrix splicing.

[0013] In some embodiments, the physical address mapping table also marks whether the matrix data is transposed. If transposed, the ID number of the transposition table is used, and the extracted slice attributes are also marked with the transposed attributes. When the transposition marking is performed, the stored data position is not changed. When used, the table of the mother matrix is ​​marked, and the mapping relationship of the table is changed. The transposed slice ID number is replaced by the dimensional information of the mother matrix.

[0014] In some embodiments, when matrix data is moved to a higher-level storage structure, a dedicated thread is used to transpose and rearrange the data moved to the shared memory.

[0015] In some embodiments, an index table and a storage mapping table are created based on the matrix data that needs to be stored after calculation, the matrix data is stored in the main memory according to the index table, the matrix data is registered according to the storage mapping table and the main memory data is transmitted through the PCIe interface.

[0016] According to a second aspect of an embodiment of the present disclosure, a slice-based storage and indexing system based on matrix data is provided, the system comprising:

[0017] Set up a slice storage structure module, which is used to set the slice data to be stored continuously in a row-first or column-first manner, the slice index numbering method to be row-first or column-first, and set the shape of the submatrix to be the starting slice ID, the ending slice ID, the starting row or column ID, the ending row or column ID, and the number of slices contained in each row or column;

[0018] The index mode module is set to set the length and width dimensions of the access instruction description slice and access data through the index mode, where the index mode includes row index mode and column index mode. The row index mode includes slice ID, row start ID, and row end ID; the column index mode includes slice ID, column start ID, and column end ID; the calculation basis of the slice ID is positioned with the starting slice ID of the mother matrix as the origin.

[0019] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the above-mentioned slice storage and indexing method based on matrix data are implemented.

[0020] According to a fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided, on which computer instructions are stored. When the instructions are executed by a processor, the steps of the above-mentioned slice storage and indexing method based on matrix data are implemented.

[0021] The present disclosure provides a slice-based storage and indexing method, system, electronic device, and storage medium based on matrix data, which sets a slice storage structure: the data within the slice is stored continuously in a row- or column-first manner, the slice index is numbered in a row-first or column-first manner, and the shape of the sub-matrix is ​​set to a starting slice ID, an ending slice ID, a starting row or column ID, an ending row or column ID, and the number of slices contained in each row or column; the indexing method is set: the access instruction describes the length and width dimensions of the slice, and accesses the data through an indexing method, wherein the indexing method includes a row indexing method and a column indexing method, the row indexing method includes a slice ID, a row starting ID, and a row ending ID; the column indexing method includes a slice ID, a column starting ID, and a column ending ID; the calculation basis of the slice ID is positioned with the starting slice ID of the mother matrix as the origin. Specifically, the beneficial effects of the present invention include:

[0022] 1. Distributed storage, lump-sum retrieval: No need to store all data in the storage space, reducing the demand for storage space. Based on the characteristics of matrix multiplication, the entire data that needs to be calculated can be easily retrieved in full, reducing the number of memory accesses and the probability of data loss.

[0023] 2. Flexible operation and reduced space waste: The concept of submatrices enables flexible operations on local data in large matrices. When transposing, there is no need to change the storage order; the data can be transposed by changing the slice ID number of the table. The operation granularity is a vector with the number of slice rows as the size. When splicing, there is no need to apply for huge continuous storage space; storage is performed by slice, effectively reducing space waste.

[0024] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0026] Figure 1 Schematic diagram of a method for storing data by slice and indexing sub-matrices in a mother matrix in an embodiment of the present invention;

[0027] Figure 2 Schematic diagram of a matrix transposition reference and submatrix splicing method according to an embodiment of the present invention;

[0028] Figure 3 is a schematic diagram of a mapping method for storing data in hardware according to an embodiment of the present invention;

[0029] Figure 4 Schematic diagram of a matrix multiplication configuration method in the Transformer decoding stage according to an embodiment of the present invention;

[0030] Figure 5 Schematic diagram of the Transformer key-value storage matrix method according to an embodiment of the present invention;

[0031] Figure 6 Schematic diagram of the structure of a slice storage and indexing system based on matrix data in an embodiment of the present invention;

[0032] Figure 7 It is a schematic diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0033] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are intended only to illustrate the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present invention, not all structures.

[0034] Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the steps as sequential processes, many of the steps can be implemented in parallel, concurrently, or simultaneously. In addition, the order of the steps can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.

[0035] The present invention provides the following embodiments for a slice-based storage and indexing method, system, electronic device, and storage medium based on matrix data:

[0036] A slice storage and indexing method based on matrix data, the method comprising:

[0037] Set the slice storage structure: intra-slice data is stored continuously in row or column priority, inter-slice data is stored continuously or discontinuously, slice indexes are numbered in row or column priority, and the shape of the submatrix is ​​set to the starting slice ID, ending slice ID, starting row or column ID, ending row or column ID, and the number of slices in each row or column;

[0038] Set the indexing method: The access instruction describes the length and width dimensions of the slice, and accesses the data through the indexing method. The indexing method includes row indexing method and column indexing method. The row indexing method includes the slice ID, row start ID, and row end ID; the column indexing method includes the slice ID, column start ID, and column end ID. The calculation basis of the slice ID is positioned with the starting slice ID of the mother matrix as the origin.

[0039] Preferably, different mother matrix regions may be provided with different sheet shapes.

[0040] Preferably, the number of slices contained in each row or column refers to the number of slices that can be accommodated in a single row or column of the sub-matrix. When the size of the mother matrix is ​​insufficient, the excess area is automatically padded with zeros.

[0041] Preferably, each sub-matrix and / or main matrix stores a physical address mapping table corresponding to one slice ID.

[0042] Preferably, the physical address mapping table also marks whether the matrix data is transposed. If transposed, the ID number of the transposition table is used, and the extracted slice attributes are also marked with the transposition attributes.

[0043] In the specific implementation process, Figure 1As shown, the slice storage structure is based on the matrix. In physical storage, the data within each slice must be stored continuously in a row-first manner, while the data between slices does not need to be stored continuously. The slice index numbering method supports both row-first and column-first modes, which can be flexibly selected according to computing needs. Each instruction must clearly describe the length and width dimensions of the slice, and access the data through the index method (slice ID, row start ID, row end ID). Among them, the calculation basis of the slice ID is positioned with the starting slice ID of the mother matrix as the origin. As shown Figure 1 As shown in the figure, the row-based access method is demonstrated in the example. However, in actual applications, block access by column can also be selected. If not specified, the default row start ID is the first row and the row end ID is the last row. The minimum data access granularity of this scheme is a row vector within the slice;

[0044] Furthermore, the shape of the slice is allowed to be set dynamically and flexibly, and different slice shapes can be set for different mother matrix regions. However, in order to facilitate hardware mapping, the dimensions of the slice should match the hardware resources (such as register capacity and bus bandwidth);

[0045] Furthermore, the shape of each submatrix is ​​described by the following parameters: (start slice ID, end slice ID, start row ID, end row ID, number of slices per row). The number of slices per row refers to the number of slices that can be accommodated in a single row of the submatrix. If the size of the mother matrix is ​​insufficient, the excess area is automatically padded with zeros to meet the needs of subsequent calculations.

[0046] Further, such as Figure 1 As shown, all matrix storage has a slice-based physical address mapping table. In addition to corresponding virtual slice IDs, the table also marks whether the table manages transposition. If transposition is performed, the ID number of the transposition table is used, and the extracted slice attributes are also marked with transposition attributes.

[0047] Preferably, when the matrix data is moved to a higher-level storage structure, the data moved to the shared memory is transposed and rearranged through a dedicated thread.

[0048] In the specific implementation process, Figure 2 As shown, when transposing the annotation, the stored data position does not change at all. When used, the table flag position corresponding to the mother matrix is ​​set to 1, and the mapping relationship of the table is changed to column priority (in brackets). The transposed slice ID number can be replaced by the dimension information of the mother matrix, for example Figure 2 The column ID number data in the brackets in the table is

[0049] ,

[0050] Where n is the row-major slice ID number, n* is the column-major slice ID number, and floor() means rounding down.

[0051] Furthermore, after data is moved to a higher-level storage structure, efficient transposition support is required at the hardware level. For example, in a CUDA environment, dedicated threads can be used to transpose and rearrange data moved to shared memory, allowing efficient transposed access for subsequent calculations.

[0052] like Figure 2 As shown in the figure, the concept of submatrices is introduced to implement matrix splicing. In actual application scenarios, the size of the matrix to be spliced ​​is usually not determined in advance. Therefore, the shape description of the submatrix is ​​based on the coordinates of the mother matrix, specifically defined as (starting slice ID, ending slice ID, number of submatrix rows and slices), and is usually indexed and managed in a row-first manner. In actual storage operations, since inter-slice data does not need to be stored continuously, when calculating the spliced ​​matrix, there is no need to apply for the entire submatrix in advance. It is only necessary to apply for space for each slice separately.

[0053] Preferably, an index table and a storage mapping table are created based on the matrix data that needs to be stored after calculation, the matrix data is stored in the main memory according to the index table, the matrix data is registered according to the storage mapping table and the main memory data is transmitted through the PCIe interface.

[0054] In the specific implementation process, Figure 3 As shown in the figure, during mapping, the index granularity of the data can be less than or equal to a slice, but the granularity must be an integer multiple of the length of a single row within the slice. After the calculation is complete, an index table for the results is created and the results are stored back to main memory according to this table. It is important to note that main memory data is typically transferred via the PCIe interface. Before transferring data, the corresponding storage mapping table must be registered for the matrix to be transferred.

[0055] In a specific embodiment, Figure 4 As shown in the figure, it is the data index of GPT2.0-345M in the decoding stage. In this table, the data of the left multiplication matrix is ​​stored continuously in rows (1×1024), and the storage dimension of the data of the right multiplication matrix is ​​32×32. With this configuration, when the bandwidth is 2 Kbyte (for example, a bandwidth of 32 channels and 512 bits), the scheme can extract the data of the left and right multiplication matrices to the on-chip storage in two requests, thereby providing 64 matrix multiplication data for the computing unit (such as the common 4×4 convolution unit), and in the subsequent 1024 / 32 = 32 times, the left matrix data will not be lost, and only the right multiplication matrix needs to be continuously moved.

[0056] In another specific embodiment, Figure 5Figure 2 shows the storage and recall matrix configuration for key values. In typical processes, storage space sufficient to hold the entire key value is allocated in a single operation based on model information. However, during the pre-population phase, the storage of key values ​​does not require the entire space to be filled, resulting in a significant amount of wasted space that cannot be filled. Due to the presence of a lookup table, or physical address mapping table, this solution only requires storage space for the next result (minimum of one slice), without requiring storage space for the parent matrix (i.e., the key value matrix). By changing the slice size to the size of a single result, storage space waste can be minimized. Regarding matrix splicing operations, this method does not alter the physical storage location of the original data. Based on the parent matrix's lookup table, the target physical address corresponding to the slice ID and row ID is located. If the target slice ID already exists in the slice index table, the corresponding physical address is directly accessed. If not, a continuous range of blank physical addresses is dynamically allocated and registered as the new slice ID. The data is then written to the corresponding storage space, achieving logical matrix splicing. This method effectively reduces the waste caused by applying for storage space of the entire mother matrix size at one time in multi-head splicing and key-value caching operations in the Transformer model, while avoiding the challenges brought by applying for larger continuous storage space.

[0057] Another embodiment is used to illustrate a slice storage and indexing system based on matrix data, such as Figure 6 As shown, the system 600 includes:

[0058] Setting a slice storage structure module 610, which is used to set the slice data to be stored continuously in a row-first or column-first manner, the slice index numbering method to be row-first or column-first, and the shape of the submatrix to be a starting slice ID, an ending slice ID, a starting row or column ID, an ending row or column ID, and the number of slices contained in each row or column;

[0059] An index mode module 620 is set to set the length and width dimensions of the access instruction description slice and access data through an index mode, wherein the index mode includes a row index mode and a column index mode. The row index mode includes a slice ID, a row start ID, and a row end ID; the column index mode includes a slice ID, a column start ID, and a column end ID; the calculation basis of the slice ID is positioned with the start slice ID of the mother matrix as the origin.

[0060] In addition to the above modules, the system 600 may also include other components. However, since these components are irrelevant to the content of the embodiment of the present disclosure, their illustration and description are omitted here.

[0061] For other specific working processes of the matrix data-based slice storage and indexing system 600, please refer to the description of the above-mentioned matrix data-based slice storage and indexing method embodiment, which will not be repeated here.

[0062] Another embodiment is used to illustrate that the system of the present invention can also be used with the help of Figure 7 The architecture of the computing device shown is implemented. Figure 7 The architecture of the computing device is shown in FIG. Figure 7 As shown, a computer system 710, a system bus 730, one or more CPUs 740, an input / output 720, a memory 750, etc. The memory 750 can store various data or files used for computer processing and / or communication, as well as program instructions executed by the CPU, including the slice storage and indexing method based on matrix data of the embodiment. Figure 7 The architecture shown is only exemplary and may be adjusted based on actual needs when implementing different devices. Figure 7 One or more components in the memory 750. The memory 750, as a computer-readable storage medium, can be used to store software programs, computer executable programs, and modules, such as program instructions / modules corresponding to the matrix data-based slice storage and indexing method in the embodiment of the present invention (for example, the slice storage structure setting module 610 and the indexing method setting module 620 in the matrix data-based slice storage and indexing system 600). One or more CPUs 740 execute various functional applications and data processing of the system of the present invention by running the software programs, instructions, and modules stored in the memory 750, that is, to implement the above-mentioned matrix data-based slice storage and indexing method, which includes:

[0063] Set the slice storage structure: intra-slice data is stored continuously in row or column priority, inter-slice data is stored continuously or discontinuously, slice indexes are numbered in row or column priority, and the shape of the submatrix is ​​set to the starting slice ID, ending slice ID, starting row or column ID, ending row or column ID, and the number of slices in each row or column;

[0064] Set the indexing method: The access instruction describes the length and width dimensions of the slice, and accesses the data through the indexing method. The indexing method includes row indexing method and column indexing method. The row indexing method includes the slice ID, row start ID, and row end ID; the column indexing method includes the slice ID, column start ID, and column end ID. The calculation basis of the slice ID is positioned with the starting slice ID of the mother matrix as the origin.

[0065] Of course, the processor of the server provided by the embodiment of the present invention is not limited to executing the method operations described above, but can also execute related operations in the slice storage and indexing method based on matrix data provided by any embodiment of the present invention.

[0066] The memory 750 may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data created based on the use of the terminal, etc. Furthermore, the memory 750 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some instances, the memory 750 may further include memory remotely located relative to one or more CPUs 740, and these remote memories may be connected to the system via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0067] The input / output 720 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the system. The input / output 720 may also include a display device such as a display screen.

[0068] Embodiments of the present invention also provide a non-transitory computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program implements the slice-based storage and indexing method for matrix data described in the above embodiments. The computer-readable storage medium of the embodiments of the present invention may be any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, system, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device.

[0069] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, system, or device.

[0070] The program code contained on the storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0071] In addition, other specific working processes of a non-transitory computer-readable storage medium refer to the description of the above-mentioned slice storage and indexing method embodiment based on matrix data, and are not repeated here.

[0072] According to the above embodiments, the present disclosure provides a slice storage and indexing method, system, electronic device and storage medium based on matrix data, setting a slice storage structure: the data in the slice is stored continuously in a row or column priority manner, the slice index is numbered in a row priority or column priority manner, and the shape of the sub-matrix is ​​set to the starting slice ID, the ending slice ID, the starting row or column ID, the ending row or column ID, and the number of slices contained in each row or column; setting the index method: the access instruction describes the length and width dimensions of the slice, and accesses the data through the index method, wherein the index method includes a row index method and a column index method, the row index method includes the slice ID, the row starting ID, and the row ending ID; the column index method includes the slice ID, the column starting ID, and the column ending ID; the calculation basis of the slice ID is positioned with the starting slice ID of the mother matrix as the origin. Specifically, the beneficial effects of the present invention include:

[0073] 1. Distributed storage, lump-sum retrieval: No need to store all data in the storage space, reducing the demand for storage space. Based on the characteristics of matrix multiplication, the entire data that needs to be calculated can be easily retrieved in full, reducing the number of memory accesses and the probability of data loss.

[0074] 2. Flexible operation and reduced space waste: The concept of submatrices enables flexible operations on local data in large matrices. When transposing, there is no need to change the storage order; the data can be transposed by changing the slice ID number of the table. The operation granularity is a vector with the number of slice rows as the size. When splicing, there is no need to apply for huge continuous storage space; storage is performed by slice, effectively reducing space waste.

[0075] In this document, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a step or method that comprises a series of elements includes not only those elements, but also includes other elements not expressly listed, or also includes elements inherent to such step or method.

[0076] The above is a further detailed description of the present invention in conjunction with specific preferred embodiments, and the specific implementation of the present invention should not be considered to be limited to these descriptions. For those skilled in the art of the present invention, without departing from the concept of the present invention, several simple deductions or substitutions can be made, which should be considered to fall within the scope of protection of the present invention.

Claims

1. A slice storage and indexing method based on matrix data, characterized in that: The method comprises: Set the slice storage structure: Intra-slice data is stored continuously in row or column priority, and inter-slice data is stored continuously or discontinuously. When the slice index numbering method is row priority, set the sub-matrix description to start slice ID, end slice ID, start row ID, end row ID, and the number of slices contained in each row; when the slice index numbering method is column priority, set the sub-matrix description to start slice ID, end slice ID, start column ID, end column ID, and the number of slices contained in each column; Set the indexing method: The access instruction describes the length and width dimensions of the slice and accesses the data through the indexing method. The indexing method includes row indexing and column indexing. The row indexing method includes the slice ID, row start ID, and row end ID; the column indexing method includes the slice ID, column start ID, and column end ID. The calculation basis of the slice ID is positioned with the starting slice ID of the mother matrix as the origin. An index table and a storage mapping table are created based on the matrix data to be stored. The storage mapping table corresponds to the slice ID and marks whether the matrix data is transposed. If transposed, the ID number of the transposition table is used. The extracted slice attributes are also marked with the transposed attributes. When the transposition marking is performed, the stored data position is not changed. When used, the table of the mother matrix is ​​marked and the mapping relationship of the table is changed. The slice ID number after transposition is replaced by the dimension information of the mother matrix.

2. The slice storage and indexing method based on matrix data according to claim 1, characterized in that: Different mother matrix regions can be set with different sheet shapes.

3. The slice storage and indexing method based on matrix data according to claim 1, characterized in that: The number of slices contained in each row or column refers to the number of slices that the sub-matrix can accommodate in a single row or column. When the size of the mother matrix is ​​insufficient, the excess area is automatically padded with zeros.

4. The slice-based storage and indexing method based on matrix data according to claim 1, characterized in that: When performing matrix splicing, the physical storage location of the original data is not changed. Based on the physical address mapping table of the mother matrix, the target physical address corresponding to the slice ID and row ID is located. If the target slice ID already exists in the slice index table, the corresponding physical address is directly accessed; if not, a continuous blank physical address is dynamically requested and registered as a new slice ID. The data is then written into the corresponding storage space to achieve logical matrix splicing.

5. The slice storage and indexing method based on matrix data according to claim 1, characterized in that: When matrix data is moved to a higher-level storage structure, a dedicated thread is used to transpose and rearrange the data moved to the shared memory.

6. The slice-based storage and indexing method based on matrix data according to claim 1, characterized in that: An index table and a storage mapping table are created based on the matrix data that needs to be stored after calculation, the matrix data is stored in the main memory according to the index table, the matrix data is registered according to the storage mapping table, and the main memory data is transmitted through the PCIe interface.

7. A slice storage and indexing system based on matrix data, characterized in that: The system comprises: Set up a slice storage structure module, which is used to set the intra-slice data to be stored continuously in row or column priority, and the inter-slice data to be stored continuously or discontinuously. When the slice index numbering method is row priority, set the sub-matrix description to be the starting slice ID, ending slice ID, starting row ID, ending row ID, and the number of slices contained in each row; when the slice index numbering method is column priority, set the sub-matrix description to be the starting slice ID, ending slice ID, starting column ID, ending column ID, and the number of slices contained in each column; The indexing mode module is used to set the length and width dimensions of the access instruction description slice and access data through the indexing mode, wherein the indexing mode includes row indexing mode and column indexing mode. The row indexing mode includes slice ID, row start ID, and row end ID; the column indexing mode includes slice ID, column start ID, and column end ID; the calculation basis of the slice ID is positioned with the starting slice ID of the mother matrix as the origin; An index table and a storage mapping table are created based on the matrix data to be stored. The storage mapping table corresponds to the slice ID and marks whether the matrix data is transposed. If transposed, the ID number of the transposition table is used. The extracted slice attributes are also marked with the transposed attributes. When the transposition marking is performed, the stored data position is not changed. When used, the table of the mother matrix is ​​marked and the mapping relationship of the table is changed. The slice ID number after transposition is replaced by the dimension information of the mother matrix.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the slice storage and indexing method based on matrix data as claimed in any one of claims 1 to 6 are implemented.

9. A non-transitory computer-readable storage medium having computer instructions stored thereon, characterized in that: When the instructions are executed by a processor, the steps of the slice storage and indexing method based on matrix data as claimed in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Graphics processing unit based matrix transpose optimization method

    CN103761215A

  • Matrix storage method, matrix access method and device and electronic equipment

    CN111176582A