Matrix matching search methods, apparatus, devices and storage media

By obtaining matrix size information from a heterogeneous computing platform and querying the corresponding relational table or constructing a hash table, the underlying heterogeneous program can be directly called, which solves the matching search bottleneck when the matrix size is small, and improves the efficiency of matrix operation and the performance of the heterogeneous computing library.

CN115563445BActive Publication Date: 2025-10-28DAWNING INT INFORMATION IND CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211148003.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-20
Publication Date
2025-10-28
Estimated Expiration
2042-09-20

Smart Images

  • Figure CN115563445B_ABST
    Figure CN115563445B_ABST
Patent Text Reader

Abstract

This application relates to a matrix matching search method, apparatus, device, and storage medium. The method includes: obtaining target size information of the target matrix during matrix operations performed on a target matrix by a target program; querying a pre-set correspondence table based on the target size information, the correspondence table storing multiple sets of correspondences between the matrix size information and the underlying heterogeneous program to be invoked; if a target underlying heterogeneous program corresponding to the target size information is found in the correspondence table, then invoking the target underlying heterogeneous program to perform matrix operations on the target matrix. This method can improve the efficiency of matrix matching search in matrix operations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of heterogeneous computing technology, and in particular to a matrix matching search method, apparatus, device, and storage medium. Background Technology

[0002] With the development of technologies such as artificial intelligence and 5G, the scale of internet data is growing rapidly, and traditional CPUs can no longer meet the increasing computing demands. To meet the computing power requirements of societal development, parallel computing on heterogeneous computing systems is becoming increasingly mainstream. High-performance BLAS (Basic Linear Algebra Subprograms) heterogeneous computing libraries are typically responsible for the efficient computation of basic vectors and matrices on heterogeneous computing platforms (CPU+GPU).

[0003] Efficient computation of general matrix multiplication is the core problem of matrix operations. On heterogeneous computing platforms, the algorithm for general matrix multiplication has different adjustable parameters for different matrix sizes. That is, different matrix sizes have different execution programs on heterogeneous computing platforms. Therefore, for a certain matrix type, high-performance BLAS heterogeneous computing libraries usually need to match the matrix type with the underlying heterogeneous program in order to select the best performing execution program for parallel computation. This process is called matching search.

[0004] Currently, when the matrix size is small, the time spent on matching search is greater than the time spent executing the underlying heterogeneous program that is matched. Therefore, when the matrix size is small, the matching search of the underlying heterogeneous program becomes the performance bottleneck of computation. Summary of the Invention

[0005] Therefore, it is necessary to provide a matrix matching search method, apparatus, device, and storage medium that can improve the efficiency of matrix matching search in order to address the above-mentioned technical problems.

[0006] Firstly, this application provides a matrix matching search method. The method includes:

[0007] During the matrix operation performed on the target matrix by the target program, the target size information of the target matrix is ​​obtained; a pre-set correspondence table is queried based on the target size information. The correspondence table stores multiple sets of correspondences between the matrix size information and the underlying heterogeneous program to be called; if the target underlying heterogeneous program corresponding to the target size information is found in the correspondence table, the target underlying heterogeneous program is called to perform matrix operation on the target matrix.

[0008] In one embodiment, the method further includes: before the target program performs matrix operations on the target matrix, starting the target program, performing matrix operations on matrices of different sizes respectively, recording the underlying heterogeneous programs called when each matrix performs matrix operations, and constructing a corresponding relationship table based on the recorded content.

[0009] In the above embodiments, the target program first traverses matrices of different sizes to perform matrix operations, thereby obtaining the underlying heterogeneous programs called when performing matrix operations on matrices of different sizes. At the same time, it constructs a correspondence table between the size information of matrices of different sizes and the underlying heterogeneous programs, which is convenient for the target program to query later.

[0010] In one embodiment, the method further includes: storing the constructed correspondence table to a hard disk; and when the target program restarts, reading the correspondence table from the hard disk into memory and converting it into a hash table for storage.

[0011] In the above embodiments, the corresponding relationship table in the hard disk is read into memory and stored and matched in the form of a hash table. Since the key-value matching speed of the hash table is fast, the matrix matching and search speed is faster in this way.

[0012] In one embodiment, the target program includes a target environment variable, and querying a preset correspondence table based on the target size information includes: when the target environment variable is a first value, performing the step of querying the correspondence table based on the target size information.

