IP Library Granted Patent US 12699748
Granted Patent B2
US 12699748 · App. 17/543,602 · Granted Aug 4, 2026

Data processing method and apparatus applied to graphics processing unit, and electronic device

Inventors: Yinghan Li (Beijing, CN); Zhenyu Gu (Beijing, CN); Shaoxuan Wang (Beijing, CN)
Assignee: Alibaba Group Holding Limited
G06F17/16G06F7/76G06F9/3013
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12699748
App. No.
17/543,602
Granted
Aug 4, 2026
Kind
B2
Abstract

This application provides a data processing method applied to a GPU, including: reading a to-be-processed matrix from memory corresponding to a target GPU into registers in a target streaming multiprocessor, where the target streaming multiprocessor is a streaming multiprocessor adapted to perform a matrix computation on the to-be-processed matrix; in a process of reading the to-be-processed matrix from the registers into shared memory corresponding to the registers, performing a first preset operation on the to-be-processed matrix to obtain an initial matrix corresponding to the to-be-processed matrix; and in a process of reading the initial matrix from the shared memory into the registers, performing a second preset operation on the initial matrix to obtain a target matrix meeting a matrix multiplication operation requirement of a matrix-dedicated computation unit. The data processing method applied to a graphics processing unit (Graphics Processing Unit, GPU) can transform a to-be-processed matrix into a target matrix meeting a matrix multiplication operation requirement of the GPU, thereby improving applicability of the GPU for matrix multiplication operations.

Claims (62)

1 . A data processing method performed by a streaming multiprocessor of a graphics processing unit (GPU), comprising:

reading a to-be-processed matrix from memory corresponding to a target GPU into registers in a target streaming multiprocessor, wherein the target streaming multiprocessor is a streaming multiprocessor adapted to perform matrix computation on the to-be-processed matrix, wherein the reading comprises:

obtaining a first number of times that a number of bits of each register is as much as a number of bits corresponding to an integer type of elements in the to-be-processed matrix; and

starting from a first column, reading every the first number of times of elements in a same row of the to-be-processed matrix into the registers based on the first number of times;

in a process of reading the to-be-processed matrix from the registers into shared memory corresponding to the registers, performing a first preset operation on the to-be-processed matrix by starting from a first row of the to-be-processed matrix, arranging elements in every second number of times of rows of the to-be-processed matrix alternately in turn to combine into one row, and reading resulting rows into the shared memory, to obtain an initial matrix corresponding to the to-be-processed matrix; and

in a process of reading the initial matrix from the shared memory into the registers, performing a second preset operation on the initial matrix to obtain a target matrix meeting a matrix multiplication operation requirement of a computation unit dedicated to matrix multiplication, wherein the computation unit dedicated to matrix multiplication is a computation unit dedicated to matrix-related operations in the target streaming multiprocessor.

2 . The data processing method applied to a GPU according to claim 1 , wherein the obtaining a first number of times that a number of bits of the register is as much as a number of bits corresponding to an integer type of elements in the to-be-processed matrix comprises:

obtaining the number of bits of the register;

obtaining the number of bits corresponding to the integer type of elements in the to-be-processed matrix; and

determining the first number of times based on the number of bits of the register and the number of bits corresponding to the integer type of elements in the to-be-processed matrix.

3 . The data processing method applied to a GPU according to claim 1 , wherein the performing a first preset operation on the to-be-processed matrix to obtain an initial matrix corresponding to the to-be-processed matrix comprises:

obtaining a first read-in instruction specific to the to-be-processed matrix, wherein the first read-in instruction is specific to a first integer type;

obtaining the second number of times that a number of bits corresponding to the first integer type is as much as a number of bits corresponding to an integer type of elements in the to-be-processed matrix;

determining the first preset operation specific to the to-be-processed matrix based on the second number of times.

4 . The data processing method applied to a GPU according to claim 3 , wherein the second number of times is 2; and

the starting from the first row, arranging elements in every the second number of times of rows in the to-be-processed matrix alternately in turn to combine into one row, and reading the resulting rows into the shared memory to obtain the initial matrix comprises: starting from the first row, arranging elements in every two rows in the to-be-processed matrix alternately in turn to combine into one row, and reading the resulting rows into the shared memory to obtain the initial matrix.

5 . The data processing method applied to a GPU according to claim 4 , wherein the second number of times is 2, comprising that the number of bits corresponding to the first integer type is 16 and the number of bits corresponding to the integer type of elements in the to-be-processed matrix is 8; or

the number of bits corresponding to the first integer type is 32 and the number of bits corresponding to the integer type of elements in the to-be-processed matrix is 16.

6 . The data processing method applied to a GPU according to claim 3 , wherein the second number of times is 1; and

the starting from the first row, arranging elements in every the second number of times of rows in the to-be-processed matrix alternately in turn to combine into one row and reading the resulting rows into the shared memory to obtain the initial matrix comprises: starting from the first row, arranging elements in every one row in the to-be-processed matrix alternately in turn to combine into one row, and reading the resulting rows into the shared memory to obtain the initial matrix.

7 . The data processing method applied to a GPU according to claim 1 , wherein the performing a second preset operation on the initial matrix to obtain a target matrix meeting a matrix multiplication operation requirement of the computation unit dedicated to matrix multiplication comprises:

obtaining a second read-in instruction specific to the initial matrix, wherein the second read-in instruction carries a second integer type that the second read-in instruction is specific to;

obtaining a third number of times that a number of bits corresponding to the second integer type is as much as a number of bits corresponding to an integer type of elements in the initial matrix;

