Sparse Matrix Multiplication Using Indexed Non-Zero Compression
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing matrix multiplication methods, particularly for sparse matrices, suffer from low efficiency due to the involvement of a large number of zero elements, leading to inefficient use of computing resources and storage.
Innovation Solution
A sparse matrix operation method that involves compressing non-zero elements in sparse matrices in row and column directions, using index matrices to identify target elements for dot product operations, and performing operations only on these elements, thereby avoiding zero elements.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If traditional dense matrix multiplication is used for sparse matrices, then the computation is straightforward and easy to implement, but a large quantity of zero elements participate in the operation, resulting in low operation efficiency
Solution Approach 1:
The sparse matrix is segmented into two separate data structures: a data matrix containing only non-zero elements and an index matrix containing position information. This segmentation allows the computation to focus only on non-zero elements, eliminating wasted operations on zero elements and improving matrix operation efficiency.
Solution Approach 2:
Zero elements are extracted and removed from the computation entirely. The index matrix extracts and stores only the position information of non-zero elements, allowing the multiplication operation to skip over zero elements completely, thereby significantly improving operation efficiency.
2Quantity of substance
If all elements including zero elements are stored in the matrix, then the matrix structure is simple and easy to access, but storage space is wasted due to the large quantity of zero elements
Solution Approach 1:
Zero elements are extracted and removed from storage. Only non-zero elements are stored in the data matrix, and their positions are recorded in the index matrix. This extraction eliminates wasted storage space while maintaining efficient access through the index structure.
Solution Approach 2:
The single two-dimensional matrix structure is transformed into a combined structure of a data matrix and an index matrix. The index matrix adds a new dimension of position information, enabling efficient storage and access of sparse data without wasting space on zero elements.
3Loss of time
If zero elements are included in the dot product operation, then the operation follows standard matrix multiplication rules, but the execution time increases due to unnecessary computations
Solution Approach 1:
Zero elements are extracted and excluded from the dot product operation. The index matrices provide position information that allows the computation to directly access and multiply only non-zero elements, eliminating unnecessary computations and reducing execution time.
Solution Approach 2:
The positions of non-zero elements are preliminarily identified and stored in the index matrices before the multiplication operation. This preliminary action allows the dot product computation to directly access relevant elements without checking zero elements, significantly reducing computation time.
Data Source
Figure 1~2
Figure 3
Figure 4
AI summary
Embodiments disclosed in this application relate to the field of computing technologies, and in particular, to a sparse matrix operation method, a processor, and a computing device. The processor includes a sparse matrix processing unit and a sparse vector operation unit. The operation method performed by the processor includes: The sparse matrix processing unit obtains a first data matrix and a first index matrix that correspond to a first sparse matrix, and a second data matrix and a second index matrix that correspond to a second sparse matrix. The sparse vector operation unit determines, based on each row of elements in the first index matrix and each column of elements included in the second index matrix, target elements on which a dot product operation needs to be performed in each row of elements in the first data matrix and each column of elements in the second data matrix, and performs a dot product operation on the target elements, to obtain a first result matrix of performing a sparse multiplication operation on the first sparse matrix and the second sparse matrix. According to this application, a quantity of zero elements participating in sparse matrix multiplication can be reduced, and efficiency of performing sparse matrix multiplication can be improved.