COMPUTING DEVICE AND METHOD FOR REUSING DATA

20220206749 · 2022-06-30

Assignee

Inventors

Cpc classification

International classification

Abstract

A computing device and a method for reusing data are provided. The computing device includes a general register and an arithmetic unit coupled to the general register. The arithmetic unit includes a data reuse unit, which is coupled to multiple dot product data units. The data reuse unit is configured to read from the general register and temporarily store a data set used for multiple convolution operations, and determine multiple data subsets from the data set to be respectively inputted into the multiple dot product data units. Two data subsets inputted into two adjacent dot product data unit include a portion of the same data. Each of the multiple dot product data units is configured to perform a dot product operation on the inputted data subset, so as to generate a dot product operation result.

Claims

1. A computing device, comprising: a general register; and an arithmetic unit, coupled to the general register, wherein the arithmetic unit comprises: a data reuse unit, coupled to a plurality of dot product data units, wherein the data reuse unit is configured to read from the general register and temporarily store a data set used for a plurality of convolution operations, and determines a plurality of data subsets from the data set, so as to respectively input the plurality of data subsets into the plurality of dot product data units, wherein two data subsets inputted into two adjacent dot product data units comprise a portion of the same data; and the plurality of dot product data units, wherein each dot product data unit of the plurality of dot product data units is configured to perform a dot product operation on an inputted data subset, so as to generate a dot product operation result.

2. The computing device according to claim 1, wherein the each dot product data unit of the plurality of dot product data units is further configured to generate a current cumulative result of the dot product data unit based on a previous cumulative result of the dot product data unit and the dot product operation result.

3. The computing device according to claim 2, wherein the each dot product data unit of the plurality of dot product data units is further configured to write the current cumulative result to the general register to serve as a convolution operation result when it is determined that a convolution operation has ended.

4. The computing device according to claim 1, wherein each data subset of the plurality of data subsets comprises a plurality of pairs of data.

5. The computing device according to claim 1, wherein the each dot product data unit of the plurality of dot product data units comprises a plurality of multipliers, a plurality of adders, and an accumulation register.

6. The computing device according to claim 1, wherein the computing device is a stream processor.

7. A method for reusing data, comprising: reading from a general register and temporarily storing a data set used for a plurality of convolution operations by a data reuse unit; determining a plurality of data subsets from the data set, so as to respectively input the plurality of data subsets into a plurality of dot product data units by the data reuse unit, wherein two data subsets inputted into two adjacent dot product data units comprise a portion of the same data; and performing a dot product operation on an inputted data subset by each dot product data unit of the plurality of dot product data units, so as to generate a dot product operation result.

8. The method according to claim 7, further comprising: generating a current cumulative result of the dot product data unit based on a previous cumulative result of the dot product data unit and the dot product operation result by the each dot product data unit of the plurality of dot product data units.

9. The method according to claim 8, further comprising: writing the current cumulative result to the general register to serve as a convolution operation result by the each dot product data unit of the plurality of dot product data units when it is determined that a convolution operation has ended.

10. The method according to claim 7, wherein each data subset of the plurality of data subsets comprises a plurality of pairs of data.

Description

BRIEF DESCRIPTION OF THE DRAWINGS

[0018] To make the above features and advantages more comprehensible, several embodiments accompanied by drawings are described in detail as follows. In the drawings, the same or similar reference numerals indicate the same or similar elements.

[0019] FIG. 1 is a schematic block diagram of a stream processor 100 according to the related art.

[0020] FIG. 2 is a flowchart of a method 200 for performing a convolution operation by an arithmetic unit of a stream processor according to the related art.

[0021] FIG. 3 is a schematic block diagram of a computing device 300 according to an embodiment of the disclosure.

[0022] FIG. 4 is a schematic block diagram of a dot product data unit 400 according to an embodiment of the disclosure.

[0023] FIG. 5 is a schematic diagram of a method 500 for reusing data according to an embodiment of the disclosure.

DESCRIPTION OF THE EMBODIMENTS

[0024] Exemplary embodiments of the disclosure are described with reference to the accompanying drawings as follows, in which various details of the embodiments of the disclosure are included to facilitate understanding. However, they should be regarded as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the disclosure. Likewise, for clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0025] The term “including” and variations thereof used herein open-ended inclusion, that is, “including but not limited to”. Unless specifically stated, the term “or” means “and/or”. The term “based on” means “at least partially based on”. The terms “an exemplary embodiment” and “an embodiment” mean “at least one exemplary embodiment”. The term “another embodiment” means “at least one additional embodiment”. Terms such as “first”, “second”, etc. may refer to different or the same objects. The following may also include other explicit and implicit definitions.