determining the second preset operation specific to the initial matrix based on the third number of times, wherein the second preset operation is: starting from the first column, performing a transposition on the matrix by taking every the third number of times of columns in the matrix as one column to obtain a target matrix, and reading the target matrix into the registers; and

starting from the first column, performing a transposition on the initial matrix by taking every the third number of times of columns in the initial matrix as one column to obtain the target matrix, and reading the target matrix into the registers.

8 . The data processing method applied to a GPU according to claim 7 , wherein the third number of times is 2; and

the starting from the first column, performing a transposition on the initial matrix by taking every the third number of times of columns in the initial matrix as one column to obtain the target matrix, and reading the target matrix into the registers comprises: starting from the first column, performing a transposition on the initial matrix by taking every two columns in the initial matrix as one column to obtain the target matrix, and reading the target matrix into the registers.

9 . The data processing method applied to a GPU according to claim 8 , wherein the third number of times is 2, comprising that the number of bits corresponding to the second integer type is 16 and the number of bits corresponding to the integer type of elements in the initial matrix is 8; or

the number of bits corresponding to the second integer type is 32 and the number of bits corresponding to the integer type of elements in the initial matrix is 16.

10 . The data processing method applied to a GPU according to claim 1 , wherein a number of rows and a number of columns of the to-be-processed matrix are both 2 to the power of a natural number.

11 . The data processing method applied to a GPU according to claim 10 , wherein the to-be-processed matrix comprises at least one of a first matrix arranged in column-major order and a second matrix arranged in row-major order, and the first matrix and the second matrix are respectively the 1 st and the 2 nd matrices of two matrices to be subjected to a matrix multiplication operation.

12 . A data processing apparatus comprising:

a to-be-processed matrix reading unit adapted to read a to-be-processed matrix from memory corresponding to a target computation unit into register of the target computation unit, wherein the to-be-processed matrix reading unit is further adapted to:

obtain a first number of times that a number of bits of each register is as much as a number of bits corresponding to an integer type of elements in the to-be-processed matrix; and

starting from a first column, read every the first number of times of elements in a same row of the to-be-processed matrix into the registers based on the first number of times;

a first preset operation execution unit adapted to: in a process of reading the to-be-processed matrix by starting from a first row of the to-be-processed matrix, arrange elements in every second number of times of rows of the to-be-processed matrix alternately in turn to combine into one row and read resulting rows into the shared memory from the registers into shared memory corresponding to the registers, perform a first preset operation on the to-be-processed matrix elements, to obtain an initial matrix corresponding to the to-be-processed matrix;

a second preset operation execution unit, adapted to: in a process of reading the initial matrix from the shared memory into the registers, perform a second preset operation on the initial matrix to obtain a target matrix meeting a matrix multiplication operation requirement of the target computation unit dedicated to matrix-related operations.

13 . The data processing apparatus of claim 12 , further comprising:

the target computation unit adapted to compute a matrix multiplication operation on the target matrix.

14 . The data processing apparatus of claim 12 , wherein performing the first preset operation comprises:

obtaining the second number of times that a number of bits corresponding to the first integer type is as much as a number of bits corresponding to an integer type of elements in the to-be-processed matrix.

15 . The data processing apparatus of claim 12 , wherein performing the second present operation comprises:

obtaining a third number of times that a number of bits corresponding to a second integer type is as much as a number of bits corresponding to an integer type of elements in the initial matrix; and

starting from the first column, performing a transposition on the initial matrix by taking every the third number of times of columns in the initial matrix as one column to obtain the target matrix.

16 . A data processing method comprising:

obtaining a to-be-processed matrix including at least one of a first matrix arranged in column-major order and a second matrix arranged in row-major order;

reading the to-be-processed matrix from memory into registers in a target computation unit, where the reading comprises;

obtaining a first number of times that a number of bits of each register is as much as a number of bits corresponding to an integer type of elements in the to-be-processed matrix;

starting from a first column, reading every the first number of times of elements in a same row of the to-be-processed matrix into the registers based on the first number of times;

in a process of reading the to-be-processed matrix from the registers into shared memory corresponding to the registers of the target computation unit, performing a first preset operation on the to-be-processed matrix elements by starting from a first row of the to-be-processed matrix, arranging the elements in every second number of times of rows of the to-be-processed matrix alternately in turn to combine into one row, and reading resulting rows into the shared memory, to obtain an initial matrix corresponding to the to-be-processed matrix;

in a process of reading the initial matrix from the shared memory into the registers of the target computation unit, performing a second preset operation on the initial matrix to obtain a target matrix meeting a matrix multiplication operation requirement of the target computation unit; and

performing a matrix multiplication operation on the target matrix by using the target computation unit.

17 . The data processing method according to claim 16 , wherein:

performing the first preset operation includes:

obtaining a second number of times that a number of bits corresponding to the first integer type is as much as a number of bits corresponding to an integer type of elements in the to-be-processed matrix; and

performing the second preset operation includes:

obtaining a third number of times that a number of bits corresponding to s second integer type is as much as a number of bits corresponding to an integer type of elements in the initial matrix; and

starting from the first column, performing a transposition on the initial matrix by taking every the third number of times of columns in the initial matrix as one column to obtain the target matrix.

18 . The data processing method according to claim 17 , wherein obtaining a first number of times that a number of bits of the register is as much as a number of bits corresponding to an integer type of elements in the to-be-processed matrix includes:

obtaining the number of bits of the register;

obtaining the number of bits corresponding to the integer type of elements in the to-be-processed matrix; and

determining the first number of times based on the number of bits of the register and the number of bits corresponding to the integer type of elements in the to-be-processed matrix.