Program, image processing method, and information processing apparatus
By dividing the input image into multiple segmented image data and optimizing the storage and processing methods, the problem of reduced efficiency in image segmentation processing is solved, achieving more efficient image processing and reducing power consumption.
Patent Information
- Application Number
- CN202410154716.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-03-17
- Filing Date
- 2024-02-04
- Publication Date
- 2024-09-20
AI Technical Summary
In image processing, when the size of the input image exceeds the processing capacity of the accelerator, segmentation processing is required, resulting in smaller output images, increasing the number of repeated processing and memory load, and reducing processing efficiency.
By dividing the input image into multiple segmented image data, and determining the reused data area in the memory, optimizing the storage and processing methods, reducing redundant loading and computing overhead, the image segmentation unit, the reused data determination unit and the memory management unit are used together. , ensuring overlapping areas between segmented images and reducing the number of convolution operations.
It effectively reduces the number of image data reads and arithmetic processing, improves processing efficiency, reduces power consumption, and ensures the same final output image size as the result of non-divided image processing.
Smart Images

Figure CN118675035A
Abstract
Description
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority from Japanese Patent Application No. 2023-043132 filed on March 17, 2023, the contents of which are hereby incorporated by reference into this application. Technical Field
[0003] The present invention relates to a program, an image processing method, and an information processing device. Background Art
[0004] One type of neural network used in the field of image processing is CNN (Convolutional Neural Network). For example, a CNN accelerator IP (Intellectual Property) installed in an in-vehicle SoC (System on Chip) for a driving support system, an autonomous driving system, etc. reads an input image onto a built-in memory and repeatedly applies convolution operations and activation function processing to extract (multiple) feature quantities required for image recognition from the input image.
[0005] One publicly available technique is listed below.
[0006] [Patent Document 1] Japanese Unexamined Patent Application Publication No. 2020-5118
[0007] If the size of the input image exceeds the size that the accelerator can process at one time, it is necessary to segment the image and process it. For example, Patent Document 1 discloses a technology in which image data after performing distortion correction processing on a distorted image is stored in a built-in memory, and the image data is read from the built-in memory, and the image data is subjected to filtering processing and image reduction processing. In this technology, the distorted image is segmented and processed while reducing the capacity of the built-in memory. In addition, when performing distortion correction processing after segmenting the distorted image, by considering that the image will become smaller after filtering processing, an overlapping area can be formed in advance between the segmented distorted images. Summary of the invention
[0008] As described above, when a filtering process using pixels surrounding a target pixel for calculations including a convolution operation is performed, the output image becomes smaller than the input image, and as the process is repeated, the final output image becomes smaller. In order to make the final output image obtained by dividing the image and repeating the process become the same as the image obtained by performing the process without dividing the image, it is necessary to perform additional processing only for the number of times the process is repeated for the pixel (s) before the division boundary of the image. For this reason, overhead occurs when loading to the built-in memory and performing arithmetic processing, thereby reducing processing efficiency.
[0009] Other problems and novel features will be apparent from the description of this specification and the accompanying drawings.
[0010] According to the non-transitory computer-readable medium of the present disclosure, which stores a program that enables a computer to execute an image processing method, the image processing method includes: dividing input image data into multiple segmented image data according to the size of a kernel used for image processing, the multiple segmented image data including first segmented image data and second segmented image data having a predetermined overlapping area with the first segmented image data; determining first reused data to be reused when performing image processing on second segmented image data in the first segmented image data; and storing, in a memory, first processed data of a first segmented image obtained by performing image processing on the first segmented image data in an area other than an area storing the first reused data, and allocating the area storing the second segmented image data to be adjacent to the area storing the first reused data.
[0011] According to the present disclosure, an image processing method executed by a computer includes: dividing input image data into multiple segmented image data according to the size of a kernel used for image processing, the multiple segmented image data including first segmented image data and second segmented image data having a predetermined overlapping area with the first segmented image data; determining first reused data to be reused when performing image processing on second segmented image data in the first segmented image data; and storing, in a memory, first processed data of a first segmented image obtained by performing image processing on the first segmented image data in an area other than an area storing the first reused data, and allocating the area storing the second segmented image data to be adjacent to the area storing the first reused data.
[0012] According to the image processing device disclosed in the present invention, it includes: an image segmentation unit, which segments input image data into multiple segmented image data according to the size of the kernel used for image processing, and the multiple segmented image data include first segmented image data and second segmented image data having a predetermined overlapping area with the first segmented image data; a reused data determination unit, which determines the first reused data to be reused when performing image processing on the second segmented image data in the first segmented image data; and a memory management unit, in which, in the memory, first processed data of the first segmented image obtained by performing image processing on the first segmented image data is stored in an area other than an area storing the first reused data, and the area storing the second segmented image data is allocated to be adjacent to the area storing the first reused data.
[0013] The present disclosure can provide a program, an image processing method, and an image processing device that can suppress a decrease in efficiency when performing a filter process by dividing an image. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1is a block diagram showing a configuration example of an image processing apparatus according to the first embodiment.
[0015] Figure 2 is a diagram for explaining one example of the image processing method according to the first embodiment.
[0016] Figure 3 is a diagram showing a state in which a first divided image obtained by dividing an input image into three is loaded into a storage unit.
[0017] Figure 4 is a diagram showing a state in which first processed data obtained by performing a first convolution operation on a first divided image is stored in a storage unit.
[0018] Figure 5 is a diagram showing a state in which second processed data obtained by performing a second convolution operation on a first divided image is stored in a storage unit.
[0019] Figure 6 is a diagram showing a state in which a second divided image obtained by dividing an input image into three is loaded into a storage unit.
[0020] Figure 7 is a diagram showing a state in which first processed data obtained by performing a first convolution operation on a second divided image is stored in a storage unit.
[0021] Figure 8 is a diagram showing a state in which second processed data obtained by performing a second convolution operation on a second divided image is stored in a storage unit.
[0022] Fig. 9 is a diagram showing a configuration example of an image processing apparatus according to the second embodiment.
[0023] Fig.10 is a diagram showing one example of an image processing method according to the second embodiment.
[0024] Fig.11 It is a diagram for explaining a comparative example. DETAILED DESCRIPTION
[0025] Embodiments of the present disclosure will be described below with reference to the accompanying drawings. Note that since the accompanying drawings are simplified, the technical scope of the present disclosure should not be narrowly interpreted based on the descriptions in the accompanying drawings. In addition, in each of the accompanying drawings, the same elements are given the same reference numerals, and their overlapping descriptions will be omitted. It should be noted that for ease of explanation, the accompanying drawings are not drawn to actual scale.
[0026] In the embodiments described below, for convenience, when necessary, the present invention will be described in multiple chapters or embodiments. However, unless otherwise stated, these chapters or embodiments are not independent of each other, and as a modified example, detail or supplementary explanation thereof, one chapter or embodiment relates to all or part of another chapter or embodiment. In addition, in the embodiments described below, when the number of elements (including number, value, amount, range, etc.) is involved, the number of elements is not limited to a specific number, unless otherwise stated or except in principle where the number is clearly limited to a specific number, and a number greater than or less than a specified number is also applicable.
[0027] Furthermore, in the embodiments described below, it is needless to say that components (including operation steps, etc.) are not always indispensable unless otherwise stated or unless the components are obviously indispensable in principle. Similarly, in the embodiments described below, when the shapes of components, their positional relationships, etc. are mentioned, substantially approximate and similar shapes, etc. are included therein unless otherwise stated or unless it can be imagined that they are obviously excluded in principle. The same is true for the above-mentioned numerical values (including numbers, values, amounts, ranges, etc.) and ranges.
[0028] As an example, an image processing device according to an embodiment relates to an image recognition accelerator that performs image recognition processing by using a convolutional neural network (CNN). First, CNN will be explained. CNN is a feedforward neural network for processing data with a grid-type topology, such as image data. CNN has a convolution processing layer and a fully connected layer, the convolution processing layer applies filtering to the image data to be processed and extracts feature points of the image to be processed, and the fully connected layer converts the image data in a two-dimensional array into one-dimensional array data and determines what the image data to be processed indicates.
[0029] The convolution processing layer has a structure in which two types of layers (convolution layer and pooling layer) are alternately stacked. The input image data to the convolution layer can be represented by a H×W×C tensor. Here, H, W, and C respectively indicate the height, width, and number of channels of the input image data. In the convolution layer, arithmetic processing using a filter called a kernel is performed on such input image data, and intermediate image data called a feature map is generated. The generated intermediate image data is sent to the subsequent layer, and arithmetic processing is further performed on it.
[0030] As described above, when the convolution process is performed, the output image is smaller than the input image, and each time the process is repeated, the final output image becomes smaller. Fig.11The size of the output image when the convolution process is performed twice without dividing the input image is shown. For example, when the kernel size is 3×3, each time the convolution process is performed once, the output image is reduced by one line from the top, bottom, right, and left of the input image, that is, two lines are reduced in the vertical and horizontal directions. Therefore, when the convolution process is performed twice, the length and width of the input image are reduced by four lines each.
[0031] When the image is segmented and processed, in order to obtain Fig.11 The output images in , are the same size as the output images in , considering that the image becomes smaller after the convolution process, so the overlap area between the segmented images is required. That is, the pixels beyond the image segmentation boundary must be processed additionally only by the number of repeated convolution processes.
[0032] For example, consider a case where an input image has a size of 100×100 and five convolution processes are performed by using a 3×3 kernel. In this case, first, the 100×100 input image is read into the built-in memory. If the image is not segmented, the first intermediate image becomes 98×98, the second intermediate image becomes 96×96, the third intermediate image becomes 94×94, the fourth intermediate image becomes 92×92, and the final output image becomes 90×90. In this case, a total of 10,000 pixels are loaded into the built-in memory, and the number of convolution operations becomes 44,220.
[0033] In contrast, when the image is split into two, data of 100×55 as the first input image and 100×55 as the second input image are read into the built-in memory. For each of the first input image and the second input image, the first intermediate image becomes 98×53, the second intermediate image becomes 96×51, the third intermediate image becomes 94×49, and the fourth intermediate image becomes 92×47, and the final output image becomes 90×90, which is a combination of two 90×45 data. In this case, a total of 11,000 pixels are loaded into the built-in memory, which is an increase of 10% compared to the case where the input image is not split. In addition, the number of convolution operations at this time is 46,140 times, which is an increase of about 4.3% compared to the case where the input image is not split.
[0034] In this way, if the number of loads to the built-in memory and the number of arithmetic operations increase and the processing efficiency decreases, this leads to an increase in power consumption. This problem is not limited to the convolution process, but is similarly applicable to other filtering processes such as averaging processing using pixels around the target pixel. Therefore, in order to reduce the number of times image data is read and the number of arithmetic processes, the inventors devised the following configuration.
[0035] First embodiment
[0036] Reference Figure 1 and Figure 2 An image processing apparatus 10 according to the first embodiment is described. Figure 1 is a block diagram showing a configuration example of an image processing apparatus according to the first embodiment. Figure 2 is a diagram for explaining one example of the image processing method according to the first embodiment.
[0037] like Figure 1 As shown, in the process related to the convolutional neural network, the image processing device 10 performs convolution processing in which a predetermined kernel is applied to an input image. The image processing device 10 divides the input image data to be processed input from the outside into a plurality of divided image data and processes them. The image processing device 10 includes at least an image segmentation unit 1, a reused data determination unit 2, and a memory management unit 3.
[0038] Specifically, in addition to these components, the image processing device 10 includes an input image specifying unit 11, an image processing type specifying unit 12, a kernel selecting unit 13, a transfer condition determining unit 14, a data transfer unit 15, a storage unit 16, and an arithmetic processing unit 17. Figure 1 In the example shown, the external memory 20 is shown as one of the external components used by the image processing device 10. The external memory 20 is, for example, a nonvolatile memory such as a flash memory, or a volatile memory such as a DDR-DRAM (Double Data Rate-Dynamic Random Access Memory). The external memory 20 stores input images and output images.
[0039] The input image designation unit 11 designates the size (H, W), header address, and data format of the input image data to be processed, and transmits the designated information to the image segmentation unit 1. The data format is a data recording method, and is sometimes also referred to as a file format. The data format of the input image data includes, for example, JPG (Joint Photographic Experts Group), GIF (Graphics Interchange Format), PNG (Portable Network Graphics), etc.
[0040] The image processing type specifying unit 12 specifies the type of image processing applied to the input image data to be processed, and sends the specified information to the kernel selecting unit 13 and the arithmetic processing unit 17. Here, it is assumed that the image processing type specifying unit 12 has specified a process in which a convolution process using a 3×3 kernel is performed twice as an example of the image processing type. Note that various specifications of the input image specifying unit 11 and the image processing type specifying unit 12 may be input from the outside, or may be set in advance.
[0041] The kernel selection unit 13 selects a kernel size for calculation according to the type of image processing specified by the image processing type specification unit 12. For example, the kernel selection unit 13 may select an appropriate convolution kernel size for performing feature detection. Here, a 3×3 kernel is selected to perform convolution processing.
[0042] The image segmentation unit 1 segments the input image data into a plurality of segmented image data including adjacent first segmented image data and second segmented image data. The image segmentation unit 1 may segment the input image data based on limitations such as the size of a built-in memory storing the input image data and / or an upper limit on the amount of data that can be processed at one time by the arithmetic processing unit 17 that performs convolution processing related to hardware (this will be explained later). Note that the segmentation method of the input image data may be determined based not only on one of these conditions but also on a combination of a plurality of conditions.
[0043] In addition, the size of the kernel affects the way the input image data is divided, but the size of the kernel is very small compared to the size of the input image. For this reason, the kernel size can be determined based on the size of the built-in memory, the processing power of the arithmetic processing unit 17, etc., after determining the large division method of the input image data, and determining the fine division method such as the adjustment of the number of pixels of the boundary portion between the plurality of divided image data and the calculation of the reused data described later.
[0044] like Figure 2 Here, an example will be described in which an input image is divided into three according to the upper limit of the image size that can be stored in the storage unit 16. It is assumed that the input image divided into three is a first divided image, a second divided image, and a third divided image.
[0045] As described above, when an image is segmented and processed, considering that the image will become smaller after the convolution process, an overlapping area is required between the segmented images. Therefore, depending on the size of the kernel used in the convolution process and the number of convolution processes, an overlapping area between the first segmented image and the second segmented image, and between the second segmented image and the third segmented image is provided. As in the first embodiment, when the input image is segmented into three and the convolution process is performed twice by using a 3×3 kernel, it is necessary to provide two lines of overlapping areas between the first segmented area and the second segmented area, and between the second segmented area and the third segmented area, respectively.
[0046] In this case, between the data loaded into the built-in memory when the first convolution process is performed on the first segmented image and the data loaded when the first convolution process is performed on the second segmented image, there is a load overhead portion of two rows to be redundantly loaded. In addition, some of the data after the first convolution process is performed on the first segmented image overlaps with the data after the first convolution process is performed on the second segmented image, so there is a calculation overhead portion. Similarly, these load overhead portions and calculation overhead portions also exist between the second segmented image and the third segmented image. In this embodiment, the following processing is performed to reduce these load overhead portions and calculation overhead portions.
[0047] The image segmentation unit 1 calculates the size of each segmented image data based on the segmentation method of the input image determined according to the size of the input image data and the upper limit of the image size that can be stored in the storage unit 16, and can determine the data to be read from the external memory.
[0048] The reuse data determination unit 2 determines the first reuse data to be reused from the first segmented image data when performing image processing on the second segmented image data after performing image processing on the first segmented image data. The reuse data determination unit 2 may calculate the size of the reuse data to be reused from the respective segmented image data based on the segmentation method of the input image and the size of each segmented image.
[0049] The size of the reused data can be calculated by considering the data load and the Figure 2 The size of the reused data is determined by the area (overhead portion) where the operations described in . The size of the reused data is determined based on the positional relationship between the annotation pixels and the peripheral pixels used to process the annotation pixels, in other words, based on the kernel size. For example, if the kernel size used in the convolution processing is 3×3, the size of the reused data can be set to two rows from the bottom of the segmentation boundary. Note that, as Figure 2 As shown, the segmentation boundary refers to the boundary between processed images of corresponding segmented images in the final output image.
[0050] The memory management unit 3 allocates an area for storing the second divided image data to the built-in memory described later to be adjacent to the area for storing the first reused data of the first divided image data. In response to a request from the transfer condition determination unit 14, the memory management unit 3 can return the head address of the area allocated on the storage unit 16.
[0051] The transfer condition determination unit 14 determines conditions regarding data transfer between the external memory 20 and the storage unit 16, and between the storage unit 16 and the arithmetic processing unit 17. Specifically, the transfer condition determination unit 14 refers to the size of each divided image data or the size of reused data, and determines the transfer condition so that each data is stored in the area of the storage unit 16 allocated by the memory management unit 3.
[0052] The data transfer unit 15 performs data transfer between the external memory 20 and the storage unit 16, and between the storage unit 16 and the arithmetic processing unit 17 based on the transfer condition sent from the transfer condition determination unit 14. The arithmetic processing unit 17 performs arithmetic processing required for the image processing specified by the image processing type specification unit 12. Here, the arithmetic processing unit 17 can perform convolution processing using the above-mentioned 3×3 kernel.
[0053] The storage unit 16 is a built-in memory that temporarily stores the above-mentioned segmented image data and processed data obtained by performing convolution processing on the segmented image data. The storage unit 16 may be configured with a volatile memory such as an SRAM (Static Random Access Memory).
[0054] The image processing device 10 includes a processor and a memory as components not shown. The memory stores a program that causes the computer to execute each process of the image processing method according to the first embodiment. The processor reads the program from the memory and executes the program. This enables the processor to implement Figure 1 The illustrated one includes each function of an image segmentation unit 1 , a reused data determination unit 2 , and a memory management unit 3 .
[0055] When a large number of fixed operations are performed as in the above-mentioned convolution processing, it is preferred to process specific operations in hardware like an accelerator. That is, each component in the image processing device 10 can be implemented by dedicated hardware. This makes it possible to shorten the calculation time. In addition, part or all of each component of each device can be implemented by a general or dedicated circuit device (circuitry), a processor, etc., or a combination thereof. These can be configured by a single chip or multiple chips connected via (multiple) buses. Part or all of each component of each device can be implemented by a combination of the above-mentioned circuit devices, etc. and programs. In addition, a CPU (central processing unit), a GPU (graphics processing unit), an FPGA (field programmable gate array), a quantum processor (quantum computer control chip), etc. can be used as a processor.
[0056] In addition, in the case where a part or all of each component in the image processing device 10 is implemented by a plurality of devices, circuit devices, etc., the plurality of devices and circuit devices, etc. may be centrally arranged or dispersed and arranged. The devices, circuit devices, etc. that implement each component may be implemented as a client-server system, a cloud computing system, etc., and may be implemented in a form in which each is connected via a communication network. In addition, the functions of the image processing device 10 may be provided in a SaaS (Software as a Service) format.
[0057] Next, the operation of the image processing device 10 when an input image is divided and convolution processing is repeatedly performed will be described. Figures 3 to 8 Each shows Figure 2 The state in which the image data related to each process in the flow of the image processing method shown is stored in the storage unit 16 (built-in memory). Here, as an example, the following case is assumed: the size of the input image data is 100×148, the input image is divided into three, and the convolution process is performed twice, and the size of the final output image is 96×144. In addition, as an example, it is assumed that the storage unit 16 has a two-dimensional storage area of 64 rows with a width of 128 pixels and can store data in a wrap-around format.
[0058] exist Figures 3 to 8 , the address in the x direction increases as it moves to the right, and the address in the y direction increases as it moves downward. In the following, the data storage location is indicated by the (x, y) coordinate. Note that the format of the storage area of the storage unit 16 is not limited to this. For example, the storage unit 16 may have a one-dimensional storage area.
[0059] First, the input image designation unit 11 designates the size, header address, and data format of the input image data, and the image processing type designation unit 12 designates the type of image processing to be performed. As described above, here, it is assumed that a process of performing a convolution process twice using a 3×3 kernel is designated. Based on this, the kernel selection unit 13 selects a kernel size of 3×3.
[0060] Then, the image segmentation unit 1 determines whether the input image data can be stored in the storage unit 16. When the image segmentation unit 1 determines that the input image data needs to be segmented, such as Figure 2 As shown, it divides the input image into three, that is, the first divided image data to the third divided image data. Figure 2 , from the top of the input image, the first segmented image is set to Tile 1, the second segmented image is set to Tile 2, and the third segmented image is set to Tile 3. In the following, the first segmented image data is set to Tile 1 data, the second segmented image data is set to Tile 2 data, and the third segmented image data is set to Tile 3 data.
[0061] Here, it is assumed that tiles 1 to 3 are all segmented into the same size (100×52). However, the sizes of the multiple segmented images do not necessarily have the same size. For example, only one segmented image among the multiple segmented images may be smaller or larger than the other segmented images, or each segmented image in the multiple segmented images may have a different size.
[0062] By performing the first convolution process, the size of each tile changes from 100×52 to 98×50. In addition, by performing the second convolution process, the size of each tile changes from 98×50 to 96×48. Thus, the reuse data determination second unit determines the size 100×2 as the first reuse data, and determines the size 98×2 as the second reuse data.
[0063] Tile 1 Processing
[0064] After the reuse data determination unit 2 determines the size of each reuse data, the subsequent process is performed. First, in order to read the tile 1 data from the external memory 20 into the storage unit 16, the memory management unit 3 allocates an area for storing the tile 1 data to be processed in the storage unit 16. Since there is no allocated area in the storage unit 16 before processing the tile 1, the memory management unit 3 allocates an area of 100×52 pixels from the head (0,0) of the storage unit 16 as the storage destination of the tile 1 data.
[0065] In addition, the memory management unit 3 marks the data of the last 100×2 pixels as the first reused data of tile 1. That is, the memory management unit 3 sets the data stored in the (0,50) to (99,51) area of the storage unit 16 as the first reused data of tile 1. The transfer condition determination unit 14 determines the transfer condition so that the tile 1 data is stored in the area of the storage unit 16 allocated by the memory management unit 3.
[0066] Based on the transfer condition, the data transfer unit 15 reads the tile 1 data from the external memory 20 and stores it in the allocated area on the storage unit 16 . Figure 3 The state in which the tile 1 data is loaded into the storage unit 16 is shown. This state is referred to as state (A). In state (A), the tile 1 first reused data is indicated by a dotted box. The tile 1 first reused data corresponds to the reused portion of the input image data loaded from the external memory 20.
[0067] Then, the arithmetic processing unit 17 reads the tile 1 data from the storage unit 16 by using the data transfer unit 15, performs the operation (s) required for the first convolution process using the 3×3 kernel, and generates the tile 1 first processed data. The memory management unit 3 allocates an area for storing the tile 1 first processed data. At this time, if the tile 1 first processed data is stored in the same position as the tile 1 data ((1,1) to (98,50)), the tile 1 first reused data stored in (0,50) to (99,51)1 is overwritten.
[0068] Therefore, in the storage unit 16, the tile 1 first processing data is stored in an area other than the area for storing the tile 1 first reused data. This makes it possible to prevent the tile 1 first reused data from disappearing. At this time, it is preferred to rewrite and store at least a part of the tile 1 first processing data, that is, the area storing the tile 1 data. This makes it possible to reduce the storage capacity of the storage unit 16.
[0069] Figure 4 FIG. 1 shows a state in which the first processed data of block 1 is stored in the storage unit 16. This state is referred to as state (B). Figure 4 As shown, the tile 1 first processed data may be stored in, for example, an area (1,0) to (98,49) shifted upward by one line in the y direction from the same position ((1,1) to (98,50)) as the position of the tile 1 data before the processing of the tile 1 first processed data. In state (B), the tile 1 second reused data is indicated by a dotted box. The tile 1 second reused data corresponds to a reused portion of the processing result obtained by performing the first convolution processing.
[0070] In addition, the memory management unit 3 marks the last 98×2 pixels of the first processed data of the tile 1 as the second reused data of the tile 1. That is, the memory management unit 3 sets the data stored in the area (1, 48) to (98, 49) of the storage unit 16 as the second reused data of the tile 1.
[0071] The transfer condition determination unit 14 determines the transfer condition so that the tile 1 first processed data is stored in the area of the storage unit 16 allocated by the memory management unit 3. The data transfer unit 15 stores the tile 1 first processed data in the allocated area on the storage unit 16 based on the transfer condition.
[0072] Thereafter, the arithmetic processing unit 17 reads the tile 1 first processing data from the storage unit 16 using the data transfer unit 15, performs the operation(s) required for the second convolution process using the 3×3 kernel, and generates the tile 1 second processing data. The memory management unit 3 allocates an area for storing the tile 1 second processing data in the storage unit 16. Similar to the above, if the tile 1 second processing data is stored in the same location as the tile 1 first processing data, the tile 1 reused data is overwritten.
[0073] Therefore, in the storage unit 16, the tile 1 second processed data is stored in an area other than the area storing the tile 1 first reused data and the tile 1 second reused data. In addition, it is preferred that at least a part of the tile 1 second processed data is rewritten and stored in the area storing the tile 1 first processed data. This makes it possible to reduce the storage capacity of the storage unit.
[0074] The transfer condition determination unit 14 determines transfer conditions such that the tile 1 second process data is stored in the area of the storage unit 16 allocated by the memory management unit 3. The data transfer unit 15 stores the tile 1 second process data in the area allocated on the storage unit 16 based on the transfer conditions.
[0075] Figure 5 FIG. 1 shows a state in which the second processed data of block 1 is stored in the storage unit 16. This state is referred to as state (C). Figure 5 As shown, the second processed data of tile 1 is stored, for example, in an area from (2,0) to (97,47) that is offset upward by one row in the y direction from the same position ((2,1) to (97,48)) as the position of the first processed data of tile 1 before processing the second processed data of tile 1.
[0076] Note that in the first embodiment, since the convolution process is completed twice, no reuse data is set in the second processed data of the tile 1. However, if the process is to be further continued, the same process as the above process can be repeated. For example, the storage area of the processed data in the storage unit 16 can be set to an area that is shifted upward by one row in the y direction from the storage area of the unprocessed data.
[0077] Thereafter, the data transfer unit 15 writes the second processed data of the tile 1 stored in the storage unit 16 into the head 96×48 portion of the area of the external memory 20 storing the output image. Thus, the processing of the tile 1 is completed.
[0078] Processing Tile 2
[0079] After the processing result of tile 1 is stored in the external memory 20, the processing of tile 2 is performed. In the process of the second tile and subsequent tiles, when data is stored in the storage unit 16, it is necessary to couple it with the reused data that has been saved. Therefore, the memory management unit 3 allocates an area for storing data to be processed in the storage unit 16 from an address adjacent to the lower end of the corresponding reused data.
[0080] The tile 2 data to be read from the external memory 20 into the storage unit 16 will be considered. The storage unit 16 has already stored the tile 1 first reused data which is the reused portion of the loaded input image data and the tile 1 second reused data which is the reused portion of the processing result. Therefore, in the first convolution processing of tile 2, 100×48 tile 2 data is required to be input, and 100×50 image data obtained by adding the tile 1 first reused data to this data becomes the target to be processed. The convolution processing is performed on this 100×50 image data, and 98×48 tile 2 first processed data is generated.
[0081] In the second convolution processing of tile 2, the image data 98×50 obtained by adding the 98×2 tile 1 second processing data to the 98×48 tile 2 first processing data becomes the target to be processed. The convolution processing is performed on this 98×50 image data, and 96×48 second processing data is generated.
[0082] The image segmentation unit 1 refers to the segmentation method of the input image data as described above, and determines to read the 100×48 Tile 2 data coupled with the 100×2 first reused data. The memory management unit 3 allocates an area in the storage unit 16 for storing the Tile 2 data. As described above, the storage unit 16 has a two-dimensional storage area of 64 rows with a width of 128 pixels, and can store data in a wraparound format. To this end, the memory management unit 3 allocates 12 rows of (0,52) to (99,63) adjacent to the lower end of (0,50) to (99,51) as the upper 100×12 storage destination of the Tile 2 data.
[0083] Furthermore, the memory management unit 3 allocates the 36 row heads (0,0) to (99,35) of the storage unit 16 as the lower 100×36 storage destinations of the tile 2 data. In this way, the area of 48 rows and 100×48 pixels spanning the two positions of the lower end and the upper end of the storage unit 16 becomes the storage destination of the tile 2 data. Note that the data transfer unit 15 can wrap around the two areas divided into the lower end and the upper end of the storage unit 16 and access them as one continuous area.
[0084] In addition, the memory management unit 3 marks the data of the last 100×2 pixels as the first reused data of Tile 2. That is, the memory management unit 3 sets the data stored in the (0,34) to (99,35) area of the storage unit 16 as the first reused data of Tile 2. The transfer condition determination unit 14 determines (multiple) transfer conditions so that the Tile 2 data is stored in the area of the storage unit 16 allocated by the memory management unit 3. Based on the transfer condition, the data transfer unit 15 reads the Tile 2 data from the external memory 20 and stores it in the area allocated on the storage unit 16. Figure 6 The state in which the tile 2 data is loaded into the storage unit 16 is shown. This state is referred to as state (D). In state (D), the tile 2 first reused data is indicated by a dotted line frame.
[0085] Then, the arithmetic processing unit 17 reads the tile 2 data from the storage unit 16 by using the data transfer unit 15, performs the (multiple) operations required for the first convolution processing using the 3×3 kernel, and generates the tile 2 first processing data. The memory management unit 3 allocates an area for storing the tile 2 first processing data in the storage unit 16. In the subsequent second convolution processing of tile 2, the tile 1 second reused data from (1, 48) to (98, 49) of the storage unit 16 is used. Therefore, the memory management unit 3 allocates the storage area for the tile 2 first processing data to the 14 rows (1, 50) to (98, 63) adjacent to the lower end of the storage area for the tile 1 second reused data of the storage unit 16, and to the 34 rows (1, 0) to (98, 33) of the head row, that is, to a total of 48 rows.
[0086] In addition, the memory management unit 3 marks the last 98×2 pixels of the first processed data of the tile 2 as the second reused data of the tile 2. That is, the memory management unit 3 sets the data stored in the area (1, 32) to (98, 33) of the storage unit 16 as the second reused data of the tile 2.
[0087] The transfer condition determination unit 14 determines transfer conditions such that the tile 2 first process data is stored in the area of the storage unit 16 allocated by the memory management unit 3. The data transfer unit 15 stores the tile 2 first process data in the area allocated on the storage unit 16 based on the transfer conditions. Figure 7 The state in which the first processed data of the tile 2 is stored in the storage unit 16 is shown. This state is referred to as state (E). In state (E), the second reused data of the tile 2 is indicated by a dotted-line frame.
[0088] Thereafter, the arithmetic processing unit 17 reads the tile 2 first processed data from the storage unit 16 using the data transfer unit 15, performs the (multiple) operations required for the second convolution process using the 3×3 kernel, and generates the tile 2 second processed data. The memory management unit 3 allocates an area for storing the tile 2 second processed data in the storage unit 16. The tile 1 second processed data may be stored in an area other than an area storing the tile 2 first reused data and the tile 2 second reused data in the storage unit 16. Furthermore, it is preferred that at least a portion of the tile 2 second processed data is rewritten and stored in an area storing the tile 2 first processed data.
[0089] The transfer condition determination unit 14 determines the transfer condition so that the tile 2 second process data is stored in the area of the storage unit 16 allocated by the memory management unit 3. The data transfer unit 15 stores the tile 2 second process data in the area allocated on the storage unit 16 based on the transfer condition.
[0090] Figure 8 FIG. 2 shows a state in which the second processed data of block 2 is stored in the storage unit 16. This state is referred to as state (F). Figure 8 As shown, the second processed data of the tile 2 can be stored in, for example, 16 rows of (2, 48) to (97, 63) and 32 rows of the head row (2, 0) to (97, 31) of the storage unit 16, that is, a total of 48 rows and a 96×48 area. Note that, as described above, in the first embodiment, since those processes are completed by two convolution processes, reused data is not set in the second processed data of the tile 2.
[0091] Thereafter, the data transfer unit 15 writes the second processed data of the tile 2 stored in the storage unit 16 into the middle 96×48 portion of the area for storing the output image of the external memory 20. Thus, the processing of the tile 2 is completed.
[0092] Processing of tile 3
[0093] Description of the processing (s) of tile 3 will be omitted because tile 3 is the same as the processing of tile 2 except that reused data is not set. Note that the data transfer unit 15 writes the tile 3 second processing data stored in the storage unit 16 to the terminal 96×48 portion of the area for storing the output image in the external memory 20. Therefore, when the image is divided into three and the convolution processing is repeated twice, a final output image of the same size as that when the image is processed without being divided can be obtained.
[0094] Here, when the input image size is X×Y and is divided into N tiles in the Y direction and the convolution process using a 3×3 kernel is repeated C times, the number of convolution processes and the data loading amount will be described.
[0095] When data is not reused, the number of necessary convolution processes Z required is expressed by the following formula (1).
[0096] [Mathematical formula 1]
[0097]
[0098] …(1)
[0099] In addition, the data load L at this time is expressed by the following formula (2).
[0100] L=X×(Y+2×C)…(2)
[0101] Meanwhile, in the case of an embodiment of reusing data, the number of times Z of necessary convolution processing is expressed by the following formula (3).
[0102] [Mathematical formula 2]
[0103]
[0104] …(2)
[0105] In addition, the data load L at this time is expressed by the following formula (4).
[0106] L=X×Y…(4)
[0107] For example, when 100×100 image data is split into two and convolution processing using a 3×3 kernel is performed five times, in the image processing device according to the first embodiment, the number of pixels loaded into the built-in memory is reduced by approximately 9.1%, and the number of convolution operations is reduced by 4.1%, compared to the case where reused data is not used.
[0108] As described above, according to the first embodiment, when an input image is divided into adjacent first and second divided images, and they are sequentially stored in the built-in memory and image processing is performed thereon, data loaded during the processing of the first divided image and data generated by the image processing can remain in the built-in memory when the processing of the first divided image is ended, and be transferred to the processing of the second divided image. When the second divided image is loaded into the built-in memory or when the image processing that is repeatedly performed is performed, the data is stored so as to be adjacent to the data remaining on the built-in memory, thereby making it possible to process the data as a series of multiple image data including the area without rereading or recalculating from the outside.
[0109] In this way, by designing the data to be arranged in the storage unit 16, the data on the storage unit 16 can be reused, and the number of times the image data is read from another storage unit and the number of calculations can be reduced, so that the processing performance of the CNN accelerator can be improved and the power consumption can be reduced.
[0110] Note that the first arithmetic processing and the second arithmetic processing for the input image data may include (a plurality of) operations that do not involve surrounding pixels and do not involve reduction of the output image. In the operation that does not involve reduction of the output image, the output image data may be written into the area in which the input image data to be processed in the storage unit 16 is stored without setting the reuse data.
[0111] Second embodiment
[0112] Reference Fig. 9 and Fig.10 An image processing apparatus 10 a according to the second embodiment is described. Fig. 9 is a block diagram showing a configuration example of an image processing apparatus according to the second embodiment. Fig.10 2 is a diagram showing one example of an image processing method according to the second embodiment. The second embodiment is different from the first embodiment in that a plurality of surrounding ranges can be set in the storage unit 16.
[0113] In the second embodiment, according to the first embodiment Figure 1 The data transfer unit 15 shown is changed to a data transfer unit 15a that performs data transfer to store each different plurality of data in a surround method in a plurality of surround ranges set by the storage unit 16. Therefore, the area in the storage unit 16 where data is stored can be divided into a plurality of surround ranges that do not overlap with each other. Note that the transfer condition determination unit 14a may have an additional function of determining the surround range in which each data is stored, in addition to the function of determining the above-mentioned transfer condition.
[0114] In the following description, it is assumed that the input image data includes first image data and second image data that are different from each other. For each of the first image and the second image, the following processing is performed: a process of segmenting them into a plurality of segmented image data, a process of determining reused data, and a process of allocating an area storing segmented image data of (multiple) targets to be processed for subsequent processing to be adjacent to an area storing reused data. For example, the first image and the second image can each be segmented into three, that is, segmented into tile 1, tile 2, and tile 3, and processed in the same manner as in the first embodiment. In the second embodiment, the processing results obtained by performing convolution processing on each of the first image data and the second image data are further operated on each other, and an operation result is generated.
[0115] In this case, in the image processing apparatus 10 of the first embodiment, the wrap-around range is fixed, so that a series of convolution processes repeatedly performed on the second image data cannot be performed while the processing results of the first image data are stored in a part of the storage unit 16. In this case, once the convolution processing results of the first image data and the second image data are output to the external memory 20, they need to be read again when performing the inter-image operation (plurality).
[0116] In contrast, in the second embodiment, the inter-image operation can be efficiently performed without inputting or outputting the convolution processing result of the first image data and the second image data to or from the external memory 20. Fig.10 An example of the state of the storage unit 16 is shown after the convolution process is performed twice on each of two input images (first image, second image) and the process results are compared with each other pixel by pixel.
[0117] Fig.10 The example shown shows a state in which the processing results of the tile 2 of the first image and the second image are respectively stored in the first surrounding range and the second surrounding range of the storage unit 16. That is, the second processed data of the tile 2 of the first image is stored in the first surrounding range, and the second processed data of the tile 2 of the second image is stored in the second surrounding range. The second processed data of the tile 2 of the first image is the output image of the tile 2 of the first image, and the second processed data of the tile 2 of the second image is the output image of the tile 2 of the second image.
[0118] The first surrounding range and the second surrounding range each correspond to the first embodiment. Figure 8 The state of memory cell 16 in Fig.10 , description of the first reused data and the second reused data of tile 2 is omitted. In this way, by being able to set different surrounding ranges for the first image and the second image in the storage unit 16, processing of the first image and the second image can be performed without affecting each other.
[0119] In addition, Fig.10In the example shown, the operation result obtained by comparing the second processed data of block 2 of each of the first image and the second image can be stored in the third surrounding range. Specifically, the arithmetic processing unit 17 uses the data transfer unit 15a to read the second processed data of block 2 of the first image from the first surrounding range of the storage unit 16, and reads the second processed data of block 2 of the second image from the second surrounding range, so that the comparison processing can be performed by using them. In addition, the data transfer unit 15a can store a third image as the operation result of the comparison between images in the third surrounding range. For example, in a driving support system, the first image and the second image acquired sequentially over time are compared, and a third image indicating the movement of the same object recognized in the first image and the second image can be generated. The second embodiment can be applied to such an example.
[0120] Furthermore, after the third image is stored in the third surrounding range, a convolution process may be performed on the tile 3 using reused data (not shown) regarding each of the first image and the second image.
[0121] Although the invention made by the inventors has been specifically explained based on the above-described embodiments, the present invention is not limited to the embodiments that have been described, and it goes without saying that various modifications can be made without departing from the scope of the present invention.
[0122] The above-mentioned program includes an instruction group (or software code) that, when loaded into a computer, causes the computer to perform one or more of the functions described in the embodiment. The program can be stored in a non-transitory computer-readable medium or a tangible storage medium. Not by way of limitation but by way of example, a computer-readable medium or a tangible storage medium includes a random access memory (RAM), a read-only memory (ROM), a flash memory, a solid-state drive (SSD) or other memory technology, a CD ROM, a DVD (digital versatile disc), a Blu-ray disc or other optical disc storage, a cassette, a magnetic tape, a disk storage or other magnetic storage device. The program can be transmitted on a temporary computer-readable medium or a communication medium. Not by way of limitation but by way of example, a temporary computer-readable medium or a communication medium includes a propagation signal in an electrical, optical, acoustic or other form.
Claims
1. A non-transitory readable medium storing a program for causing a computer to execute an image processing method, the image processing method comprising: According to the size of the kernel for image processing, the input image data is divided into a plurality of divided image data, the plurality of divided image data including first divided image data and second divided image data, the second divided image data having a predetermined overlapping area with the first divided image data; determining first reused data to be reused when performing the image processing on the second divided image data among the first divided image data; and In the memory, first processed data of the first segmented image obtained by performing the image processing on the first segmented image data is stored in an area other than the area storing the first reused data, and an area storing the second segmented image data is allocated to be adjacent to the area storing the first reused data.
2. The non-transitory computer readable medium according to claim 1, wherein the image processing method further comprises: At least a portion of the first processed data of the first divided image is rewritten and stored in a region of the memory storing the first divided image data.
3. The non-transitory computer readable medium according to claim 1, wherein the image processing method further comprises: determining second reused data to be reused when performing the image processing on the second divided image data to generate the first processed data of the second divided image, among the first processed data of the first divided image; and In the memory, second processed data of the first segmented image obtained by performing the image processing on the first processed data of the first segmented image is stored in an area other than the area storing the first reused data and the area storing the second reused data, and the area storing the first processed data of the second segmented image is allocated to be adjacent to the area storing the second reused data.
4. The non-transitory computer readable medium according to claim 3, wherein the image processing method further comprises: At least a portion of the first processed data of the second divided image is rewritten and stored in a region of the memory storing the second divided image data.
5. The non-transitory computer readable medium of claim 3, The second reused data is used when the image processing is further performed on the first processed data of the second segmented image.
6. The non-transitory computer readable medium according to claim 1, wherein the image processing method further comprises: The first divided image data, data obtained by performing the image processing on the first divided image data, the second divided image data, and data obtained by performing the image processing on the second divided image data are stored in the memory in a wraparound method.
7. The non-transitory computer readable medium of claim 1, wherein the input image data comprises first image data and second image data, and The image processing method further comprises: According to the size of the kernel for image processing, the second image data is divided into a plurality of divided image data, wherein the plurality of divided image data includes third divided image data and fourth divided image data, wherein the fourth divided image data has a predetermined overlapping area with the third divided image data; determining third reused data to be reused when performing the image processing on the fourth divided image data in the third divided image data; and storing, in the memory, first processed data of a third divided image obtained by performing the image processing on the third divided image data in an area other than an area storing the first reused data, and allocating an area storing the fourth divided image data to be adjacent to the area storing the third reused data; storing the first divided image data, data obtained by performing the image processing on the first divided image data, the second divided image data, and data obtained by performing the image processing on the second divided image data in a first surrounding range of the memory in a surrounding method; and In a second surrounding range different from the first surrounding range of the memory, the third segmented image data, the data obtained by performing the image processing on the third segmented image data, the fourth segmented image data, and the data obtained by performing the image processing on the fourth segmented image data are stored in the surrounding method.
8. The non-transitory computer readable medium according to claim 7, wherein the image processing method further comprises: In a third surrounding range different from the first surrounding range and the second surrounding range of the memory, output image data generated by using the third divided image data and the fourth divided image data are stored in the surrounding method.
9. An image processing method executed by a computer, the image processing method comprising: According to the size of the kernel for image processing, the input image data is divided into a plurality of divided image data, the plurality of divided image data including first divided image data and second divided image data, the second divided image data having a predetermined overlapping area with the first divided image data; determining first reused data to be reused when performing the image processing on the second divided image data in the first divided image data; and In the memory, first processed data of the first segmented image obtained by performing the image processing on the first segmented image data is stored in an area other than the area storing the first reused data, and an area storing the second segmented image data is allocated to be adjacent to the area storing the first reused data.
10. The image processing method according to claim 9, further comprising: At least a portion of the first processed data of the first divided image is rewritten and stored in a region of the memory storing the first divided image data.
11. The image processing method according to claim 9, further comprising: determining, in the first processed data of the first divided image, second reused data to be reused when the image processing is performed on the second divided image data to generate the first processed data of the second divided image; and In the memory, second processed data of the first segmented image obtained by performing the image processing on the first processed data of the first segmented image is stored in an area other than the area storing the first reused data and the area storing the second reused data, and the area storing the first processed data of the second segmented image is allocated to be adjacent to the area storing the second reused data.
12. The image processing method according to claim 11, further comprising: At least a portion of the first processed data of the second divided image is rewritten and stored in a region of the memory storing the second divided image data.
13. The image processing method according to claim 11, further comprising: The second reused data is used when the image processing is further performed on the first processed data of the second divided image.
14. The image processing method according to claim 9, further comprising: The first divided image data, data obtained by performing the image processing on the first divided image data, the second divided image data, and data obtained by performing the image processing on the second divided image data are stored in the memory in a wraparound method.
15. The image processing method according to claim 9, wherein the input image data comprises first image data and second image data, and The image processing method further comprises: According to the size of the kernel for image processing, the second image data is divided into a plurality of divided image data, wherein the plurality of divided image data includes third divided image data and fourth divided image data, wherein the fourth divided image data has a predetermined overlapping area with the third divided image data; determining third reused data to be reused when performing the image processing on the fourth divided image data in the third divided image data; and storing, in the memory, first processed data of a third divided image obtained by performing the image processing on the third divided image data in an area other than an area storing the first reused data, and allocating an area storing the fourth divided image data to be adjacent to the area storing the third reused data; storing the first divided image data, data obtained by performing the image processing on the first divided image data, the second divided image data, and data obtained by performing the image processing on the second divided image data in a first surrounding range of the memory in a surrounding method; and In a second surrounding range different from the first surrounding range of the memory, the third segmented image data, the data obtained by performing the image processing on the third segmented image data, the fourth segmented image data, and the data obtained by performing the image processing on the fourth segmented image data are stored in the surrounding method.
16. The image processing method according to claim 15, further comprising: In a third surrounding range different from the first surrounding range and the second surrounding range of the memory, output image data generated by using the third divided image data and the fourth divided image data are stored in the surrounding method.
17. An image processing device, comprising: an image segmentation unit configured to segment the input image data into a plurality of segmented image data according to a size of a kernel for image processing, the plurality of segmented image data including first segmented image data and second segmented image data, the second segmented image data having a predetermined overlapping area with the first segmented image data; a reused data determination unit configured to determine first reused data to be reused when performing the image processing on the second divided image data in the first divided image data; as well as A memory management unit is configured to store, in a memory, first processed data of a first segmented image obtained by performing the image processing on the first segmented image data in an area other than an area storing the first reused data, and to allocate an area storing the second segmented image data to be adjacent to the area storing the first reused data.
18. The image processing device according to claim 17, At least a portion of the first processed data of the first divided image is rewritten and stored in a region of the memory storing the first divided image data.
19. The image processing device according to claim 17, wherein the input image data comprises first image data, wherein the image segmentation unit is configured to segment the second image data into a plurality of segmented image data according to the size of the kernel for image processing, the plurality of segmented image data including the third segmented image data and the fourth segmented image data having a predetermined overlapping area with the third segmented image data, wherein the reused data determination unit is configured to determine the first reused data to be reused when the image processing is performed on the fourth divided image data in the third divided image data, wherein the memory management unit is configured to store, in the memory, first processed data of a third divided image obtained by performing the image processing on the third divided image data in an area other than an area storing the first reused data, and to allocate an area storing the fourth divided image data to be adjacent to the area storing the third reused data, and The memory management unit is configured as follows: storing the first divided image data, data obtained by performing the image processing on the first divided image data, the second divided image data, and data obtained by performing the image processing on the second divided image data in a first surrounding range of the memory in a surrounding method; and In a second surrounding range different from the first surrounding range of the memory, the third segmented image data, the data obtained by performing the image processing on the third segmented image data, the fourth segmented image data, and the data obtained by performing the image processing on the fourth segmented image data are stored in the surrounding method.
20. The image processing device according to claim 19, wherein the memory management unit is configured to store output image data generated by using the third divided image data and the fourth divided image data in the surround method in a third surround range different from the first surround range and the second surround range of the memory.