[0013] In one embodiment, the method further includes: when the target environment variable is a second value, calling a lookup function to find the target underlying heterogeneous program based on the target size information, and calling the target underlying heterogeneous program to perform matrix operations on the target matrix.

[0014] In one embodiment, the method further includes: when the target environment variable is a third value, executing matrix operations on matrices of different sizes by the target program, recording the underlying heterogeneous programs called when performing matrix operations on each matrix, and constructing a corresponding relationship table based on the recorded content.

[0015] In one embodiment, the method further includes: if no target underlying heterogeneous program corresponding to the target size information is found in the correspondence table, a lookup function is called to find the target underlying heterogeneous program based on the target size information, and the target underlying heterogeneous program is called to perform matrix operations on the target matrix.

[0016] In the above embodiments, by taking different values ​​for the target environment variable, the target program can execute different matrix matching search processes without changing the original search function, making the target program run more flexibly.

[0017] Secondly, this application also provides a matrix matching search apparatus. The apparatus includes:

[0018] The acquisition module is used to acquire the target size information of the target matrix during the matrix operation performed by the target program on the target matrix;

[0019] The query module is used to query a pre-set correspondence table based on the target size information. The correspondence table stores multiple sets of correspondences between the size information of the matrix and the underlying heterogeneous program to be called.

[0020] The first execution module is used to call the target underlying heterogeneous program to perform matrix operations on the target matrix if the target size information is found in the corresponding relationship table.

[0021] In one embodiment, the device further includes a construction module for starting the target program before the target program performs matrix operations on the target matrix, performing matrix operations on matrices of different sizes respectively, recording the underlying heterogeneous programs called when each matrix performs matrix operations, and constructing a correspondence table based on the recorded content.

[0022] In one embodiment, the device further includes a storage module for storing the constructed mapping table to a hard disk; when the target program restarts, the mapping table is read from the hard disk into memory and converted into a hash table for storage.

[0023] In one embodiment, the target program includes a target environment variable and queries a preset correspondence table based on the target size information. The device also includes a second execution module, which is used to perform the step of querying the correspondence table based on the target size information when the target environment variable is a first value.

[0024] In one embodiment, the device further includes a third execution module, which, when the target environment variable is a second value, calls a lookup function to find the target underlying heterogeneous program based on the target size information, and calls the target underlying heterogeneous program to perform matrix operations on the target matrix.

[0025] In one embodiment, the device further includes a fourth execution module, which, when the target environment variable is a third value, executes matrix operations performed by the target program on matrices of different sizes, records the underlying heterogeneous programs called when each matrix performs matrix operations, and constructs a corresponding relationship table based on the recorded content.

[0026] In one embodiment, the device further includes a fifth execution module, configured to call a lookup function if the target underlying heterogeneous program corresponding to the target size information is not found in the correspondence table, so as to find the target underlying heterogeneous program according to the target size information through the lookup function, and call the target underlying heterogeneous program to perform matrix operations on the target matrix.

[0027] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the matrix matching search method described in any of the first aspects above.

[0028] Fourthly, this application also provides a computer-readable storage medium. This computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the matrix matching search method described in any of the first aspects above.

[0029] The aforementioned matrix matching search method, apparatus, device, and storage medium, during the matrix operation performed by the target program on the target matrix, obtains the target size information of the target matrix; based on the target size information, it queries a pre-set correspondence table, which stores multiple sets of correspondences between the matrix size information and the underlying heterogeneous programs to be called; if the target underlying heterogeneous program corresponding to the target size information is found in the correspondence table, then the target underlying heterogeneous program is called to perform matrix operations on the target matrix. In this way, during the matrix operation performed by the target program, the correspondence table is queried based on the matrix size information. If the matrix size information exists in the table, the underlying heterogeneous program to be called for the matrix operation is obtained. By querying the correspondence table, the operation of the lookup functions related to matching search is optimized, saving matching search time, and the speed of querying the correspondence table is faster. Therefore, this method can improve the efficiency of matrix matching search in matrix operations. Attached Figure Description

[0030] Figure 1 This is a flowchart illustrating a matrix matching search method in one embodiment;

[0031] Figure 2 This is a flowchart illustrating the matrix matching search method in another embodiment;

[0032] Figure 3 This is a schematic diagram illustrating different values ​​of the target environment variable in one embodiment;

[0033] Figure 4 This is a flowchart illustrating the matrix matching search method in another embodiment;