[0026] It should be understood that when a component is described as being “connected to” or “coupled to” to another component, it may be directly connected or coupled to another component, and there may be an intermediate component. Conversely, when a component is described as being “directly connected to” or “directly coupled to” another component, there is no intermediate component. Other words used to describe a relationship between components may also be interpreted in a similar manner, such as “between” and “directly between”, or “adjacent to” and “directly adjacent to” and so on.

[0027] As mentioned above, the related art faces the following issues. As each of the operation cycle may only complete a mathematical operation of a single pixel point, a large number of cycles is required for a convolution and pooling operation, therefore having a low execution efficiency. As each of the operation cycles contains multiple steps, and each step requires multiple instructions, the execution efficiency is low. As data is not shared or reused between the operation cycles, a large number of memory reading and writing operations are required, and the power consumption is high.

[0028] Therefore, this disclosure provides a computing device and a method for reusing data.

[0029] FIG. 3 is a schematic block diagram of a computing device 300 according to an embodiment of the disclosure. As shown in FIG. 3, the computing device 300 includes a general register 310 and an arithmetic unit 320. The computing device 300 includes, but is not limited to, a stream processor, for example.

[0030] The general register 310 is used to store data used in a calculation process and an operation result. The data and the operation result include, but are not limited to, numerical values, such as a pixel matrix, a convolution operation result matrix, a convolution kernel, and so on. There may be one or more general registers 310.

[0031] The arithmetic unit 320 is coupled to the general register 310. The arithmetic unit 320 may include a data reuse unit 321 and multiple dot product data units 322-1 to 322-n.

[0032] The data reuse unit 321 is coupled with the general register 310 and the multiple dot product data units 322-1 to 322-n. The data reuse unit 321 is configured to read from the general register 310 and temporarily store a data set used for multiple convolution operations. The data reuse unit 321 is also configured to obtain multiple data subsets from the data set, so as to respectively input the multiple data subsets into the multiple dot product data units 322-1 to 322-n. For example, the data reuse unit 321 may determine the multiple data subsets by splicing and shifting the data in the data set, so as to complete reusing of the inputted data between multiple mathematical operations. Each of the data subsets may include multiple pairs of data. The multiple pairs of data may be associated with multiple pixels. The data reuse unit 321 is also configured to respectively input the multiple data subsets into the multiple dot product data units 322-1 to 322-n.

[0033] Each of the multiple dot product data units 322-1 to 322-n receives a data subset from the data reuse unit 321. Each of the dot product data units is configured to perform a dot product operation on the data subset, so as to generate a dot product operation result. Each of the dot product data units is further configured to generate a current cumulative result of the dot product data unit based on the generated dot product operation result and a previous cumulative result of the dot product data unit. For example, adding the dot product operation result and the previous cumulative result, so as to generate the current cumulative result. Each of the dot product data units is further configured to write the current cumulative result of the dot product data unit to the general register 310 to serve as a convolution operation result when it is determined that the convolution operation has ended.

[0034] Each of the dot product data units may be associated with a convolution operation. For example, performing a 3×3 convolution operation on a 5×5 pixel matrix, is to perform the convolution operation on a 3×3 pixel matrix in the 5×5 pixel matrix and a 3×3 convolution kernel to obtain the convolution operation result, which may be considered as an one-time convolution operation.

[0035] Two adjacent dot product data units may be configured to be used for two adjacent convolution operations. Two data subsets inputted into the two adjacent dot product data units that are associated with each other may include a portion of the same data, thereby allowing a portion of output of the data reuse unit 321 to be shared, so as to implement data reusing. This is because the two adjacent convolution operations have a portion of the same pixels, therefore allowing data reusing. The dot product data unit may be controlled by the arithmetic unit to perform data reading, mathematical operations, and result writing.

[0036] FIG. 4 is a schematic block diagram of a dot product data unit 400 that performs a dot product operation on three pairs of data according to an embodiment of the disclosure. As shown in FIG. 4, the dot product data unit 400 includes three multipliers 410-1 to 410-3, three adders 420-1 to 420-3, and an accumulation register 430. It should be understood that the three multipliers and the three adders are only for illustrative purposes, and the dot product operation path 400 may include additional or fewer multipliers and adders, thereby performing the dot product operation on more or less pairs of data.

[0037] Each of the multipliers 410 is configured to multiply one pair of inputted data, so as to generate a product, and input the product to a corresponding adder 420. A pair of data includes, for example, a pixel and a weight in the convolution kernel.

[0038] The adder 420-1 adds the products outputted by the multipliers 410-1 and 410-2, so as to generate a first addition result, and inputs the first addition result to the adder 420-2.

