Inference apparatus
Patent Information
- Application Number
- JP2023567627
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2022-11-15
- Filing Date
- 2022-11-15
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2042-11-15
AI Technical Summary
Existing inference apparatuses face challenges in increasing processing speed due to memory bandwidth limitations in battery-powered devices, particularly in performing convolutional neural network operations.
The apparatus employs a parallel processing architecture with multiple arithmetic modules, each with dedicated line memories and arithmetic units, to divide and process image data in a pipelined manner, optimizing memory usage and reducing the need for high bandwidth.
This approach eliminates memory bandwidth bottlenecks and accelerates processing speed by efficiently utilizing smaller memory capacities, allowing for faster inference operations.
Description
[Technical Field]
[0001] The technology of the present disclosure relates to an inference apparatus. [Background Art]
[0002] Japanese Patent Application Laid-Open No. 2009-080693 discloses an arithmetic processing apparatus that generates arithmetic result data by performing arithmetic on input data, and executes network computation in a hierarchical network in which a plurality of logical processing nodes are connected. The arithmetic processing apparatus calculates, for each of a plurality of types of buffer allocation methods for allocating an intermediate buffer storage area for holding arithmetic result data in a memory corresponding to each of the plurality of processing nodes configuring the network, a memory amount required for the network computation based on a configuration of the network computation, and causes the network computation to be executed in an execution order corresponding to the buffer allocation method selected based on the calculated memory amount. [Summary of the Invention] [Problem to be Solved by the Invention]
[0003] One embodiment according to the technology of the present disclosure provides an inference apparatus that enables an increase in processing speed. [Means for Solving the Problem]
[0004] To achieve the above object, the inference apparatus of the present disclosure is an inference apparatus that performs inference using machine-learned data, and includes a first arithmetic module and a second arithmetic module that execute arithmetic processing including convolution processing and pooling processing, wherein the first arithmetic module includes a first memory that stores a plurality of first row data generated by dividing input first image data in the row direction for each first number of pixels, and a plurality of first arithmetic units that execute first convolution processing on the plurality of first row data, the second arithmetic module includes a second memory that stores a plurality of second row data generated by dividing input second image data in the row direction for each second number of pixels, and a plurality of second arithmetic units that execute second convolution processing on the plurality of second row data, the number of channels of the first image data and the number of channels of the second image data are different from each other, and a first number, which is the number of first arithmetic units that execute one first convolution processing in parallel on the plurality of first row data, is different from a second number, which is the number of second arithmetic units that execute one second convolution processing in parallel on the plurality of second row data.
[0005] It is preferable that the second image data is image data including a feature amount generated by the first arithmetic module performing arithmetic processing on the first image data.
[0006] It is preferable that the number of channels of the second image data is larger than the number of channels of the first image data, and the first number is larger than the second number.
[0007] It is preferable that the number of processed pixels of the second image data input to the second arithmetic module is smaller than the number of processed pixels of the first image data input to the first arithmetic module.
[0008] It is preferable that the arithmetic processing by the first arithmetic module and the arithmetic processing by the second arithmetic module are executed in parallel.
[0009] It is preferable that a data storage unit of the first memory corresponds to the first number of pixels, a size of a filter used for the first convolution processing, and the number of channels of a filter used for the first convolution processing.
[0010] Preferably, the data storage unit of the second memory corresponds to the second number of pixels, the size of the filter used in the second convolution process, and the number of channels of the filter used in the second convolution process.
[0011] It is preferable that the number of filters used in the second convolution process is greater than the number of filters used in the first convolution process.
[0012] The first row of data is preferably data that corresponds to a portion of the rows of the first image data.
[0013] The system further comprises a third memory having a larger data storage capacity than the first and second memories and storing feature image data including feature quantities generated by the first arithmetic module, and a third arithmetic module that upsamples the input image data, wherein the first arithmetic module is a module that downsamples the first image data, and the third arithmetic module upsamples the input image data and generates corrected first image data using the feature image data stored in the third memory. [Brief explanation of the drawing]
[0014] [Figure 1] This figure shows an example of the configuration of an inference device. [Figure 2] This diagram conceptually illustrates an example of feature extraction and classification processing. [Figure 3] This diagram provides a detailed explanation of the convolution and pooling processes. [Figure 4] This diagram shows the configuration of the k-th channel of the filter. [Figure 5] This is a block diagram showing an example of the configuration of the feature extraction unit. [Figure 6] This figure shows an example of image data segmentation processing. [Figure 7] This figure shows an example of the configuration of the line memory provided in the first arithmetic module. [Figure 8]This figure shows an example of the configuration of the line memory provided in the second arithmetic module. [Figure 9] This diagram illustrates the first convolution process. [Figure 10] This diagram illustrates the second convolution process. [Figure 11] This block diagram shows an example of ALU configuration. [Figure 12] This flowchart shows an example of the flow of a single first convolution operation performed by an ALU. [Figure 13] This diagram conceptually illustrates a single first convolution operation performed by an ALU. [Figure 14] This diagram conceptually illustrates the first and second feature extraction processes. [Figure 15] This diagram shows the timing of the first feature extraction process and the second feature extraction process. [Figure 16] This is a block diagram showing the configuration of the feature extraction unit according to a modified example of the first embodiment. [Figure 17] This block diagram shows an example of the configuration of the third arithmetic module. [Figure 18] This diagram illustrates the third convolution process. [Figure 19] This diagram conceptually illustrates the first to third feature extraction processes. [Figure 20] This block diagram shows an example of the configuration of the feature extraction unit according to the second embodiment. [Figure 21] This block diagram shows an example of the configuration of multiple arithmetic modules included in a decoder. [Figure 22] This diagram conceptually illustrates the hierarchical structure of a CNN, which consists of encoders and decoders. [Figure 23] This diagram illustrates the pipeline processing performed on feature maps. [Modes for carrying out the invention]
[0015] An example of an embodiment relating to the technology of this disclosure will be described with reference to the attached drawings.
[0016] First, let's explain the terminology used in the following explanation.
[0017] In the following explanation, "IC" is an abbreviation for "Integrated Circuit". "DRAM" is an abbreviation for "Dynamic Random Access Memory". "FPGA" is an abbreviation for "Field Programmable Gate Array". "PLD" is an abbreviation for "Programmable Logic Device". "ASIC" is an abbreviation for "Application Specific Integrated Circuit". Yes. "CNN" is an abbreviation for "Convolutional Neural Network." "ALU" is an abbreviation for "Arithmetic Logic Unit."
[0018] [First Embodiment] Figure 1 shows an example of the configuration of the inference device 2. For example, the inference device 2 is incorporated into an imaging device such as a digital camera. The inference device 2 is a device that performs inference using machine learning, and for example, it determines the type of subject captured in the image data through inference. The imaging device performs various controls related to imaging based on the inference results output from the inference device 2.
[0019] The inference device 2 comprises an input unit 3, a feature extraction unit 4, an output unit 5, and a trained data storage unit 6. The input unit 3 acquires image data generated by the imaging device and inputs the acquired image data as input data to the feature extraction unit 4. The feature extraction unit 4 and the output unit 5 constitute a so-called convolutional neural network (CNN). The trained data storage unit 6 stores weights 7A and biases 7B. Weights 7A and biases 7B are trained data generated by machine learning.
[0020] The feature extraction unit 4 is an intermediate layer composed of multiple convolutional layers and pooling layers. In this embodiment, the output unit 5 is an output layer composed of a fully connected layer.
[0021] The feature extraction unit 4 extracts features by performing convolution and pooling operations on the image data input from the input unit 3. The output unit 5 classifies the image data input to the inference device 2 based on the features extracted by the feature extraction unit 4. For example, the output unit 5 classifies the type of subject depicted in the image data. The feature extraction unit 4 and the output unit 5 perform feature extraction and classification processing using a trained model configured with weights 7A and biases 7B stored in the trained data storage unit 6. The feature extraction process is an example of the "computational processing" related to the technology of this disclosure.
[0022] Figure 2 conceptually illustrates an example of feature extraction and classification processing. As shown in Figure 2, the image data P1 input from the input unit 3 to the feature extraction unit 4 consists of three channels: R (Red), G (Green), and B (Blue). The feature extraction unit 4 repeatedly performs convolution and pooling processing on the input image data P1. Image data P1 is an example of the "first image data" related to the technology of this disclosure.
[0023] The feature extraction unit 4 generates a 6-channel feature map FM1 by performing a convolution operation on the 3-channel image data P1, and generates image data P2 by performing a pooling operation on the generated feature map FM1. Image data P1 and image data P2 have different numbers of channels. The number of channels in image data P2 is greater than the number of channels in image data P1. Image data P2 has fewer pixels than image data P1 (i.e., the image size is reduced). Image data P2 is also image data that includes features generated by the first arithmetic module 11 performing a feature extraction operation on image data P1. Image data P2 is an example of the "second image data" related to the technology of this disclosure.
[0024] Furthermore, the feature extraction unit 4 generates a 12-channel feature map FM2 by performing a convolution operation on the image data P2, and generates image data P3 by performing a pooling operation on the generated feature map FM2. Image data P2 and image data P3 have different numbers of channels. The number of channels in image data P3 is greater than the number of channels in image data P2. Image data P3 has fewer pixels than image data P2 (i.e., the image size is reduced). Also, image data P3 is image data that includes features generated by the feature extraction operation performed by the second arithmetic module 12 on image data P2.
[0025] In the example shown in Figure 2, image data P3 is input from the feature extraction unit 4 to the output unit 5. The output unit 5 is composed of a fully connected layer and classifies image data P1 based on the image data P3 containing the features. The output unit 5 outputs the result of classifying image data P1 as the inference result.
[0026] Figure 3 illustrates the convolution and pooling processes in detail. In Figure 3, the number of channels in the image data P1 is K. The feature extraction unit 4 applies N filters F1 to F to the image data P1 as input data. N By performing a convolution operation using this method, N image data CP1~CP N Generates filters F1~F N This is composed of the aforementioned weight 7A. Image data CP1~CP N The number of channels in each of these is K.
[0027] Furthermore, the feature extraction unit 4 extracts image data CP1~CP N After integrating the channels for each of them, bias b1~b N Feature map FM1 is generated by adding each of these values. Channel merging refers to converting multiple channels into a single channel by adding the corresponding pixel values. The number of channels in feature map FM1 is N. Note that biases b1 to b N This corresponds to the bias 7B mentioned above.
[0028] Further, the feature extraction unit 4 generates image data P2 by performing a pooling process on the feature map FM1 using, for example, a 2×2 kernel Q. The pooling process is, for example, a max pooling process that acquires the maximum value of pixel values within the kernel Q. Note that instead of the max pooling process, an average pooling process that acquires the average value of pixel values within the kernel Q may be used. When a 2×2 kernel Q is used, the number of pixels of the image data P2 is 1 / 4 times the number of pixels of the image data P1.
[0029] Note that the feature extraction unit 4 applies an activation function in the convolution process or the pooling process. In FIG. 3, illustration of the application of the activation function is omitted.
[0030] FIG. 4 shows the filter F n configuration of the k-th channel of . The filter F n is one filter among N filters F1 to F N . In the example shown in FIG. 4, the filter F n has a size of 3×3 and the number of channels is K. The filter F n the k-th channel of is represented by nine weights w p,q,k,n . Here, p represents a horizontal coordinate within the filter F n , and q represents a vertical coordinate within the filter F n . The weight w p,q,k,n corresponds to the aforementioned weight 7A. Note that the size of the filter F n is not limited to 3×3, and can be appropriately changed to a size such as 5×5.
[0031] The aforementioned convolution process is expressed by the following formula 1. [Formula]
[0032] In formula 1, a x+p,y+q,k is the weight w in the k-th channel of the image data P1 p,q,k,nThis represents the pixel value of the pixel being multiplied. x,y represent the coordinates in the feature map FM1. x,y,n This represents the pixel value of the pixel at coordinates x,y in the nth channel of the feature map FM1. n This represents the bias added to each pixel of the nth channel of the feature map FM1.
[0033] Furthermore, when the feature extraction unit 4 performs convolution and pooling operations on image data P2, it uses image data P2 as input data instead of image data P1 and performs the same operations.
[0034] Figure 5 shows an example of the configuration of the feature extraction unit 4. The feature extraction unit 4 comprises an input data storage unit 10, a first arithmetic module 11, a second arithmetic module 12, and an arithmetic control unit 18. The input data storage unit 10 stores the image data P1 input from the input unit 3. The first arithmetic module 11 comprises a line memory 20A, a convolution processing unit 21A, and a pooling processing unit 22A. Note that one pooling processing unit 22A may be provided for each of the ALUs 23A to 23D.
[0035] The second arithmetic module 12 includes a line memory 20B, a convolution processing unit 21B, and a pooling processing unit 22B. Note that one pooling processing unit 22B may be provided for each of the ALUs 23A to 23D.
[0036] The arithmetic control unit 18 controls the operation of the input data storage unit 10, the first arithmetic module 11, and the second arithmetic module 12. The first arithmetic module 11 generates the above-mentioned image data P2 by performing feature extraction processing on image data P1. The second arithmetic module 12 generates the above-mentioned image data P3 by performing feature extraction processing on image data P2. The first arithmetic module 11 and the second arithmetic module 12 execute the feature extraction processing in parallel by performing pipeline processing. Specifically, the feature extraction processing of the second arithmetic module 12 on the data processed by the first arithmetic module 11 and the feature extraction processing of the next data by the first arithmetic module 11 are executed in parallel.
[0037] The convolution processing unit 21A includes multiple ALUs that perform convolution operations. In this embodiment, the convolution processing unit 21A comprises four ALUs 23A to 23D. As will be described in detail later, ALUs 23A to 23D execute convolution operations on input data in parallel.
[0038] Similarly, the convolution processing unit 21B includes multiple ALUs that perform convolution operations. In this embodiment, the convolution processing unit 21B comprises four ALUs 23A to 23D. As will be described in detail later, ALUs 23A to 23D execute convolution operations on input data in parallel.
[0039] The ALUs 23A to 23D included in the convolution processing unit 21A of the first arithmetic module 11 are an example of the "multiple first arithmetic units" related to the technology of this disclosure. The ALUs 23A to 23D included in the convolution processing unit 21B of the second arithmetic module 12 are an example of the "multiple second arithmetic units" related to the technology of this disclosure.
[0040] The arithmetic control unit 18 divides the image data P1 stored in the input data storage unit 10 in the row direction for each first pixel count G1 to generate multiple strip-shaped data (hereinafter referred to as first strip-shaped data PS1). The arithmetic control unit 18 also sequentially stores multiple first row data R1 contained in the first strip-shaped data PS1 in the line memory 20A of the first arithmetic module 11. The ALUs 23A to 23D of the first arithmetic module 11 perform a convolution operation on the multiple first row data R1. The first row data R1 is data corresponding to some of the rows of the image data P1.
[0041] Furthermore, the arithmetic control unit 18 sequentially stores the multiple second row data R2 that constitute the image data P2 output from the first arithmetic module 11 in the line memory 20B of the second arithmetic module 12. The multiple second row data R2 are included in multiple strip-shaped data (hereinafter referred to as second strip-shaped data PS2) generated by dividing the image data P2 in the row direction for each second pixel count G2. The ALUs 23A to 23D of the second arithmetic module 12 perform a convolution process on the multiple second row data R2.
[0042] Hereinafter, the convolution process performed by the first arithmetic module 11 will be referred to as the "first convolution process," and the convolution process performed by the second arithmetic module 12 will be referred to as the "second convolution process." Line memory 20A is an example of the "first memory" related to the technology of this disclosure. Line memory 20B is an example of the "second memory" related to the technology of this disclosure. The number of filters used in the second convolution process is greater than the number of filters used in the first convolution process.
[0043] Figure 6 shows an example of the division process of image data P1 by the arithmetic control unit 18. Image data P1 has pixels arranged in a two-dimensional array in the x and y directions for each R, G, and B channel. As shown in Figure 6, the arithmetic control unit 18 generates four first strip-shaped data PS1 by dividing the image data P1 into four parts in the x direction (corresponding to the row direction). The width of the first strip-shaped data PS1 in the x direction corresponds to the first number of pixels G1.
[0044] Furthermore, in this embodiment, the arithmetic control unit 18 divides the image data P1 such that the ends of adjacent first strip-shaped data PS1 in the x direction overlap. In this embodiment, since the convolution process using a 3x3 filter is performed twice, the overlap width is set to 6 pixels. It is preferable to change the overlap width according to the size of the filter and the number of convolution processes.
[0045] If convolution processing is performed without dividing the image data P1, it is necessary to increase the memory bandwidth in order to store the multi-channel data generated by the convolution process in a large-capacity memory (such as DRAM). However, in imaging devices such as battery-powered digital cameras, increasing the memory bandwidth is not easy, so the memory bandwidth becomes a bottleneck in processing. In contrast, as described above, by dividing the image data P1, convolution processing can be performed using a small-capacity line memory, thus eliminating the memory bandwidth bottleneck and speeding up processing.
[0046] Figure 7 shows an example of the configuration of the line memory 20A. The data storage unit of the line memory 20A corresponds to the first pixel count G1, the size of the filter used in the first convolution process, and the number of channels K of the filter used in the first convolution process. In Figure 7, M1 represents the number of lines per channel. The number of lines M1 is determined according to the size of the filter. In this embodiment, K=3 and M1=3.
[0047] The line memory 20A stores the first row data R1 in units of M1 × K lines. The first row data R1 is sequentially input from the line memory 20A to the convolution processing unit 21A. The first row data R1 refers to the data of a line in the first strip-shaped data PS1 where pixels for one channel are arranged in the x direction.
[0048] Figure 8 shows an example of the configuration of the line memory 20B. The data storage unit of the line memory 20B corresponds to the second number of pixels G2, the size of the filter used in the second convolution process, and the number of channels N of the filter used in the second convolution process. In Figure 8, M2 represents the number of lines per channel. The number of lines M2 is determined according to the size of the filter. In this embodiment, N=6 and M2=4. Also, the second number of pixels G2 is half the number of first pixels G1. This is because the number of pixels in the x direction is halved in the pooling process in the first arithmetic module 11.
[0049] The line memory 20B stores the second row data R2 in units of M2 × N lines. The second row data R2 is sequentially input from the line memory 20B to the convolution processing unit 21B. The second row data R2 refers to the data of a line in the second strip-shaped data PS2 where pixels for one channel are arranged in the x direction.
[0050] Figure 9 illustrates the first convolution process. In Figure 9, R1 i,k This shows the i-th row of data from the k-channel line memory 20A. First row data R1 i,k The data is divided into four blocks, B1 to B4, and input to ALU23A to 23D respectively. The width of each block, B1 to B4, corresponds to 1 / 4 times the number of pixels of the first pixel count, G1.
[0051] Each of the ALU23A~23D performs the first convolution by multiplying the input block by weights while pixel-shifting it. ALU23A~23D then processes the three first row data R1 i,k ,R1 i+1,k ,R1 i+2,k For each of these, one first convolution operation is performed in parallel. That is, in the first arithmetic module 11, the number of first arithmetic units that perform one first convolution operation in parallel for multiple first row data R1 (hereinafter referred to as the first number) is "4".
[0052] The data output from ALU23A~23D is input to the pooling processing unit 22A. The pooling processing unit 22A performs 2x2 pooling processing to obtain the second row of data R2, which has a width of the second number of pixels G2. i,k Outputs multiple second-line data R2 output from the pooling processing unit 22A. i,k This constitutes the second strip-shaped data PS2. The image data P2 is composed of multiple second strip-shaped data PS2s.
[0053] Figure 10 illustrates the second convolution process. In Figure 10, R2 i,k This shows the i-th second row data of the k-channel read from line memory 20B. i-th second row data R2 i,k It is divided into two blocks B1 and B2 and input into ALU23A and 23B respectively. At the same time, the (i+1)th row of data R2 i+1,k The data is divided into two blocks, B1 and B2, and input to ALU23C and 23D respectively. The width of each block, B1 and B2, corresponds to half the number of pixels of the second pixel count, G2.
[0054] Each of the ALU23A~23D performs a second convolution by multiplying the input block by weights while shifting its pixels. ALU23A and 23B process three second row data R2 i,k ,R2 i+1,k ,R2 i+2,k A second convolution operation is performed in parallel on the three second row data R2. i+1,k ,R2 i+2,k ,R2 i+3,k A single second convolution operation is performed in parallel for each of the second row data R2. That is, in the second arithmetic module 12, the number of second arithmetic units that perform a single second convolution operation in parallel for multiple second row data R2 (hereinafter referred to as the second number) is "2". In other words, the first number and the second number are different. In this embodiment, the first number is greater than the second number.
[0055] The data output from ALU23A~23D is input to the pooling processing unit 22B. The pooling processing unit 22B performs a 2x2 pooling process to obtain the third row data R3, which has a width of the third pixel count G3. i,k Outputs multiple third-line data R3 output from the pooling processing unit 22B. i,k This constitutes the third strip-shaped data PS3. Image data P3 is composed of multiple third strip-shaped data PS3s. The third pixel count G3 is half the second pixel count G2.
[0056] The first arithmetic module 11 simultaneously processes one first row of data R1 using ALUs 23A to 23D. In contrast, the second arithmetic module 12 simultaneously processes two adjacent second row of data R2 using ALUs 23A to 23D. The number of pixels processed in the image data P2 input to the second arithmetic module 12 is smaller than the number of pixels processed in the image data P1 input to the first arithmetic module 11. The number of pixels processed refers to the number of pixels that an arithmetic module processes.
[0057] Figure 11 shows an example of the configuration of ALU23A. ALU23A is composed of register 30, shift arithmetic unit 31, multiplier 32, register 33, adder 34, selector 35, adder 36, and register 37.
[0058] The block B1 described above is input to register 30. The multiplier 32 multiplies each pixel of block B1 input to register 30 by weight 7A. The block B1 multiplied by weight 7A is input to register 33.
[0059] The shift unit 31 shifts block B1 stored in register 30 by one pixel each time the multiplier 32 multiplies by weight 7A. The multiplier 32 multiplies each pixel of block B1 by weight 7A each time block B1 is shifted by a pixel. The adder 34 sequentially adds the pixels of block B1 input to register 33.
[0060] The multiplication and addition operations described above are repeated a number of times corresponding to the filter size and the number of channels. For example, if the filter size is 3x3 and the number of channels is 3, the multiplication and addition operations will be repeated 27 times.
[0061] Selector 35 selects the bias 7B corresponding to the filter. Adder 36 adds the bias 7B selected by selector 35 to the added data stored in register 33. Register 37 stores the data with the bias 7B added. The data stored in register 37 is output to the pooling processing unit 22A.
[0062] ALU23B~23D have the same configuration as ALU23A, so their explanation will be omitted.
[0063] Figure 12 shows an example of the flow of a single first convolution process by the ALU23A. In step S1, a block B1 divided from a single first row of data R1 is input to register 30. In step S2, a multiplication process with weight 7A is performed by multiplier 32. In step S3, pixel-by-pixel addition is performed by adder 34. In step S4, it is determined whether the pixel shift has been completed a predetermined number of times. If the filter size is 3x3, the pixel shift will be performed twice, so the predetermined number of times is 2. If the pixel shift has not been completed a predetermined number of times (step S4: NO), the pixel shift is performed in step S5. Steps S2 to S5 are repeatedly executed until the pixel shift has been completed a predetermined number of times. If the pixel shift has been completed a predetermined number of times (step S4: YES), the process moves to step S6.
[0064] In step S6, it is determined whether the modification of the first row data R1 has been completed a predetermined number of times. If the filter size is 3x3, the modification of the first row data R1 will be performed twice, so the predetermined number of times is 2. If the modification of the first row data R1 has not been completed a predetermined number of times (step S6: NO), the first row data R1 is modified in step S7. When block B1 is modified, block B1, which was separated from the first row data R1 modified in step S1, is input into register 30. Steps S1 to S7 are repeatedly executed until the modification of the first row data R1 is completed a predetermined number of times. If the modification of the first row data R1 has been completed a predetermined number of times (step S6: YES), the process moves to step S8.
[0065] In step S8, it is determined whether the predetermined number of channel changes have been completed. When using a 3-channel filter, the channel changes will be performed twice, so the predetermined number of changes is 2. If the predetermined number of channel changes has not been completed (step S8: NO), the channel is changed in step S9. When the channel is changed, block B1 of the channel changed in step S1 is input to register 30. Steps S1 to S9 are repeatedly executed until the predetermined number of channel changes have been completed. If the predetermined number of channel changes have been completed (step S8: YES), the process proceeds to step S10.
[0066] In step S10, the adder 36 performs the addition of bias 7B. In step S11, the data with the added bias 7B is output to the pooling processing unit 22A.
[0067] The process shown in Figure 12 represents a single first convolution operation targeting the three first row data R1 contained in the first strip-shaped data PS1. ALU23A executes the first convolution operation while sequentially changing the three target first row data R1.
[0068] ALU23B~23D perform the same processing as ALU23A.
[0069] Figure 13 conceptually illustrates a single first convolution operation by ALU23A. As shown in Figure 13, ALU23A processes three first row data R1 i,k ,R1 i+1,k ,R1 i+2,k The blocks B1, which were divided from the original, are sequentially pixel-shifted while corresponding weights w p,q,k,n Multiply by and add. Perform pixel shift, weight multiplication and addition for all channels k, and apply bias b n By adding the image data CP n One block that makes up the structure is obtained.
[0070] In the first arithmetic module 11, ALU23A~23D each handle the three target first row data R1 i,k ,R1 i+1,k ,R1 i+2,k The first convolution process is performed while changing the set row by row.
[0071] In the second arithmetic module 12, ALU23A and 23B each process the three target second row data R2 i,k ,R2 i+1,k ,R2 i+2,k The second convolution process is performed while changing the set of two rows at a time. In addition, ALU23A and 23B each process the three target second row data R2 i+1,k ,R2 i+2,k ,R2 i+3,k The second convolution process is performed while changing the set of two rows at a time.
[0072] The second convolution process is the same as the first convolution process described above, so a detailed explanation will be omitted.
[0073] Figure 14 conceptually illustrates the first and second feature extraction processes. In the example shown in Figure 14, the second strip-shaped data PS2, generated by performing the first feature extraction process on the first strip-shaped data PS1, has half the number of pixels in both the horizontal and vertical directions, and double the number of channels. Similarly, the third strip-shaped data PS3, generated by performing the second feature extraction process on the second strip-shaped data PS2, also has half the number of pixels in both the horizontal and vertical directions, and double the number of channels.
[0074] Thus, the number of pixels G2 in the second row data R2 generated by the first feature extraction process is half the number of pixels G1 in the first row data R1. For this reason, if the first arithmetic module 11 and the second arithmetic module 12 were configured to process one second row data R2 with four ALUs, two of the four ALUs in the second arithmetic module 12 would be unused and wasted. In this embodiment, the first arithmetic module 11 is configured to process one first row data R1 with four ALUs, and the second arithmetic module 12 is configured to process one second row data R2 with two ALUs, so that no unused ALUs are wasted.
[0075] Furthermore, since the second feature extraction process processes more channels than the first feature extraction process, the first feature extraction process experiences a processing delay while the second feature extraction process processes all channels. Specifically, the first arithmetic module 11 outputs one row of data to the second arithmetic module 12, but cannot output the next row of data until the second feature extraction process has finished processing all channels, resulting in a processing delay. In contrast, in this embodiment, the second arithmetic module 12 processes two rows of data simultaneously with two ALUs, so the second feature extraction process is faster than the first feature extraction process. This eliminates the processing delay in the first feature extraction process.
[0076] Figure 15 shows the timing of the first and second feature extraction processes. Figure 15(A) shows an example of processing timing when the first arithmetic module 11 and the second arithmetic module 12 are configured to process one row of data with four ALUs each. The first process represents processing a set of three rows of data. In this case, the first feature extraction process takes less time than the second feature extraction process, so there is a waiting period for the first feature extraction process.
[0077] Figure 15(B) shows an example of processing timing when the first arithmetic module 11 is configured to process one row of data with four ALUs, and the second arithmetic module 12 is configured to process one row of data with two ALUs. The first process represents processing a set of three rows of data. The second process represents processing the next set of three rows of data shifted by one row. In this case, the first feature extraction process takes less time than the second feature extraction process, but since the first and second processes are performed in parallel in the second feature extraction process, the processing delay in the first feature extraction process is eliminated.
[0078] Thus, in this embodiment, the processing delay for the first feature extraction process is eliminated, and the processing speed of inference by the inference device 2 is accelerated.
[0079] [Modified version of the first embodiment] In the first embodiment, the feature extraction unit 4 has two arithmetic modules, a first arithmetic module 11 and a second arithmetic module 12, but the number of arithmetic modules is not limited to two and may be three or more.
[0080] Figure 16 shows the configuration of a modified feature extraction unit 4A. The feature extraction unit 4A has the same configuration as the feature extraction unit 4 according to the first embodiment, except that it has a third arithmetic module 13 in addition to the first arithmetic module 11 and the second arithmetic module 12.
[0081] Figure 17 shows an example of the configuration of the third arithmetic module 13. Similar to the first arithmetic module 11 and the second arithmetic module 12, the third arithmetic module 13 includes a line memory 20C, a convolution processing unit 21C, and a pooling processing unit 22C. The convolution processing unit 21C also includes four ALUs 23A to 23D. Note that one pooling processing unit 22C may be provided for each of the ALUs 23A to 23D.
[0082] The arithmetic control unit 18 sequentially stores the multiple third row data R3 that constitute the image data P3 output from the second arithmetic module 12 in the line memory 20C of the third arithmetic module 13. The multiple third row data R3 are included in the multiple third strip-shaped data PS3 that are generated by dividing the image data P3 in the row direction for each third pixel count G3.
[0083] The ALU23A~23D of the third arithmetic module 13 perform a convolution operation on multiple third row data R3. Hereinafter, the convolution operation performed by the third arithmetic module 13 will be referred to as the "third convolution operation".
[0084] Figure 18 illustrates the third convolution process. In Figure 18, R3 i,k This shows the i-th third row data of the k channel read from line memory 20C. i-th third row data R3 i,k This is input to ALU23A. The (i+1)th row of data, R3 i+1,k This is input to ALU23B. The i+2th row of data, row 3, is R3. i+2,k This is input to ALU23C. The i+3th row data, R3 i+3,k This is input to ALU23D.
[0085] Each of the ALU23A~23D performs a third convolution by multiplying the input third row data R3 by weights while performing a pixel shift. ALU23A processes three third row data R3 i,k ,R3 i+1,k ,R3 i+2,kA single third convolution operation is performed in parallel on the three third row data R3. i+1,k ,R3 i+2,k ,R3 i+3,k A single third convolution operation is performed in parallel on the three third row data R3. i+2,k ,R3 i+3,k ,R3 i+4,k A single third convolution operation is performed in parallel on the three third row data R3. i+3,k ,R3 i+4,k ,R3 i+5,k For each of these, a single third convolution operation is performed in parallel.
[0086] The third convolution is the same as the first and second convolutions described above, so a detailed explanation will be omitted.
[0087] The data output from ALU23A~23D is input to the pooling processing unit 22C. The pooling processing unit 22C performs 2x2 pooling processing to obtain the fourth row of data R4, which has a width of the fourth pixel count G4. i,k Outputs multiple fourth-line data R4 output from the pooling processing unit 22C. i,k This constitutes the fourth strip-shaped data PS4. Image data P4 is composed of multiple fourth strip-shaped data PS4s. The fourth pixel count G4 is half the third pixel count G3. Also, image data P4 has more channels than image data P3.
[0088] In this modified example, the third arithmetic module 13 outputs image data P4 to the output unit 5. The output unit 5 classifies image data P1 based on the image data P4 which includes feature quantities.
[0089] Figure 19 conceptually illustrates the first to third feature extraction processes. In the example shown in Figure 19, the second strip-shaped data PS2, generated by performing the first feature extraction process on the first strip-shaped data PS1, has half the number of pixels in both the vertical and horizontal directions, and double the number of channels. Similarly, the third strip-shaped data PS3, generated by performing the second feature extraction process on the second strip-shaped data PS2, has half the number of pixels in both the vertical and horizontal directions, and double the number of channels. Furthermore, the fourth strip-shaped data PS4, generated by performing the third feature extraction process on the third strip-shaped data PS3, has half the number of pixels in both the vertical and horizontal directions, and double the number of channels.
[0090] [Second Embodiment] Next, a second embodiment of the present disclosure will be described. In the inference device according to the second embodiment, a feature extraction unit 4B shown in Figure 20 is used instead of the feature extraction unit 4. The feature extraction unit 4B according to this embodiment constitutes a CNN used for object detection and / or region extraction. For example, the feature extraction unit 4B constitutes a so-called U-Net. In this embodiment, the inference device performs object detection and / or region extraction rather than classification, so image data is output from the output unit 5.
[0091] As shown in Figure 20, the feature extraction unit 4B includes an input data storage unit 10, an encoder 40, a decoder 50, a DRAM 60, and an arithmetic control unit 18. The encoder 40 includes three arithmetic modules 41 to 43. The decoder 50 also includes three arithmetic modules 51 to 53. The number of arithmetic modules in the encoder 40 and the decoder 50 is not limited to three, but may be two or four or more.
[0092] Similar to the first embodiment, the encoder 40 repeatedly performs convolution and pooling operations on the image data P1 as input data. The arithmetic modules 41 to 43 have the same configuration as the first arithmetic module 11, the second arithmetic module 12, and the third arithmetic module 13 described above. Each time the arithmetic modules 41 to 43 sequentially perform convolution and pooling operations, the image size is reduced and the number of channels increases. Since the pooling operation reduces the image size, it is also called downsampling.
[0093] The decoder 50 repeatedly performs upsampling and deconvolution on the image data P4 output by the encoder 40. Unlike the arithmetic modules 41 to 43, the arithmetic modules 51 to 53 are configured to perform deconvolution and upsampling. As the arithmetic modules 51 to 53 sequentially perform deconvolution and upsampling, the image size is increased and the number of channels is reduced.
[0094] Furthermore, the decoder 50 performs a merging process to combine the feature map generated by the encoder 40 with the feature map generated by the decoder 50. The DRAM 60 has a larger data storage capacity than the line memory provided by the arithmetic modules 41 and 42, and temporarily stores the feature maps FM1 and FM2 generated by the arithmetic modules 41 and 42. The DRAM 60 is an example of the "third memory" related to the technology of this disclosure.
[0095] Each time the first convolution process is performed by the arithmetic module 41 and data constituting a part of the feature map FM1 is generated, the generated data is stored in the DRAM 60. Similarly, each time the second convolution process is performed by the arithmetic module 42 and data constituting a part of the feature map FM2 is generated, the generated data is stored in the DRAM 60. The arithmetic control unit 18 supplies the data stored in the DRAM 60 to the arithmetic modules 52 and 53 according to the timing required when the decoder 50 performs the concatenation process.
[0096] Each time a third convolution operation is performed in the arithmetic module 43 and data constituting a part of the feature map FM3 is generated, the generated data is supplied to the arithmetic module 51 of the decoder 50 without going through the DRAM 60. This is because, since the merging process is performed in the arithmetic module 51 after the arithmetic module 43, there is no need to store the data generated in the arithmetic module 43 in the DRAM 60.
[0097] Figure 21 shows an example of the configuration of the arithmetic modules 51 to 53 provided in the decoder 50. Arithmetic module 51 includes a line memory 60A, a deconvolution processing unit 61A, an upsampling processing unit 62A, and a merging processing unit 63A. Arithmetic module 52 includes a line memory 60B, a deconvolution processing unit 61B, an upsampling processing unit 62B, and a merging processing unit 63B. Arithmetic module 53 includes a line memory 60C, a deconvolution processing unit 61C, an upsampling processing unit 62C, and a merging processing unit 63C.
[0098] The arithmetic module 51 receives image data P4 output by the encoder 40. The image data P4 is stored in line memory 60A for each of the multiple line data, and deconvolution processing is performed by the deconvolution processing unit 61A. The number of channels is reduced by the deconvolution processing by the deconvolution processing unit 61A. The upsampling processing unit 62A generates a feature map FM4 by upsampling the data output from the deconvolution processing unit 61A. Upsampling is a process that increases the number of pixels, the opposite of the pooling process described above. In this embodiment, the upsampling processing unit 62A doubles the number of pixels in the vertical and horizontal directions of the image data.
[0099] The size of feature map FM4 is the same as the size of feature map FM3 supplied by encoder 40. The merging unit 63A generates image data P5 by merging feature map FM3 with feature map FM4. For example, the merging unit 63A performs a concat-type merge in which feature map FM3 is added as a channel to feature map FM4.
[0100] The arithmetic module 52 receives image data P5 output by the arithmetic module 51 as input. The arithmetic module 52 performs the same processing on the image data P5 as the arithmetic module 51. The upsampling processing unit 62B generates a feature map FM5 by upsampling the data output from the deconvolution processing unit 61B. The size of the feature map FM5 is the same as the size of the feature map FM2 supplied from the encoder 40 via the DRAM 60. The merging processing unit 63B generates image data P6 by merging the feature map FM2 with the feature map FM5.
[0101] The arithmetic module 53 receives image data P6 output by the arithmetic module 52. The arithmetic module 53 performs the same processing on the image data P6 as the arithmetic module 51. The upsampling processing unit 62C generates a feature map FM6 by upsampling the data output from the deconvolution processing unit 61C. The size of the feature map FM6 is the same as the size of the feature map FM1 supplied from the encoder 40 via the DRAM 60. The merging processing unit 63C generates image data P7 by merging the feature map FM1 with the feature map FM6.
[0102] The image data P7 output by the arithmetic module 53 is input to the output unit 5. The output unit 5 generates and outputs output image data by further performing deconvolution processing on the image data P7. Image data P7 has the same image size as image data P1.
[0103] The arithmetic modules 41 and 42 of the encoder 40 correspond to the "first arithmetic module" and "second arithmetic module" related to the technology of this disclosure, respectively. Furthermore, arithmetic module 41 is the "module for downsampling the first image data" related to the technology of this disclosure. Feature map FM6 corresponds to the "feature image data stored in the third memory" related to the technology of this disclosure. Image data P6 corresponds to the "input image data" related to the technology of this disclosure. Arithmetic module 53 corresponds to the "third arithmetic module for upsampling the input image data" related to the technology of this disclosure. Image data P7 corresponds to the "first image data corrected using the feature image data" related to the technology of this disclosure. The merging of feature maps is an example of "correction" related to the technology of this disclosure.
[0104] Figure 22 conceptually shows the hierarchical structure of the CNN, which consists of an encoder 40 and a decoder 50. Figure 23 illustrates the pipeline processing performed on feature maps FM1 to FM6.
[0105] In pipeline processing, when the first row of feature map FM1 is joined to the first row of feature map FM6, the 18th row of feature map FM1 is generated. Therefore, if the feature extraction unit 4B is not equipped with DRAM 60, it is necessary to retain 18 rows of feature map FM1 when joining the first row of feature map FM1 to the first row of feature map FM6. To store 18 rows of feature map FM1 in the line memory (first memory) of the arithmetic module 41, the storage capacity of the line memory needs to be increased. Similarly, when joining the first row of feature map FM2 to the first row of feature map FM5, it is necessary to retain 8 rows of feature map FM2. To store 8 rows of feature map FM2 in the line memory (second memory) of the arithmetic module 42, the storage capacity of the line memory needs to be increased.
[0106] In this embodiment, the feature maps FM1 and F2 generated by the arithmetic modules 41 and 42 are stored in a DRAM 60 (third memory) with a large data storage capacity, and the necessary rows of data are transferred to the arithmetic modules 52 and 53 at the timing required for the merging process. By providing the DRAM 60 in this way, it becomes unnecessary to increase the storage capacity of the line memory of the arithmetic modules 41 and 42. Note that the DRAM 60 only needs to store the required number of rows of feature maps FM1 and FM2 for the merging process.
[0107] Furthermore, the technology disclosed herein is not limited to digital cameras, but can also be applied to electronic devices such as smartphones and tablet devices that have imaging capabilities.
[0108] Furthermore, various processors can be used for the ALU that performs the convolution operation described above. Similarly, various processors can be used for the arithmetic control unit, pooling unit, and upsampling unit described above. These processors include ICs as well as processors whose circuit configuration can be changed after manufacturing, such as FPGAs. FPGAs include dedicated electrical circuits, which are processors with circuit configurations specifically designed to perform particular processing, such as PLDs or ASICs.
[0109] The descriptions and illustrations presented above are detailed explanations of the technical aspects of this disclosure and are merely examples of the technical aspects. For example, the above descriptions of the structure, function, operation, and effect are examples of the structure, function, operation, and effect of the technical aspects of this disclosure. Therefore, it goes without saying that you may delete unnecessary parts, add new elements, or replace elements in the descriptions and illustrations presented above, as long as you do not deviate from the essence of the technical aspects of this disclosure. Furthermore, in order to avoid confusion and facilitate understanding of the technical aspects of this disclosure, explanations of common technical knowledge and the like that do not require special explanation to enable the implementation of the technical aspects of this disclosure have been omitted from the descriptions and illustrations presented above.
[0110] All documents, patent applications, and technical standards described herein are incorporated by reference to the same extent as if each individual document, patent application, and technical standard were specifically and individually noted to be incorporated by reference.
Claims
1. An inference device that performs inference using machine-learned data, A first calculation module and a second calculation module are provided to perform calculation processes including a convolution process and a pooling process, the first calculation module includes a first memory that stores a plurality of first row data generated by dividing input first image data in a row direction for each first number of pixels, and a plurality of first calculation units that execute a first convolution process on the plurality of first row data; the second calculation module includes a second memory that stores a plurality of second row data generated by dividing the input second image data in the row direction for each second number of pixels, and a plurality of second calculation units that execute a second convolution process on the plurality of second row data; the number of channels of the first image data and the number of channels of the second image data are different from each other, a first number which is the number of the first computing units which execute the first convolution process once in parallel on the plurality of first row data is different from a second number which is the number of the second computing units which execute the second convolution process once in parallel on the plurality of second row data; Reasoning device.
2. The second image data is image data including a feature amount generated by performing the arithmetic processing on the first image data by the first arithmetic module. The inference device of claim 1 .
3. the number of channels of the second image data is greater than the number of channels of the first image data; the first number is greater than the second number; The inference device according to claim 2.
4. the number of pixels to be processed of the second image data input to the second calculation module is smaller than the number of pixels to be processed of the first image data input to the first calculation module; 4. The inference device of claim 3.
5. the arithmetic processing by the first arithmetic module and the arithmetic processing by the second arithmetic module are executed in parallel; The inference device of claim 1 .
6. a data storage unit of the first memory corresponds to the first number of pixels, a size of a filter used in the first convolution process, and a number of channels of a filter used in the first convolution process; The inference device of claim 1 .
7. a data storage unit of the second memory corresponds to the second number of pixels, a size of a filter used in the second convolution process, and a number of channels of a filter used in the second convolution process; 7. The inference apparatus of claim 6.
8. the number of filters used in the second convolution process is greater than the number of filters used in the first convolution process; 8. The inference apparatus of claim 7.
9. The first row data corresponds to a part of rows of the first image data. The inference device of claim 1 .
10. a third memory having a larger data storage capacity than the first memory and the second memory, the third memory storing feature image data including the feature amount generated by the first calculation module; a third arithmetic module for upsampling the input image data; Further equipped with the first calculation module is a module for downsampling the first image data; The third calculation module generates the corrected first image data by upsampling the input image data and using the feature image data stored in the third memory. An inference device according to any one of claims 1 to 9.