[0034] Figure 5This is a structural block diagram of a matrix matching search device in one embodiment;

[0035] Figure 6 This is a structural block diagram of a matrix matching search device in another embodiment;

[0036] Figure 7 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0037] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0038] With the development of technologies such as artificial intelligence and 5G, the scale of internet data is growing rapidly, and traditional CPUs can no longer meet the increasing computing demands. To meet the computing power requirements of societal development, parallel computing on heterogeneous computing systems is becoming increasingly mainstream. High-performance BLAS (Basic Linear Algebra Subprograms) heterogeneous computing libraries are typically responsible for the efficient computation of basic vectors and matrices on heterogeneous computing platforms (CPU+GPU).

[0039] Efficient computation of general matrix multiplication is the core problem of matrix operations. On heterogeneous computing platforms, the algorithm for general matrix multiplication has different adjustable parameters for different matrix sizes. That is, different matrix sizes have different execution programs on heterogeneous computing platforms. Therefore, for a certain matrix type, high-performance BLAS heterogeneous computing libraries usually need to match the matrix type with the underlying heterogeneous program in order to select the best performing execution program for parallel computation. This process is called matching search.

[0040] AMD ROCm (Radeon Open Computing platform) is an open-source software framework for high-performance heterogeneous computing (CPU+GPU). It includes various high-performance heterogeneous computing libraries, among which rocBLAS is the high-performance BLAS heterogeneous computing library within the ROCm framework. The matrix matching search process implemented by rocBLAS involves loading a directory file named TensileLibrary.yaml, also known as the Master Solution Library, as part of the warm-up code before the matching search. This directory file uses a specific data organization pattern to map a large number of matrix size types to underlying heterogeneous execution programs. However, since the matrix size types are infinite, when encountering a matrix of a certain size, rocBLAS compares it with the matrix size types in the current directory file using a distance metric, selecting the heterogeneous execution program corresponding to the closest and most performant matrix size for the final calculation.

[0041] The rocBLAS matching search functions include: `get_library_and_adapter()`, which initializes and loads the directory file `TensileLibrary.yaml` to assist in matching the underlying heterogeneous program with the current matrix size; `GetDevice()`, which mainly retrieves various attribute information of the current hardware; `ConstructTensileProblem()`, which performs data structure transformation; `findBestSolution()`, which uses distance matching and minimum time strategies to match the current matrix size with the values ​​in `TensileLibrary.yaml` to find the best-performing underlying heterogeneous program for execution; and `solve()`, which parses parameters to obtain the underlying heterogeneous program. These functions all have a certain time consumption. Testing with matrix samples of different sizes on rocBLAS matching search related functions revealed that the time consumption of rocBLAS matching-related functions is consistently around 500µs. When the matrix size to be operated on is relatively large, the execution time of the underlying heterogeneous program is longer. The ratio of the execution time of the underlying heterogeneous program to the execution time of the matching-related functions is large, indicating that the execution time of the matching-related functions has a relatively small impact on performance. When the matrix size is small, the execution time of the underlying heterogeneous program is very small, and the ratio of the execution time of the underlying heterogeneous program to the execution time of the matching-related functions is very small, indicating that the matching-related functions become the performance bottleneck of the computation at this time.

[0042] In view of this, this application proposes a matrix matching search method. During the matrix operation of the target program, the corresponding relationship table is queried according to the matrix size information. If the matrix size information exists in the table, the underlying heterogeneous program to be called for the matrix operation is obtained. Since querying the corresponding relationship table is faster than searching the underlying heterogeneous program that matches the matrix size through the matching search related lookup function, this method can improve the efficiency of matrix matching search in matrix operation.

[0043] In one embodiment, such as Figure 1 As shown, a matrix matching search method is provided. The method is illustrated using a terminal as an example. It can be understood that this method can also be applied to a server, and furthermore, to a system including both a terminal and a server, and is implemented through interaction between the terminal and the server. The method includes the following steps:

[0044] Step 101: During the matrix operation performed on the target matrix by the target program, the terminal obtains the target size information of the target matrix.

[0045] In this context, the target program is the program that needs to perform matrix operations, the target matrix is ​​the matrix to be operated on, and the target size information is the size of the target matrix. On heterogeneous platforms, general matrix operation algorithms have different adjustable parameters for different matrix sizes. This means that the underlying heterogeneous programs performing matrix operations on matrices of different sizes are different. Therefore, the target program needs to obtain the matrix size information during the matrix operation process.