[0039] The adder 420-2 adds the first addition result outputted by the adder 420-1 and the product outputted by the multiplier 410-3 to generate a second addition result, and inputs the second addition result to the adder 420-3. The generated second addition result represents the dot product operation result of the three pairs of data.

[0040] The adder 420-3 adds the second addition result outputted by the adder 420-2 and a previous cumulative result outputted by the accumulation register 430, so as to generate a third addition result, and outputs the third addition result to the accumulation register 430. The third addition result represents a current cumulative result of the convolution operation.

[0041] The accumulation register 430 is configured to temporarily store the current cumulative result.

[0042] Taking a 5×5 convolution operation as an example, it has to perform dot product operation processing on 25 pairs of data (each pair of data includes a pixel value and a corresponding weight in the convolution kernel), so as to generate a convolution operation result.

[0043] The dot product data unit calculates three pairs of data in a cycle, and a maximum number of 25/3=9 cycles may generate the convolution operation result. As compared to the related art that requires 25 cycles, the number of cycles is greatly reduced.

[0044] In general, for a MxN convolution size, using the dot product data unit that performs the dot product operation on L pixels only requires (M/L)*N cycles, which greatly reduces the number of operation cycles as compared to the M*N cycles required by the related art.

[0045] As a result, the number of operation cycles of the convolution operation may be reduced and the calculation efficiency may be improved by using the dot product data units, data reading of the general-purpose register is reduced and the power consumption is reduced by using the data reuse unit, and the requirement for data bandwidth is reduced and the area is reduced by sharing the input data among the dot product data units.

[0046] FIG. 5 shows a method for reusing data according to an embodiment of the disclosure. For example, a method 500 may be executed by the computing device 110 shown in FIG. 3. It should be understood that the method 500 may further include additional blocks not shown and/or the shown blocks may be omitted, and the scope of the disclosure is not limited thereto.

[0047] In Block 502, the data reuse unit 321 reads from the general register 310 and temporarily stores the data set used for the multiple convolution operations.

[0048] In Block 504, the data reuse unit 321 determines the multiple data subsets from the data set, so as to respectively input the multiple data subsets into the multiple dot product data units 322-1 to 322-n. The two data subsets inputted into the two adjacent dot product data units include a portion of the same data.

[0049] In Block 506, each dot product data unit of the multiple dot product data units 322-1 to 322-n performs the dot product operation on the inputted data subset, so as to generate the dot product operation result.

[0050] In Block 508, each dot product data unit of the multiple dot product data units 322-1 to 322-n generates the current cumulative result of the dot product data unit based on the previous cumulative result of the dot product data unit and the dot product operation result.

[0051] In Block 510, each dot product data unit of the multiple dot product data units write the current cumulative result to the general register to serve as the convolution operation result when it is determined that the convolution operation has ended.

[0052] In Block 510, it is determined whether the convolution operation has ended.

[0053] In Block 512, each dot product data unit of the dot product data units 322-1 to 322-n writes the current cumulative result of the dot product data unit to the general register 310 to serve as the convolution operation result when it is determined in the Block 510 that the convolution operation is over. Otherwise, return to the Block 504 to continue performing the cycle on the data to be calculated in the convolution operation. Each operation cycle includes the following steps. A data preparation step (such as the Block 504), a data calculation step (such as the Block 506), and a data cumulative step (such as the Block 508), which may be completed by a single instruction.

[0054] As a result, the number of operation cycles of the convolution operation may be reduced and the calculation efficiency may be improved by using the dot product data units, data reading of the general-purpose register is reduced and the power consumption is reduced by using the data reuse unit, and the requirement for data bandwidth is reduced and the area is reduced by sharing the input data among the dot product data units.

[0055] The following is an example of performing a 3×3 convolution operation on a 5×5 pixel matrix. It should be understood that this is only exemplary, and the disclosure does not limit the size of the pixel matrix and the size of the convolution kernel.

TABLE-US-00001 TABLE 1 5 × 5 pixel matrix A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 A21 A22 A23 A24 A25

TABLE-US-00002 TABLE 2 3 × 3 convolution kernel B1 B2 B3 B4 B5 B6 B7 B8 B9

[0056] The data reuse unit 321 may read from the general register 310 and temporarily store the above-mentioned 5×5 pixel matrix and the 3×3 convolution kernel.

[0057] The dot product data unit 322-1 is configured to perform a convolution operation (hereinafter referred to as a first convolution operation) on pixel points A1, A2, A3, A6, A7, A8, A11, A12, and A13 with a 3×3 convolution kernel. The adjacent dot product data unit 322-2 is configured to perform a convolution operation (hereinafter referred to as a second convolution operation) on pixel points A2, A3, A4, A7, A8, A9, A12, A13, and A14 with a 3×3 convolution kernel. It may be seen that the dot product data units 322-1 and 322-2 may reuse the pixels A2, A3, A7, A8, A12, and A13.

