Matrix processing method and apparatus, and logic circuit
AssigneeHuawei Technologies Co., Ltd.
InventorsZhenjiang Dong, CHIO IN IEONG, Hu Liu, Hai Chen
Life of this patent
Estimating the term…
Abstract
A matrix processing method includes: determining a quantity of non-zero elements in a to-be-processed matrix, where the to-be-processed matrix is a one-dimensional matrix; generating a distribution matrix of the to-be-processed matrix, where the distribution matrix is used to indicate a position of a non-zero element in the to-be-processed matrix; combining the quantity of non-zero elements, values of all non-zero elements in the to-be-processed matrix arranged sequentially, and the distribution matrix, to obtain a compressed matrix of the to-be-processed matrix.
Claims20
A matrix processing method, comprising:
- determining a quantity of non-zero elements in a to-be-processed matrix, wherein the to-be-processed matrix is a one-dimensional matrix;
- generating a distribution matrix of the to-be-processed matrix, wherein the distribution matrix is used to indicate a position of a non-zero element in the to-be-processed matrix;
- and
- combining the quantity of non-zero elements, values of all non-zero elements in the to-be-processed matrix arranged sequentially, and the distribution matrix, to obtain a compressed matrix of the to-be-processed matrix.
A logic circuit, wherein the logic circuit is configured to obtain a first mask matrix and a second mask matrix using a first distribution matrix and a second distribution matrix, wherein the first distribution matrix is used to indicate a position of a non-zero element in a first to-be-processed matrix;
- the second distribution matrix is used to indicate a position of a non-zero element in a second to-be-processed matrix;
- the first mask matrix is used to indicate a first target element in the second distribution matrix, wherein positions of all first target elements in the second distribution matrix are the same as positions of all elements whose values are 1 in the first distribution matrix;
- and the second mask matrix is used to indicate a second target element in the second distribution matrix, wherein positions of all second target elements in the first distribution matrix are the same as positions of all elements whose values are 1 in the first distribution matrix;
- and
- the logic circuit comprises first switch logic and second switch logic, wherein
- a first input end of the first switch logic is configured to sequentially receive elements in all positions in the second distribution matrix, a second input end of the first switch logic is configured to sequentially receive elements in the first distribution matrix that are in same positions as the received elements in the second distribution matrix, and an output end of the first switch logic is configured to output the first target element, to form the first mask matrix;
- when a value of an element received by the second input end of the first switch logic is 1, the first switch logic outputs, from the output end, an element received by the first input end;
- a first input end of the second switch logic is configured to sequentially receive elements in all positions in the first distribution matrix, a second input end of the second switch logic is configured to sequentially receive elements in the second distribution matrix that are in same positions as the received elements in the first distribution matrix, and an output end of the second switch logic is configured to output the second target element, to form the second mask matrix;
- and
- when a value of an element received by the second input end of the second switch logic is 1, the second switch logic outputs, from the output end, an element received by the first input end.
A matrix processing apparatus, comprising:
- a processor and a memory, wherein
- the memory is configured to store a program;
- and
- the processor is configured to invoke the program stored in the memory, to perform:
- determining a quantity of non-zero elements in a to-be-processed matrix, wherein the to-be-processed matrix is a one-dimensional matrix;
- generating a distribution matrix of the to-be-processed matrix, wherein the distribution matrix is used to indicate a position of a non-zero element in the to-be-processed matrix;
- and
- combining the quantity of non-zero elements, values of all non-zero elements in the to-be-processed matrix arranged sequentially, and the distribution matrix, to obtain a compressed matrix of the to-be-processed matrix.
A matrix processing method, comprising:
- obtaining a first to-be-processed matrix and a second to-be-processed matrix, wherein the first to-be-processed matrix and the second to-be-processed matrix are one-dimensional or multidimensional matrices;
- determining a first distribution matrix corresponding to the first to-be-processed matrix and a second distribution matrix corresponding to the second to-be-processed matrix, wherein the first distribution matrix is used to indicate a location of at least one non-zero element in the first to-be-processed matrix, and the second distribution matrix is used to indicate a location of at least one non-zero element in the second to-be-processed matrix;
- determining valid elements of the first to-be-processed matrix and the second to-be-processed matrix according to the first distribution matrix and the second distribution matrix;
- and
- performing data processing on the valid elements of the first to-be-processed matrix and the second to-be-processed matrix, to obtain a same result of performing the data processing on the first to-be-processed matrix and the second to-be-processed matrix.
Dependencies are inferred from the claim text.