[0046] Step 102: The terminal queries the preset correspondence table based on the target size information.

[0047] The mapping table stores multiple sets of correspondences between matrix size information and the underlying heterogeneous programs that need to be called. Each matrix size corresponds to a specific underlying heterogeneous program that needs to be called when performing matrix operations on that matrix. The table is then checked to see if the matrix size obtained in the previous step exists.

[0048] Step 103: If the terminal finds the target underlying heterogeneous program corresponding to the target size information in the corresponding relationship table, it calls the target underlying heterogeneous program to perform matrix operations on the target matrix.

[0049] The target underlying heterogeneous program is a heterogeneous program that performs matrix operations on the target matrix. If the target size information exists in the correspondence table, the underlying heterogeneous program corresponding to that target size information can be obtained. Then, the target program can directly call this underlying heterogeneous program to perform matrix operations on the target matrix. This eliminates the need to execute functions related to matching and searching, such as ConstructTensileProblem(), findBestSolution(), and solve(), thus saving matching and searching time.

[0050] In the matrix matching search method described above, during the matrix operation performed by the target program on the target matrix, the target size information of the target matrix is ​​obtained. A pre-set correspondence table is then queried based on the target size information. This table stores multiple sets of correspondences between the matrix size information and the underlying heterogeneous programs to be called. If the target underlying heterogeneous program corresponding to the target size information is found in the correspondence table, then the target underlying heterogeneous program is called to perform the matrix operation on the target matrix. In this way, during the matrix operation performed by the target program, the correspondence table is queried based on the matrix size information. If the matrix size information exists in the table, the underlying heterogeneous program to be called for the matrix operation is obtained. Querying the correspondence table optimizes the operation of the lookup functions related to matching search, saves matching search time, and is faster. Therefore, this method can improve the efficiency of matrix matching search in matrix operations.

[0051] In one embodiment, before the target program performs matrix operations on the target matrix, the target program is started and performs matrix operations on matrices of different sizes respectively, and records the underlying heterogeneous programs called when performing matrix operations on each matrix, and constructs a corresponding relationship table based on the recorded content.

[0052] Optionally, a corresponding relationship table can be constructed before the target program is officially run. After the target program starts, the original matrix matching search process of the target program, such as the matching search function of rocBLAS mentioned above, is used to run the lookup function related to the matching search to perform matrix operations on matrices of different sizes. At the same time, the underlying heterogeneous programs called by matrices of different sizes during the matrix operation process are recorded in the form of key-value pairs. The key of the key-value pair is the size information of the matrix of different sizes, and the value of the key-value pair is the underlying heterogeneous program called by the matrix of different sizes.

[0053] In the above embodiments, the target program first traverses matrices of different sizes to perform matrix operations, thereby obtaining the underlying heterogeneous programs called when performing matrix operations on matrices of different sizes. At the same time, it constructs a correspondence table between the size information of matrices of different sizes and the underlying heterogeneous programs, which is convenient for the target program to query later.

[0054] In one embodiment, after the correspondence table is constructed, it is loaded before the target program runs to facilitate program queries. Figure 2 As shown, the specific steps include:

[0055] Step 201: The terminal stores the constructed correspondence table to the hard disk.

[0056] Optionally, the constructed key-value pair mapping table can be stored in an external database, such as a database on a hard drive. In this way, the mapping table will not be lost when the system loses power.

[0057] Step 202: When the target program is restarted, the terminal reads the corresponding relationship table from the hard disk into memory and stores it in the form of a hash table.

[0058] Optionally, after the correspondence table is constructed, when the target program is restarted, the correspondence table is read from the database on the hard disk into memory during the warm-up part of the target program, and stored in the form of a hash table. The key-value matching speed of the hash table is fast, and the time complexity is theoretically O(1). In this way, when the target program performs matrix operations, the value of the key-value pair is obtained according to the size information of the matrix, that is, the key of the key-value pair in the hash table, which is the underlying heterogeneous program called by the matrix.

[0059] In the above embodiments, the corresponding relationship table in the hard disk is read into memory and stored and matched in the form of a hash table. Since the key-value matching speed of the hash table is fast, the matrix matching and search speed is faster in this way.

[0060] In an optional embodiment, the target program includes a target environment variable, wherein the value of the target environment variable includes three cases. Different values ​​of the target environment variable result in different matrix matching search processes executed by the target program. The three cases are detailed below.