[0058] For example, each of the dot product data units performs a dot product operation on three pixels. It should be understood that this is only exemplary, and the disclosure does not limit the number of pixels targeted by each of the dot product data units.

[0059] In a first cycle of the first convolution operation, the data reuse unit 321 determines and inputs three pairs of data (A1, B1), (A2, B2), and (A3, B3) from the 5×5 pixel matrix and the 3×3 convolution kernel to the dot product data unit 322-1, and the dot product data unit 322-1 may perform a dot product operation of A1*B1+A2*B2+A3*B3 and use A1*B1+A2*B2+A3*B3 to serve as a cumulative result.

[0060] In a second cycle of the first convolution operation, the data reuse unit 321 determines and inputs three pairs of data (A6, B4), (A7, B5), and (A8, B6) from the 5×5 pixel matrix and the 3×3 convolution kernel to the dot product data unit 322-1, and the dot product data unit 322-1 may perform a dot product calculation of A6*B4+A7*B5+A8*B6 and add the cumulative result of A1*B1+A2*B2+A3*B3 to A6*B4+A7*B5+A8*B6, so as to obtain a new cumulative result of A1*B1+A2*B2+A3*B3+A6*B4+A7*B5+A8*B6.

[0061] In a third cycle of the first convolution operation, the data reuse unit 321 determines and inputs three pairs of data (A11, B7), (A12, B8), and (A13, B9) from the 5×5 pixel matrix and the 3×3 convolution kernel to the dot product data unit 322-1, and the dot product data unit 322-1 may perform a dot product calculation of A11*B7+A12*B8+A13*B9 and add the cumulative result of A1*B1+A2*B2+A3*B3+A6*B4+A7*B5+A8*B6, so as to obtain a new cumulative result of

[0062] A1*B1+A2*B2+A3*B3+A6*B4+A7*B5+A8*B6+A11*B7+A12*B8+A13*B9. At this point, the first convolution operation ends, and the dot product data unit 322-1 may use the cumulative result of A1*B1+A2*B2+A3*B3+A6*B4+A7*B5+A8*B6+A11*B7+A12*B8+A13*B9 to serve as a first convolution operation result and write it to the general register 310.

[0063] Similarly, in a first cycle of the second convolution operation, the data reuse unit 321 reuses the two pixels A2 and A3, and inputs three pairs of data (A2, B1), (A3, B2), and (A4, B3) to the dot product data unit 322-2, and the dot product data unit 322-2 may perform a dot product calculation of A2*B1+A3*B2+A4*B3 and use A2*B1+A3*B2+A4*B3 to serve as a cumulative result.

[0064] In a second cycle of the second convolution operation, the data reuse unit 321 reuses the two pixels A7 and A8, and inputs three pairs of data (A7, B4), (A8, B5), and (A9, B6) to the dot product data unit 322-2, and the dot product data unit 322-2 may perform a dot product calculation of A7*B4+A8*B5+A9*B6 and add the cumulative result of A2*B1+A3*B2+A4*B3 to A7*B4+A8*B5+A9*B6, so as to obtain a new cumulative result of A2*B1+A3*B2+A4*B3+A7*B4+A8*B5+A9*B6.

[0065] In a third cycle of the second convolution operation, the data reuse unit 321 reuses the two pixels A12 and A13, and inputs three pairs of data (A12, B7), (A13, B8), and (A14, B9) to the dot product data unit 322-2, and the dot product data unit 322-2 may perform a dot product calculation of A12*B7+A13*B8+A14*B9 and add the cumulative result of A2*B1+A3*B2+A4*B3+A7*B4+A8*B5+A9*B6, so as to obtain a new cumulative result of A2*B1+A3*B2+A4*B3+A7*B4+A8*B5+A9*B6+A12*B7+A13*B8+A14*B9. At this point, the second convolution operation ends, and the dot product data unit 322-2 may use the cumulative result of A2*B1+A3*B2+A4*B3+A7*B4+A8*B5+A9*B6+A12*B7+A13*B8+A14*B9 to serve as a second convolution operation result and write it to the general register 310.

[0066] Those skilled in the art should understand that the method steps described herein are not only limited to the order illustrated in the drawings, but may be executed in any other feasible order.

[0067] The above description of the disclosure is to enable any person of ordinary skill in the art to implement or use the disclosure. Various modifications of the disclosure are obvious to those of ordinary skill in the art, and the general principles defined herein may also be applied to other modifications without departing from the spirit and scope of the disclosure. Therefore, the disclosure is not limited to the examples and designs described herein, but is consistent with the broadest scope of the principles and novel features disclosed herein.