[0061] In the first case, if the target environment variable is the first value, the step of querying the corresponding relationship table based on the target size information is executed.

[0062] Optionally, the first value can be 1, when the target environment variable is set to 1, such as... Figure 3 As shown, ENV represents the target environment variable. When the target program performs matrix operations, during the warm-up phase of the target program, the corresponding relationship table in the database on the hard disk is read into memory and stored in the form of a hash table. When the target program performs matrix operations, it obtains the size information of the matrix and then queries the corresponding relationship table based on the size information, that is, it searches in the hash table.

[0063] In the second scenario, if the target environment variable has the second value, a lookup function is called to locate the target underlying heterogeneous program based on the target size information, and then the target underlying heterogeneous program is called to perform matrix operations on the target matrix.

[0064] Optionally, the second value can be 0. When the target environment variable is set to 0, please refer to [the relevant documentation]. Figure 3 The matrix matching search process of the target program is consistent with the original unoptimized matrix matching search process. When the target program performs matrix operations, it calls the lookup function related to matching search, as mentioned above. The lookup function searches for the target underlying heterogeneous program based on the target size information, and then calls the found target underlying heterogeneous program to perform matrix operations.

[0065] In the third scenario, when the target environment variable has a third value, the target program performs matrix operations on matrices of different sizes, records the underlying heterogeneous programs called when performing matrix operations on each matrix, and constructs a corresponding relationship table based on the recorded content.

[0066] Optionally, the second value can be 2. When the target environment variable is set to 2, please refer to [the relevant documentation]. Figure 3 The target program performs matrix operations on matrices of different sizes. The matching search process during the matrix operation is consistent with the original unoptimized matrix matching search process. At the same time, it obtains the size information of all matrix operations and the corresponding underlying heterogeneous programs found. Then, it constructs a corresponding relationship table in the form of key-value pairs and stores it in the database on the hard disk.

[0067] In the above embodiments, by taking different values ​​for the target environment variable, the target program can execute different matrix matching search processes without changing the original search function, making the target program run more flexibly.

[0068] In one embodiment, if the target underlying heterogeneous program corresponding to the target size information is not found in the correspondence table, a lookup function is called to find the target underlying heterogeneous program based on the target size information, and the target underlying heterogeneous program is called to perform matrix operations on the target matrix.

[0069] If the matrix's size information is not recorded in the correspondence table, the original matching search function is invoked to locate the target underlying heterogeneous program based on the target size information, and then the target underlying heterogeneous program is called to perform matrix operations on the target matrix. Optionally, after execution, the unrecorded size information and the corresponding underlying heterogeneous program can be added to the correspondence table.

[0070] In the embodiments of this application, please refer to Figure 4The diagram illustrates a flowchart of a matrix matching search method provided in an embodiment of this application. The matrix matching search method includes the following steps:

[0071] Step 401: Before the target program performs matrix operations on the target matrix, the terminal starts the target program and performs matrix operations on matrices of different sizes respectively. The target program records the underlying heterogeneous programs called when performing matrix operations on each matrix and constructs a corresponding relationship table based on the recorded content.

[0072] Step 402: The terminal stores the constructed correspondence table to the hard disk.

[0073] Step 403: When the target program is restarted, the terminal reads the corresponding relationship table from the hard disk into memory and stores it in the form of a hash table.

[0074] Step 404: During the matrix operation performed on the target matrix by the target program, obtain the target size information of the target matrix.

[0075] Step 405: Query the preset correspondence table based on the target size information.

[0076] Step 406: If the target underlying heterogeneous program corresponding to the target size information is found in the corresponding relationship table, then the target underlying heterogeneous program is called to perform matrix operations on the target matrix.

[0077] To facilitate readers' understanding of the technical solutions provided in the embodiments of this application, the matrix matching search method of this application is illustrated below with examples. When performing matrix operations according to the optimized matrix matching search method described above, the target environment variable is first set to 2, the target program is executed, and the size information of various matrices of different sizes involved, along with the corresponding underlying heterogeneous programs, are stored in the disk database. Then, the target environment variable is set to 1, and the program is run again. At this point, only the first warm-up requires reading the corresponding relationship table from the database into memory, which is relatively time-consuming. After the table is read, the corresponding relationship table is stored in memory in the form of a hash table. During subsequent matrix operations, after obtaining the matrix size, key-value matching is performed in the hash table. The fast matching speed of the hash table significantly reduces the original matching search time. Sample testing shows that the matching search time has been reduced from over 500 µs to 50 µs. Therefore, when the matrix size is small, the reduced matching search time improves the matrix matching search efficiency, resulting in a significant performance improvement for the BLAS heterogeneous computing library.

[0078] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0079] Based on the same inventive concept, this application also provides a matrix matching search apparatus for implementing the matrix matching search method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more matrix matching search apparatus embodiments provided below can be found in the limitations of the matrix matching search method described above, and will not be repeated here.

[0080] In one embodiment, such as Figure 5 As shown, a matrix matching search device 500 is provided, including: an acquisition module 501, a query module 502, and a first execution module 503, wherein:

[0081] The acquisition module 501 is used to acquire the target size information of the target matrix during the matrix operation performed by the target program on the target matrix;

[0082] The query module 502 is used to query a preset correspondence table based on the target size information. The correspondence table stores multiple sets of correspondences between the size information of the matrix and the underlying heterogeneous program to be called.

[0083] The first execution module 503 is used to call the target underlying heterogeneous program to perform matrix operations on the target matrix if the target size information is found in the corresponding relationship table.

[0084] Please refer to Figure 6 This application embodiment also provides another matrix matching search device 600, which, in addition to including Figure 5 In addition to the modules shown, it also includes a construction module 601, a storage module 602, a third execution module 603, a fourth execution module 604, and a fifth execution module 605.

[0085] In one embodiment, the device further includes a construction module 601, which is used to start the target program before the target program performs matrix operations on the target matrix, and the target program performs matrix operations on matrices of different sizes respectively, and records the underlying heterogeneous programs called when each matrix performs matrix operations, and constructs a correspondence table based on the recorded content.

[0086] In one embodiment, the device further includes a storage module 602 for storing the constructed correspondence table to a hard disk; when the target program is restarted, the correspondence table is read from the hard disk into memory and converted into a hash table for storage.

[0087] In one embodiment, the target program includes a target environment variable and queries a preset correspondence table based on the target size information. The device also includes a second execution module, which is used to perform the step of querying the correspondence table based on the target size information when the target environment variable is a first value.

[0088] In one embodiment, the device further includes a third execution module 603, which is used to call a lookup function when the target environment variable is a second value, so as to find the target underlying heterogeneous program according to the target size information through the lookup function, and call the target underlying heterogeneous program to perform matrix operations on the target matrix.

[0089] In one embodiment, the device further includes a fourth execution module 604, which is used to execute the steps of performing matrix operations on matrices of different sizes by the target program when the target environment variable is a third value, recording the underlying heterogeneous programs called when each matrix performs matrix operations, and constructing a corresponding relationship table based on the recorded content.

[0090] In one embodiment, the device further includes a fifth execution module 605, which is used to call a lookup function if the target underlying heterogeneous program corresponding to the target size information is not found in the correspondence table, so as to find the target underlying heterogeneous program according to the target size information through the lookup function, and call the target underlying heterogeneous program to perform matrix operations on the target matrix.

[0091] Each module in the aforementioned matrix matching search device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0092] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 7As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a matrix matching search method. The display screen can be an LCD screen or an e-ink display screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.

[0093] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0094] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0095] During the matrix operation performed on the target matrix by the target program, the target size information of the target matrix is ​​obtained; a pre-set correspondence table is queried based on the target size information. The correspondence table stores multiple sets of correspondences between the matrix size information and the underlying heterogeneous program to be called; if the target underlying heterogeneous program corresponding to the target size information is found in the correspondence table, the target underlying heterogeneous program is called to perform matrix operation on the target matrix.

[0096] In one embodiment, when the processor executes the computer program, it further implements the following steps: before the target program performs matrix operations on the target matrix, the target program is started, and the target program performs matrix operations on matrices of different sizes respectively, and records the underlying heterogeneous programs called when each matrix performs matrix operations, and constructs a corresponding relationship table based on the recorded content.

[0097] In one embodiment, when the processor executes the computer program, it further performs the following steps: storing the constructed mapping table to the hard disk; and when the target program restarts, reading the mapping table from the hard disk into memory and storing it in the form of a hash table.

[0098] In one embodiment, when the processor executes the computer program, it further implements the following steps: the target program contains a target environment variable, and a preset correspondence table is queried according to the target size information, including: when the target environment variable is a first value, the step of querying the correspondence table according to the target size information is executed.

[0099] In one embodiment, when the processor executes the computer program, it further performs the following steps: when the target environment variable is a second value, it calls a lookup function to find the target underlying heterogeneous program based on the target size information, and calls the target underlying heterogeneous program to perform matrix operations on the target matrix.

[0100] In one embodiment, when the processor executes the computer program, it further implements the following steps: when the target environment variable is a third value, it executes matrix operations on matrices of different sizes by the target program, records the underlying heterogeneous programs called when performing matrix operations on each matrix, and constructs a corresponding relationship table based on the recorded content.

[0101] In one embodiment, when the processor executes the computer program, it further implements the following steps: if the target underlying heterogeneous program corresponding to the target size information is not found in the correspondence table, a lookup function is called to find the target underlying heterogeneous program based on the target size information, and the target underlying heterogeneous program is called to perform matrix operations on the target matrix.

[0102] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the matrix matching search method described above.

[0103] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0104] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0105] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0106] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.

Claims

1. A matrix matching search method, characterized in that, The method includes: During the matrix operation performed on the target matrix by the target program, the target size information of the target matrix is ​​obtained; The target size information is used to query a preset correspondence table, which stores multiple sets of correspondences between the size information of the matrix and the underlying heterogeneous program to be called. If the target underlying heterogeneous program corresponding to the target size information is found in the corresponding relationship table, then the target underlying heterogeneous program is called to perform matrix operations on the target matrix; Before the target program performs matrix operations on the target matrix, the target program is started, and the target program performs matrix operations on matrices of different sizes respectively, and records the underlying heterogeneous programs called when performing matrix operations on each matrix, and constructs the correspondence table based on the recorded content; Store the constructed correspondence table to the hard disk; When the target program restarts, the corresponding relationship table is read from the hard disk into memory and stored in the form of a hash table.

2. The method according to claim 1, characterized in that, The target program contains target environment variables, and the step of querying a preset correspondence table based on the target size information includes: If the target environment variable is a first value, perform the step of querying the corresponding relationship table based on the target size information.

3. The method according to claim 2, characterized in that, The method further includes: When the target environment variable is the second value, a lookup function is invoked to find the target underlying heterogeneous program based on the target size information, and the target underlying heterogeneous program is invoked to perform matrix operations on the target matrix.

4. The method according to claim 3, characterized in that, The method further includes: When the target environment variable is a third value, the following steps are performed: the target program performs matrix operations on matrices of different sizes, records the underlying heterogeneous programs called when performing matrix operations on each matrix, and constructs the corresponding relationship table based on the recorded content.

5. The method according to claim 3, characterized in that, The method further includes: If the target underlying heterogeneous program corresponding to the target size information is not found in the corresponding relationship table, the lookup function is called to find the target underlying heterogeneous program based on the target size information, and the target underlying heterogeneous program is called to perform matrix operations on the target matrix.

6. A matrix matching search device, characterized in that, The device includes: The acquisition module is used to acquire the target size information of the target matrix during the matrix operation performed on the target matrix by the target program; The query module is used to query a preset correspondence table based on the target size information. The correspondence table stores multiple sets of correspondences between the size information of the matrix and the underlying heterogeneous program to be called. The first execution module is used to call the target underlying heterogeneous program to perform matrix operations on the target matrix if the target size information is found in the corresponding relationship table; The module is used to start the target program before the target program performs matrix operations on the target matrix, and the target program performs matrix operations on matrices of different sizes respectively, and records the underlying heterogeneous programs called when performing matrix operations on each matrix, and constructs the correspondence table based on the recorded content; The storage module is used to store the constructed correspondence table to the hard disk; when the target program is restarted, the correspondence table is read from the hard disk into memory and converted into a hash table for storage.

7. The apparatus according to claim 6, characterized in that, The target program includes target environment variables, and the device further includes a second execution module, used to perform the step of querying the corresponding relationship table based on the target size information when the target environment variable is a first value.

8. The apparatus according to claim 7, characterized in that, The device further includes a third execution module, which is used to call a lookup function when the target environment variable is a second value, so as to find the target underlying heterogeneous program according to the target size information through the lookup function, and call the target underlying heterogeneous program to perform matrix operations on the target matrix.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data detection method and device, server and storage medium

    CN111464513A

  • Data processing method and device, and storage medium

    WO2022022362A1