Program, image processing method, and image processing apparatus
By dividing images with overlapping areas and managing memory to reuse data, the method enhances processing efficiency and reduces power consumption in convolutional neural network operations.
Patent Information
- Application Number
- JP2023043132
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-03-17
- Publication Date
- 2024-10-01
AI Technical Summary
When processing large images using convolutional neural networks, dividing the image leads to inefficiencies due to increased memory and arithmetic processing overhead, resulting in reduced processing efficiency and increased power consumption.
The image processing method involves dividing the input image into multiple parts with overlapping areas and managing memory to store and process these parts efficiently, reusing data in adjacent memory locations to minimize redundant loading and calculations.
This approach reduces the number of memory loads and arithmetic operations, improving processing efficiency and reducing power consumption while maintaining the output image size.
Smart Images

Figure 2024132391000001_ABST
Abstract
Description
[Technical field]
[0001] The present invention relates to a program, an image processing method, and an image processing device. [Background technology]
[0002] One of the neural networks used in the field of image processing is the convolutional neural network (CNN). For example, a CNN accelerator IP (Intellectual Property) installed in an in-vehicle SoC (System on Chip) used in driver assistance systems and autonomous driving systems loads an input image into the built-in memory and repeatedly applies convolution operations and activation function processing to extract features required for image recognition from the input image.
[0003] When the size of an input image exceeds the size that can be processed at one time by an accelerator, the image needs to be divided and processed. For example, Patent Document 1 discloses a technique in which image data after distortion correction processing of a distorted image is stored in an internal memory, and the image data is read from the internal memory and subjected to filtering and image reduction processing. In this technique, when the capacity of the internal memory is reduced, the distorted image is divided and processed. In addition, when distortion correction processing is performed after dividing a distorted image, an overlapping area is created between the divided distorted images, taking into consideration that the image will be smaller after filtering processing. [Prior art documents] [Patent documents]
[0004] [Patent Document 1] JP 2020-5118 A Summary of the Invention [Problem to be solved by the invention]
[0005] As mentioned above, when performing filter processing such as convolution operations that use pixels surrounding a target pixel in the calculation, the output image is reduced in size compared to the input image, and the more the processing is repeated, the smaller the final output image becomes. In order to ensure that the final output image obtained by dividing an image and repeatedly processing it is the same as that obtained by processing the image without dividing it, the pixels beyond the dividing boundary of the image must be processed as many times as the number of times the processing is repeated. This causes overhead in loading to the internal memory and in the calculation process, reducing the efficiency of the processing.
[0006] Other objects and novel features will become apparent from the description of this specification and the accompanying drawings. [Means for solving the problem]
[0007] The program of the present disclosure causes a computer to execute the following processes: dividing input image data into multiple split image data including first split image data and second split image data having a predetermined overlapping area with the first split image data depending on the size of the kernel used for image processing; determining first reuse data from the first split image data to be reused when performing image processing on the second split image data; and storing in a memory first post-processing data of the first split image obtained by performing the image processing on the first split image data in an area excluding the area in which the first reuse data is stored, and allocating an area for storing the second split image data adjacent to the area in which the first reuse data is stored.
[0008] The image processing method of the present disclosure includes a process in which a computer divides input image data into a plurality of split image data including first split image data and second split image data having a predetermined overlapping area with the first split image data according to the size of a kernel used for image processing, a process in which first reuse data from the first split image data is determined to be reused when performing image processing on the second split image data, and a process in which, in a memory, first post-processing data of the first split image obtained by performing the image processing on the first split image data is stored in an area excluding the area in which the first reuse data is stored, and an area in which the second split image data is stored is allocated so as to be adjacent to the area in which the first reuse data is stored.
[0009] The image processing device of the present disclosure includes an image division unit that divides input image data into a plurality of split image data including first split image data and second split image data having a predetermined overlapping area with the first split image data according to the size of a kernel used for image processing, a reuse data determination unit that determines first reuse data from the first split image data to be reused when performing image processing on the second split image data, and a memory management unit that stores in a memory first post-processing data of the first split image obtained by performing the image processing on the first split image data in an area excluding the area in which the first reuse data is stored, and allocates an area for storing the second split image data adjacent to the area in which the first reuse data is stored. Effect of the Invention
[0010] The present disclosure can provide a program, an image processing method, and an image processing device that can suppress a decrease in efficiency when dividing an image and performing filter processing. [Brief description of the drawings]
[0011] [Figure 1] FIG. 1 is a block diagram showing an example of the configuration of an image processing device according to the first embodiment. [Diagram 2]FIG. 2 is a diagram for explaining an example of the image processing method according to the first embodiment. [Diagram 3] FIG. 3 is a diagram showing a state in which a first divided image obtained by dividing an input image into three parts is loaded into a storage unit. [Figure 4] FIG. 4 is a diagram showing a state in which the first processed data obtained by performing the first convolution operation on the first divided image is stored in the storage unit. [Diagram 5] FIG. 5 is a diagram showing a state in which second processed data obtained by performing a second convolution operation on the first divided image is stored in the storage unit. [Figure 6] FIG. 6 is a diagram showing a state in which the second divided images obtained by dividing the input image into three are loaded into the storage unit. [Figure 7] FIG. 7 is a diagram showing a state in which the first processed data obtained by performing the first convolution operation on the second divided image is stored in the storage unit. [Figure 8] FIG. 8 is a diagram showing a state in which the second processed data obtained by performing the second convolution operation on the second divided image is stored in the storage unit. [Figure 9] FIG. 9 is a diagram illustrating an example of the configuration of an image processing device according to the second embodiment. [Figure 10] FIG. 10 is a diagram illustrating an example of an image processing method according to the second embodiment. [Figure 11] FIG. 11 is a diagram for explaining a comparative example. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0012] Hereinafter, an embodiment of the present disclosure will be described with reference to the drawings. Note that the drawings are simplified, and the technical scope of the present disclosure should not be interpreted narrowly based on the description in the drawings. In addition, in each drawing, the same elements are given the same reference numerals, and duplicated explanations are omitted. Note that, for convenience of explanation, each drawing is not drawn to actual scale.
[0013] In the following embodiments, when necessary for convenience, the description will be divided into multiple sections or embodiments. However, unless otherwise specified, they are not unrelated to each other, and one is a partial or complete modification, application example, detailed explanation, supplementary explanation, etc. of the other. In addition, in the following embodiments, when the number of elements (including the number, numerical value, amount, range, etc.) is mentioned, it is not limited to the specific number, and may be more than or less than the specific number, unless otherwise specified or when it is clearly limited to a specific number in principle.
[0014] Furthermore, in the following embodiments, the components (including operation steps, etc.) are not necessarily essential unless otherwise specified or considered to be clearly essential in principle. Similarly, in the following embodiments, when referring to the shape, positional relationship, etc. of the components, etc., it is intended to include those that are substantially similar or similar to the shape, etc., unless otherwise specified or considered to be clearly not essential in principle. The same applies to the above numbers, etc. (including numbers, numerical values, amounts, ranges, etc.).
[0015] The image processing device according to the embodiment relates to an image recognition accelerator that performs image recognition processing using a convolutional neural network (CNN), as an example. First, CNN will be described. CNN is a feedforward neural network for processing data having a grid-type topology, such as image data. CNN has a convolution processing layer that applies a filter to the image data to be processed to extract feature points of the image to be processed, and a fully connected layer that converts two-dimensional array image data into one-dimensional array data and determines what the image data to be processed indicates.
[0016] The convolution processing layer has a structure in which two types of layers, convolution layers and pooling layers, are alternately stacked. The input image data to the convolution layer can be represented as an H×W×C tensor, where H, W, and C respectively indicate the height, width, and number of channels of the input image data. In the convolution layer, arithmetic processing is performed on such input image data using a filter called a kernel, and intermediate image data called a feature map is generated. The generated intermediate image data is sent to the subsequent layer, where further arithmetic processing is performed.
[0017] As described above, when performing convolution processing, the output image is reduced from the input image, and the final output image becomes smaller the more the processing is repeated. FIG. 11 shows the size of the output image when performing convolution processing twice without dividing the input image. For example, when the kernel size is 3×3, the output image is reduced by one line each from the top, bottom, left, and right of the input image each time convolution processing is performed, that is, by two lines each vertically and horizontally. Therefore, when convolution processing is performed twice, the input image is reduced by four lines each vertically and horizontally.
[0018] When dividing an image for processing, in order to obtain an output image of the same size as the output image in Fig. 11, an overlapping area is required between the divided images, taking into account that the image will become smaller after the convolution process. In other words, the pixels beyond the dividing boundary of the image must be processed extra for each iteration of the convolution process.
[0019] For example, consider the case where the input image size is 100x100 and five convolution processes are performed using a 3x3 kernel. In this case, the 100x100 input image is first loaded into the internal memory. If the image is not divided, the first intermediate image will be 98x98, the second intermediate image will be 96x96, the third intermediate image will be 94x94, and the fourth intermediate image will be 92x92, and the final output image will be 90x90. In this case, a total of 10,000 pixels are loaded into the internal memory, and the number of convolution operations will be 44,220.
[0020] In contrast, when an image is divided into two, 100x55 data is loaded into the built-in memory as the first input image and 100x55 data is loaded into the built-in memory as the second input image. For the first and second input images, the first intermediate image is 98x53, the second intermediate image is 96x51, the third intermediate image is 94x49, and the fourth intermediate image is 92x47, respectively, and the final output image is 90x90, which is a combination of two 90x45 data. In this case, a total of 11,000 pixels are loaded into the built-in memory, which is 10% more than when the input image is not divided. Also, the number of convolution operations is 46,140, which is about 4.3% more than when the input image is not divided.
[0021] In this way, when the number of loads to the built-in memory and the number of calculation processes increase and the efficiency of processing decreases, this causes an increase in power consumption. This problem is not limited to convolution processing, but also applies to other filter processing such as averaging processing in which pixels surrounding a target pixel are used for calculation. Therefore, the present inventors have devised the following configuration to reduce the number of times image data is read and calculation processes are performed.
[0022] Embodiment 1. An image processing device 10 according to the first embodiment will be described with reference to Figs. 1 and 2. Fig. 1 is a block diagram showing an example of the configuration of the image processing device according to the first embodiment. Fig. 2 is a diagram for explaining an example of an image processing method according to the first embodiment.
[0023] As shown in Fig. 1, an image processing device 10 performs convolution processing by applying a predetermined kernel to an input image, among processing related to a convolution neural network. The image processing device 10 divides input image data to be processed, which is input from the outside, into a plurality of divided image data and processes the divided image data. The image processing device 10 includes at least an image dividing unit 1, a reuse data determining unit 2, and a memory management unit 3.
[0024] Specifically, in addition to these components, the image processing device 10 may include an input image designation unit 11, an image processing type designation unit 12, a kernel selection unit 13, a transfer condition determination unit 14, a data transfer unit 15, a storage unit 16, and an arithmetic processing unit 17. In the example shown in Fig. 1, an 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 non-volatile 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.
[0025] The input image specification unit 11 specifies the size (H, W), the starting address and the data format of the input image data to be processed, and transmits the specified information to the image division unit 1. The data format is a data recording method, and may also be called a file format. Examples of the data format of the input image data include JPG (Joint Photographic Experts Group), GIF (Graphics Interchange Format), PNG (Portable Network Graphics), etc.
[0026] The image processing type designation unit 12 designates the type of image processing to be applied to the input image data to be processed, and transmits the designated information to the kernel selection unit 13 and the calculation processing unit 17. Here, it is assumed that the image processing type designation unit 12 designates a process of performing convolution processing using a 3×3 kernel twice as an example of the type of image processing. Note that the various designations made by the input image designation unit 11 and the image processing type designation unit 12 may be input from outside, or may be set in advance.
[0027] The kernel selection unit 13 selects a kernel size to be used 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 can select an appropriate convolution kernel size for feature detection. Here, a 3×3 kernel for performing convolution processing is selected.
[0028] The image division unit 1 divides the input image data into a plurality of divided image data including adjacent first and second divided image data. The image division unit 1 can divide the input image data based on hardware restrictions such as the size of an internal memory that stores the input image data and the upper limit of the number of data that can be processed at one time by the calculation processing unit 17 that executes the convolution process, which will be described later. The division method of the input image data may be determined based on not only one of these conditions but also a combination of multiple conditions.
[0029] In addition, although the size of the kernel affects the division method of the input image data, the size of the kernel is very small compared to the size of the input image. Therefore, after a large division method of the input image data is determined based on the size of the built-in memory and the processing capacity of the arithmetic processing unit 17, the kernel size can be used to determine a fine division method, such as adjusting the number of pixels at the boundary between a plurality of divided image data and calculating reuse data, which will be described later.
[0030] 2, an example will be described in which an input image is divided into three parts in accordance with the upper limit of the image size that can be stored in the storage unit 16. The input image divided into three parts will be referred to as a first divided image, a second divided image, and a third divided image, respectively.
[0031] As described above, when an image is divided and processed, an overlapping area is required between the divided images, considering that the image becomes smaller after the convolution process. Therefore, an overlapping area according to the size of the kernel used in the convolution process and the number of convolution processes is provided between the first divided image and the second divided image, and between the second divided image and the third divided image. When an input image is divided into three and two convolution processes are performed using a 3×3 kernel as in the first embodiment, an overlapping area of two lines must be provided between the first divided image and the second divided image, and between the second divided image and the third divided image.
[0032] In this case, there is a load overhead portion of two lines between the data loaded into the internal memory when performing the first convolution process on the first divided image and the data loaded when performing the first convolution process on the second divided image. Also, a part of the data after performing the first convolution process on the first divided image overlaps with the data after performing the first convolution process on the second divided image, and a calculation overhead portion exists. This load overhead portion and calculation overhead portion also exist between the second divided image and the third divided image. In this embodiment, the following process is performed to reduce this load overhead portion and calculation overhead portion.
[0033] The image division unit 1 can calculate the size of each divided image data and determine the data to be read from the external memory 20 based on a division 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 memory unit 16.
[0034] The reuse data determination unit 2 determines the first reuse data to be reused from the first divided image data when performing image processing on the second divided image data after performing image processing on the first divided image data. The reuse data determination unit 2 can calculate the size of the reuse data to be reused from each divided image data based on the division method of the input image and the size of each divided image.
[0035] The size of the reuse data can be determined taking into consideration the area (overhead portion) where data loading and calculations overlap as described in FIG. 2. The size of the reuse data is determined according to the positional relationship between the pixel of interest and the surrounding pixels used in processing the pixel of interest, in other words, according to the kernel size. For example, when the kernel size used in the convolution process is 3×3, the size of the reuse data can be two lines from the bottom of the division boundary. Note that the division boundary refers to the boundary between the images after processing of each divided image in the final output image, as shown in FIG. 2.
[0036] The memory management unit 3 allocates an area for storing the second divided image data adjacent to an area for storing the first reuse data of the first divided image data in an internal memory described later. The memory management unit 3 can return the start address of the allocated area on the storage unit 16 in response to a request from the transfer condition determination unit 14.
[0037] The transfer condition determination unit 14 determines conditions for 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 piece of divided image data or the size of the reuse data, and determines the transfer conditions so that each piece of data is stored in an area of the storage unit 16 allocated by the memory management unit 3.
[0038] The data transfer unit 15 executes 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 conditions transmitted from the transfer condition determination unit 14. The arithmetic processing unit 17 performs arithmetic processing necessary 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.
[0039] The storage unit 16 is an internal memory that temporarily stores the divided image data described above and processed data obtained by performing a convolution process on the divided image data. The storage unit 16 can be configured of a volatile memory such as a static random access memory (SRAM).
[0040] The image processing device 10 includes a processor and a memory as components not shown. The memory stores a program for causing a 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 realize each function shown in FIG. 1, including the image division unit 1, reuse data determination unit 2, and memory management unit 3.
[0041] When a fixed calculation such as the above-mentioned convolution process is performed a large number of times, it is preferable to process the specific calculation in hardware such as an accelerator. That is, each component of the image processing device 10 may be realized by dedicated hardware. This can shorten the calculation time. Also, a part or all of each component of each device may be realized by a general-purpose or dedicated circuit, processor, etc., or a combination of these. These may be configured by a single chip, or may be configured by multiple chips connected via a bus. A part or all of each component of each device may be realized by a combination of the above-mentioned circuit, etc., and a program. Also, a CPU (Central Processing Unit), a GPU (Graphics Processing Unit), an FPGA (Field-Programmable Gate Array), a quantum processor (quantum computer control chip), etc. may be used as a processor.
[0042] Furthermore, when some or all of the components of the image processing device 10 are realized by a plurality of devices, circuits, etc., the plurality of devices, circuits, etc. may be centrally arranged or distributed. The devices, circuits, etc. that realize the components may be realized in a form in which each is connected via a communication network, such as a client-server system or a cloud computing system. Furthermore, the functions of the image processing device 10 may be provided in a SaaS (Software as a Service) format.
[0043] Next, the operation of the image processing device 10 when the input image is divided and convolution processing is repeatedly performed will be described. Figs. 3 to 8 show a state in which image data for each process is stored in the storage unit 16 (built-in memory) in the flow of the image processing method shown in Fig. 2. Here, as an example, it is assumed that the size of the input image data is 100 x 148, the input image is divided into three, and two convolution processes are performed, resulting in a final output image size of 96 x 144. Also, as an example, the storage unit 16 has a two-dimensional storage area of 64 lines with a width of 128 pixels, and is capable of storing data in a wraparound format.
[0044] 3 to 8, the address in the x direction increases toward the right, and the address in the y direction increases toward the bottom. In the following, the storage position of data is indicated by (x, y) coordinates. Note that the form of the storage area of storage unit 16 is not limited to this. For example, storage unit 16 may have a one-dimensional storage area.
[0045] First, the input image specification unit 11 specifies the size, start address, and data format of the input image data, and the image processing type specification unit 12 specifies the type of image processing to be performed. As described above, it is assumed here that a convolution process using a 3x3 kernel is specified twice. Based on this, the kernel selection unit 13 selects a kernel size of 3x3.
[0046] Then, the image division unit 1 judges whether the input image data can be stored in the storage unit 16. When the image division unit 1 judges that division of the input image data is necessary, it divides the input image into three, first to third divided image data, as shown in Fig. 2. In Fig. 2, from the top of the input image, the first divided image data is Tile 1, the second divided image data is Tile 2, and the third divided image data is Tile 3. Hereinafter, the first divided image data is Tile 1 data, the second divided image data is Tile 2 data, and the third divided image data is Tile 3 data.
[0047] Here, assume that each of Tile1 to Tile3 is divided into the same size (100×52). However, the sizes of the multiple divided images do not necessarily have to be the same. For example, only one of the multiple divided images may be smaller or larger than the other divided images, or each of the multiple divided images may have different sizes.
[0048] Each Tile becomes a size of 98×50 from 100×52 by performing the first convolution process. Also, each Tile becomes a size of 96×48 from 98×50 by performing the second convolution process. From this, the reuse data determination unit 2 determines a size of 100×2 as the first reuse data and a size of 98×2 as the second reuse data.
[0049] <Processing of Tile1> After the reuse data determination unit 2 determines the size of each reuse data, subsequent processing is executed. First, in order to read the Tile1 data from the external memory 20 into the storage unit 16, the memory management unit 3 allocates an area in the storage unit 16 to store the Tile1 data to be processed. Since there is no allocated area in the storage unit 16 before the processing of Tile1, 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 for the Tile1 data.
[0050] Also, the memory management unit 3 marks the data of the last 100×2 pixels as the Tile1 first reuse data. That is, the memory management unit 3 sets the data stored in the area of (0, 50) to (99, 51) of the storage unit 16 as the Tile1 first reuse data. The transfer condition determination unit 14 determines the transfer condition so that the Tile1 data is stored in the area of the storage unit 16 allocated by the memory management unit 3.
[0051] The data transfer unit 15 reads the Tile 1 data from the external memory 20 based on this transfer condition, and stores it in the allocated area on the storage unit 16. The state in which the Tile 1 data is loaded into the storage unit 16 is shown in FIG. 3. This state is called state (A). In state (A), the Tile 1 first reuse data is indicated by a dashed frame. The Tile 1 first reuse data corresponds to the reused portion of the input image data loaded from the external memory 20.
[0052] Then, the calculation processing unit 17 uses the data transfer unit 15 to read the Tile1 data from the storage unit 16, performs calculations necessary for the first convolution process using a 3×3 kernel, and generates the Tile1 first processed data. The memory management unit 3 allocates an area in the storage unit 16 to store the Tile1 first processed data. At this time, if the Tile1 first processed data is stored in the same position as the Tile1 data ((1, 1) to (98, 50)), the Tile1 first reuse data stored in (0, 50) to (99, 51) will be overwritten.
[0053] Therefore, the Tile1 first post-processing data is stored in an area of the storage unit 16 excluding the area in which the Tile1 first reuse data is stored. This makes it possible to prevent the Tile1 first reuse data from being lost. At this time, it is preferable to overwrite and store at least a part of the Tile1 first post-processing data in the area in which the Tile1 data is stored. This makes it possible to reduce the storage capacity of the storage unit 16.
[0054] FIG. 4 shows the state in which the Tile1 first processed data is stored in the memory unit 16. This state is referred to as state (B). As shown in FIG. 4, the Tile1 first processed data can be stored, for example, in an area (1, 0) to (98, 49) shifted one line upward in the y direction from the same position ((1, 1) to (98, 50)) as the Tile1 data before processing the Tile1 first processed data. In state (B), the Tile1 second reuse data is indicated by a dashed frame. The Tile1 second reuse data corresponds to the reused portion of the processing result obtained by performing the first convolution process.
[0055] Furthermore, the memory management unit 3 marks the data of 98 × 2 pixels at the end of the first post-processing data of Tile 1 as the second reusable data of 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 reusable data of Tile 1.
[0056] The transfer condition determination unit 14 determines the transfer conditions so that the Tile1 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 Tile1 first processed data in the allocated area on the storage unit 16 based on the transfer conditions.
[0057] Thereafter, the calculation processing unit 17 uses the data transfer unit 15 to read the Tile1 first processed data from the storage unit 16, performs calculations necessary for the second convolution process using a 3×3 kernel, and generates Tile1 second processed data. The memory management unit 3 allocates an area in the storage unit 16 for storing the Tile1 second processed data. As described above, if the Tile1 second processed data is stored in the same position as the Tile1 first processed data, the Tile1 second reuse data will be overwritten.
[0058] Therefore, the data after the second processing of Tile1 is stored in the storage unit 16 in an area excluding the area where the first reuse data of Tile1 and the second reuse data of Tile1 are stored. Further, it is preferable to overwrite and store at least a part of the data after the second processing of Tile1 in the area where the data after the first processing of Tile1 is stored. Thereby, the storage capacity of the storage unit 16 can be reduced.
[0059] The transfer condition determination unit 14 determines a transfer condition so that the data after the second processing of Tile1 is stored in the area of the storage unit 16 assigned by the memory management unit 3. The data transfer unit 15 stores the data after the second processing of Tile1 in the assigned area on the storage unit 16 based on this transfer condition.
[0060] The state in which the data after the second processing of Tile1 is stored in the storage unit 16 is shown in FIG. 5. This state is referred to as state (C). As shown in FIG. 5, the data after the second processing of Tile1 can be stored, for example, in the area (2, 0) to (97, 47) shifted 1 line upward in the y direction from the same position ((2, 1) to (97, 48)) as the data after the first processing of Tile1 before the second processing of Tile1.
[0061] In the first embodiment, since the processing is completed by two convolution processes, the reuse data is not set in the data after the second processing of Tile1. However, when the processing is further continued, the same processing as described above can be repeated. For example, the storage area of the processed data in the storage unit 16 can be set as an area shifted 1 line upward in the y direction from the storage area of the pre-processed data.
[0062] Thereafter, the data transfer unit 15 writes the data after the second processing of Tile1 stored in the storage unit 16 to the first 96×48 part of the area for storing the output image of the external memory 20. Thereby, the processing for Tile1 is completed.
[0063] <Processing of Tile2> After the processing result of Tile 1 is stored in the external memory 20, processing of Tile 2 is executed. In processing the second and subsequent tiles, when storing data in the storage unit 16, it is necessary to link the data with the reusable data that has already been stored. For this reason, the memory management unit 3 allocates an area in the storage unit 16 for storing the data to be processed, starting from an address adjacent to the bottom end of the corresponding reusable data.
[0064] Consider the Tile2 data to be read from the external memory 20 into the storage unit 16. The storage unit 16 already stores Tile1 first reuse data, which is the reuse portion of the loaded input image data, and Tile1 second reuse data, which is the reuse portion of the processing result. Therefore, in the first convolution process for Tile2, it is necessary to input 100x48 Tile2 data, and the 100x50 image data to be processed is made by adding the Tile1 first reuse data to this. Convolution process is executed on this 100x50 image data, and 98x48 Tile2 first processed data is generated.
[0065] In the second convolution process for Tile2, the 98x50 image data is processed, which is the 98x48 Tile2 first processed data plus the 98x2 Tile1 second processed data. Convolution processing is performed on this 98x50 image data to generate 96x48 second processed data.
[0066] The image division unit 1 refers to the division method of the input image data described above and decides to read the Tile2 data of 100×48 to be linked to the first reuse data of 100×2. The memory management unit 3 allocates an area in the storage unit 16 to store this Tile2 data. As described above, the storage unit 16 has a two-dimensional storage area of 64 lines with a width of 128 pixels, and is capable of storing data in a wrap-around format. For this reason, the memory management unit 3 allocates 12 lines from (0, 52) to (99, 63) adjacent to the bottom end of the Tile1 first reuse data ((0, 50) to (99, 51)) in the storage unit 16 as a storage destination for the upper 100×12 of the Tile2 data.
[0067] Furthermore, the memory management unit 3 allocates the first 36 lines (0,0) to (99,35) of the storage unit 16 as the storage destination for the lower 100x36 of the Tile2 data. In this way, a total of 48 lines, or 100x48 pixel areas across two locations at the bottom and top of the storage unit 16, become the storage destination for the Tile2 data. Note that the data transfer unit 15 can wrap around these two areas at the bottom and top of the storage unit 16 and access them as one continuous area.
[0068] Furthermore, the memory management unit 3 marks the data of the last 100×2 pixels as the Tile2 first reuse data. That is, the memory management unit 3 sets the data stored in the area of the storage unit 16 from (0, 34) to (99, 35) as the Tile2 first reuse data. The transfer condition determination unit 14 determines the transfer conditions so that the Tile2 data is stored in the area of the storage unit 16 allocated by the memory management unit 3. Based on these transfer conditions, the data transfer unit 15 reads the Tile2 data from the external memory 20 and stores it in the allocated area on the storage unit 16. This state in which the Tile2 data is loaded into the storage unit 16 is shown in FIG. 6. This state is called state (D). In state (D), the Tile2 first reuse data is indicated by a dashed frame.
[0069] Then, the calculation processing unit 17 uses the data transfer unit 15 to read the Tile2 data from the storage unit 16, performs calculations necessary for the first convolution process using a 3×3 kernel, and generates Tile2 first-processed data. The memory management unit 3 allocates an area in the storage unit 16 to store the Tile2 first-processed data. In the subsequent second convolution process of Tile2, the Tile1 second reuse data from (1, 48) to (98, 49) in the storage unit 16 is used. For this reason, the memory management unit 3 allocates the storage area for the Tile2 first-processed data to a total of 48 lines, including 14 lines from (1, 50) to (98, 63) adjacent to the bottom end of the storage area for the Tile1 second reuse data in the storage unit 16, and the top 34 lines from (1, 0) to (98, 33).
[0070] In addition, the memory management unit 3 marks the data of 98 × 2 pixels at the end of the Tile 2 first-processed data as the second reusable data of Tile 2. That is, the memory management unit 3 sets the data stored in the areas (1, 32) to (98, 33) of the storage unit 16 as the second reusable data of Tile 2.
[0071] The transfer condition determination unit 14 determines the transfer conditions so that the Tile2 first post-processing 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 Tile2 first post-processing data in the allocated area on the storage unit 16 based on these transfer conditions. The state in which the Tile2 first post-processing data is stored in the storage unit 16 is shown in FIG. 7. This state is called state (E). In state (E), the Tile2 second reuse data is indicated by a dashed frame.
[0072] Thereafter, the calculation processing unit 17 uses the data transfer unit 15 to read the Tile2 first processed data from the storage unit 16, performs calculations necessary for the second convolution process using a 3×3 kernel, and generates Tile2 second processed data. The memory management unit 3 allocates an area in the storage unit 16 for storing the Tile2 second processed data. The Tile1 second processed data may be stored in an area in the storage unit 16 excluding the areas storing the Tile2 first reuse data and the Tile2 second reuse data. It is also preferable to overwrite at least a part of the Tile2 second processed data in the area storing the Tile2 first processed data and store it.
[0073] The transfer condition determination unit 14 determines the transfer conditions so that the Tile2 second-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 Tile2 second-processed data in the allocated area on the storage unit 16 based on the transfer conditions.
[0074] The state in which the data after the second processing of Tile2 is stored in the storage unit 16 is shown in FIG. 8. This state is referred to as state (F). As shown in FIG. 8, the data after the second processing of Tile2 can be stored, for example, in a total of 48 lines, a 96×48 region, including 16 lines from (2, 48) to (97, 63) and 32 lines from (2, 0) to (97, 31) at the head line of the storage unit 16. Note that, as described above, in Embodiment 1, since the processing is completed in two convolution processes, no reuse data is set in the data after the second processing of Tile2.
[0075] Thereafter, the data transfer unit 15 writes the data after the second processing of Tile2 stored in the storage unit 16 to the 96×48 portion in the middle of the region for storing the output image of the external memory 20. Thereby, the processing for Tile2 is completed.
[0076] <Processing of Tile3> Regarding the processing of Tile3, since it is the same as the processing of Tile2 except that no reuse data is set, the description is omitted. Note that the data transfer unit 15 writes the data after the second processing of Tile3 stored in the storage unit 16 to the 96×48 portion at the end of the region for storing the output image of the external memory 20. Thereby, when the image is divided into three parts and the convolution process is repeated twice, a final output image of the same size as when the image is processed without division can be obtained.
[0077] Here, assuming the input image size is X×Y, it is divided into N tiles in the Y direction, and the number of convolution processes and the data load amount when the convolution process with a 3×3 kernel is repeated C times will be described. When data is not reused, the required number of convolution processes Z is represented by the following formula (1). [Equation] Also, the data load amount L at this time is represented by the following formula (2). L = X×(Y + 2×C) ···(2)
[0078] On the other hand, in the case of an embodiment in which data is reused, the number of times Z of convolution processing required is expressed by the following formula (3).
number
[0079] For example, when 100 x 100 image data is divided into two and convolution processing is performed five times with a 3 x 3 kernel, in the image processing device of embodiment 1, the number of pixels loaded into the internal memory is reduced by approximately 9.1% and the number of convolution operations is reduced by 4.1% compared to when reused data is not used.
[0080] As described above, according to the first embodiment, when an input image is divided into adjacent first and second divided images and sequentially stored in an internal memory for image processing, when the processing of the first divided image is completed and the processing of the second divided image is started, the data loaded during the processing of the first divided image and the data generated by the image processing can be left in the internal memory. When the second divided image is loaded into the internal memory or when repeatedly executing image processing, the data is stored adjacent to the data left in the internal memory, so that it is possible to process the second divided image as a series of image data including this area without re-reading from the outside or recalculating.
[0081] In this way, by devising an appropriate data arrangement in the memory unit 16, the data in the memory unit 16 can be reused, and the number of times image data is read from outside and calculations can be reduced, thereby improving the processing performance of the CNN accelerator and reducing power consumption.
[0082] The first and second calculation processes for the input image data may include a calculation that does not refer to surrounding pixels and does not involve reduction of the output image. In a calculation that does not involve reduction of the output image, the output image data can be written to the area of the memory unit 16 where the input image data to be processed is stored, without setting reuse data.
[0083] Embodiment 2. An image processing device 10a according to the second embodiment will be described with reference to Figs. 9 and 10. Fig. 9 is a block diagram showing an example of the configuration of the image processing device according to the second embodiment. Fig. 10 is a diagram for explaining an example of an image processing method according to the second embodiment. The second embodiment differs from the first embodiment in that a plurality of wraparound ranges can be set in the storage unit 16.
[0084] In the second embodiment, the data transfer unit 15 shown in Fig. 1 of the first embodiment is changed to a data transfer unit 15a that executes data transfer so that different data is stored in a wraparound format in a plurality of wraparound ranges set in the storage unit 16. This allows the area in the storage unit 16 where data is stored to be divided into a plurality of wraparound ranges that do not overlap each other. Note that the transfer condition determination unit 14a may be given a function of determining the wraparound range in which each data is stored, in addition to the function of determining the transfer conditions described above.
[0085] In the following description, 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, a process of dividing the first image and the second image into a plurality of divided image data, a process of determining reuse data, and a process of allocating an area for storing the divided image data to be processed subsequently so as to be adjacent to the area in which the reuse data is stored are executed. For example, the first image and the second image can be divided into three parts, Tile1, Tile2, and Tile3, and processed in the same manner as in the first embodiment. In the second embodiment, the first image data and the second image data are subjected to convolution processing, respectively, and the processing results obtained are further calculated to generate the calculation results.
[0086] In such a case, since the wraparound range is fixed in the image processing device 10 of the first embodiment, it is not possible to execute a series of convolution processes that are repeatedly executed on the second image data while storing the processing results of the first image data in a part of the storage unit 16. In this case, it was necessary to temporarily output the convolution processing results of the first image data and the second image data to the external memory 20 and read them again when performing the inter-image calculation.
[0087] In contrast, in the second embodiment, inter-image calculation can be performed efficiently without inputting and outputting the result of the convolution process of the first image data and the second image data to the external memory 20. Fig. 10 shows an example of the state of the storage unit 16 when two convolution processes are performed on each of two input images (a first image and a second image) and then the process results are compared on a pixel-by-pixel basis.
[0088] 10 shows a state in which the processing results of Tile2 of the first image and the second image are stored in the first and second wraparound ranges of the storage unit 16, respectively. That is, the second processed data of Tile2 of the first image is stored in the first wraparound range, and the second processed data of Tile2 of the second image is stored in the second wraparound range. The second processed data of Tile2 of the first image is the output image of Tile2 of the first image, and the second processed data of Tile2 of the second image is the output image of Tile2 of the second image.
[0089] The first and second wraparound ranges correspond to the states of the storage unit 16 in Fig. 8 of the first embodiment. Note that the first reuse data and the second reuse data of Tile 2 are omitted in Fig. 10. In this way, by being able to set different wraparound ranges for the first image and the second image in the storage unit 16, the first image and the second image can be processed without affecting each other.
[0090] In the example shown in FIG. 10, the calculation result obtained by performing a process of comparing the Tile2 second processing data of the first image and the second image may be stored in the third wraparound range. Specifically, the calculation processing unit 17 can use the data transfer unit 15a to read the Tile2 second processing data of the first image from the first wraparound range of the storage unit 16, read the Tile2 second processing data of the second image from the second wraparound range, and perform a comparison process using these. In addition, the data transfer unit 15a can store a third image, which is a calculation result of the image comparison, in the third wraparound range. For example, in a driving assistance system, the first image and the second image acquired sequentially over time may be compared to generate a third image showing the movement of the same object recognized in the first image and the second image. The second embodiment is applicable to such an example.
[0091] Furthermore, after storing the third image in the third wraparound range, it is possible to execute the convolution process of Tile3 for each of the first image and the second image by using reuse data (not shown).
[0092] The invention made by the present inventor has been specifically described above based on an embodiment, but it goes without saying that the present invention is not limited to the embodiment already described, and various modifications are possible without departing from the gist of the invention.
[0093] The above-mentioned program includes a set of instructions (or software code) for making the computer perform one or more functions described in the embodiment when the program is loaded into the computer. The program may be stored in a non-transitory computer-readable medium or a tangible storage medium. By way of example and not limitation, the computer-readable medium or the tangible storage medium may include 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 digital versatile disc (DVD), a Blu-ray® disk or other optical disk storage, a magnetic cassette, a magnetic tape, a magnetic disk storage or other magnetic storage device. The program may be transmitted on a transitory computer-readable medium or a communication medium. By way of example and not limitation, the transitory computer-readable medium or the communication medium may include an electrical, optical, acoustic, or other form of propagating signal. [Explanation of symbols]
[0094] 1 Image division section 2 Reusable Data Decision Section 3. Memory Management 10, 10a Image processing device 11 Input image specification section 12 Image processing type specification section 13 Kernel Selection Section 14, 14a Transfer condition determination unit 15, 15a Data transfer section 16 Memory section 17 Processing section 20 External Memory
Claims
1. A process of dividing input image data into a plurality of divided image data including a first divided image data and a second divided image data having a predetermined overlapping area with the first divided image data according to a size of a kernel used for image processing; determining first reuse data, which is to be reused when performing image processing on second divided image data, from among the first divided image data; a process of storing, in a memory, first processed data of a first divided image obtained by performing the image processing on the first divided image data in an area excluding an area in which the first reuse data is stored, and allocating an area in which the second divided image data is stored so as to be adjacent to the area in which the first reuse data is stored; to cause a computer to execute program.
2. and causing the computer to execute a process of overwriting and storing at least a part of the first processed data of the first divided image in an area of the memory in which the first divided image data is stored. The program according to claim 1.
3. determining second reuse data, from among the first processed data of the first divided image, which is reused when the image processing is performed on the second divided image data to generate the first processed data of the second divided image; a process of storing, in the memory, second processed data of the first divided image obtained by performing the image processing on the first processed data of the first divided image in an area excluding the areas storing the first reuse data and the second reuse data, and allocating an area for storing the first processed data of the second divided image adjacent to the area storing the second reuse data; and further causing the computer to execute the steps: The program according to claim 1.
4. and causing the computer to execute a process of overwriting and storing at least a part of the first processed data of the second divided image in an area of the memory in which the second divided image data is stored. The program according to claim 3.
5. the second reuse data is used when performing further image processing on the first processed data of the second divided image. The program according to claim 3.
6. and causing the computer to execute a process of storing, in the memory in a wraparound manner, the first divided image data, data obtained by image processing the first divided image data, and the second divided image data, and data obtained by image processing the second divided image data. The program according to claim 1.
7. the input image data includes first image data and second image data; For each of the first image data and the second image data, A process of dividing the image data into a plurality of divided image data; determining the first reusable data; a process of allocating an area for storing the second divided image data so as to be adjacent to an area for storing the first reuse data; Run the command, a process of storing, in a first wraparound range of the memory, the first divided image data and data obtained by image processing the first divided image data, and the second divided image data and data obtained by image processing the second divided image data, for the first image data, in a wraparound manner; a process of storing, in a second wraparound range of the memory different from the first wraparound range, the first divided image data and data obtained by image processing the first divided image data, and the second divided image data and data obtained by image processing the second divided image data, for the second image data, in a wraparound manner; and further causing the computer to execute the steps: The program according to claim 1.
8. and causing the computer to execute a process of storing, in a wraparound manner, output image data generated using the first divided image data of the first image data and the second image data in a third wraparound range of the memory, the third wraparound range being different from the first wraparound range and the second wraparound range. The program according to claim 7.
9. The computer A process of dividing input image data into a plurality of divided image data including a first divided image data and a second divided image data having a predetermined overlapping area with the first divided image data according to a size of a kernel used for image processing; determining first reuse data, which is to be reused when performing image processing on second divided image data, from the first divided image data; a process of storing, in a memory, first processed data of a first divided image obtained by performing the image processing on the first divided image data in an area excluding an area in which the first reuse data is stored, and allocating an area in which the second divided image data is stored so as to be adjacent to the area in which the first reuse data is stored; Execute Image processing methods.
10. the computer further executes a process of overwriting at least a part of the first processed data of the first divided image in an area of the memory in which the first divided image data is stored, and storing the data. The image processing method according to claim 9.
11. The computer determining second reuse data, from among the first processed data of the first divided image, which is reused when the image processing is performed on the second divided image data to generate the first processed data of the second divided image; a process of storing, in the memory, second processed data of the first divided image obtained by performing the image processing on the first processed data of the first divided image in an area excluding the areas storing the first reuse data and the second reuse data, and allocating an area for storing the first processed data of the second divided image adjacent to the area storing the second reuse data; Further execute The image processing method according to claim 9.
12. The computer and further executing a process of overwriting and storing at least a part of the first processed data of the second divided image in an area of the memory in which the second divided image data is stored. The image processing method according to claim 11.
13. The computer using the second reuse data when performing further image processing on the first processed data of the second divided image; The image processing method according to claim 11.
14. The computer further executes a process of storing, in the memory in a wraparound manner, the first divided image data, data obtained by image processing the first divided image data, and the second divided image data, and data obtained by image processing the second divided image data. The image processing method according to claim 9.
15. the input image data includes first image data and second image data; The computer For each of the first image data and the second image data, A process of dividing the image data into a plurality of divided image data; determining the first reusable data; a process of allocating an area for storing the second divided image data so as to be adjacent to an area for storing the first reuse data; Run a process of storing, in a first wraparound range of the memory, the first divided image data and data obtained by image processing the first divided image data, and the second divided image data and data obtained by image processing the second divided image data, for the first image data, in a wraparound manner; a process of storing, in a second wraparound range of the memory different from the first wraparound range, the first divided image data and data obtained by image processing the first divided image data, and the second divided image data and data obtained by image processing the second divided image data, for the second image data, in a wraparound manner; Further execute The image processing method according to claim 9.
16. The computer and further performing a process of storing output image data generated using the first divided image data of the first image data and the second image data in a wraparound manner in a third wraparound range of the memory, the third wraparound range being different from the first wraparound range and the second wraparound range. The image processing method according to claim 15.
17. an image dividing unit that divides input image data into a plurality of divided image data including a first divided image data and a second divided image data having a predetermined overlapping area with the first divided image data according to a size of a kernel used for image processing; a reuse data determination unit that determines first reuse data, from among the first divided image data, to be reused when performing image processing on the second divided image data; a memory management unit that stores, in a memory, first processed data of a first divided image obtained by performing the image processing on the first divided image data in an area excluding an area in which the first reuse data is stored, and allocates an area in which the second divided image data is stored adjacent to the area in which the first reuse data is stored; Equipped with Image processing device.
18. At least a part of the first processed data of the first divided image is overwritten and stored in an area of the memory in which the first divided image data is stored. The image processing device according to claim 17.
19. the input image data includes first image data and second image data; For each of the first image data and the second image data, The image dividing unit divides the image data into the plurality of divided image data, the reuse data determination unit determines the first reuse data; the memory management unit allocates an area for storing the second divided image data so as to be adjacent to an area for storing the first reuse data; The memory management unit storing, in a first wraparound range of the memory, the first divided image data and data obtained by image processing the first divided image data, and the second divided image data and data obtained by image processing the second divided image data, for the first image data, in a wraparound manner; storing, in a second wraparound range of the memory different from the first wraparound range, the first divided image data and data obtained by image processing the first divided image data, and the second divided image data and data obtained by image processing the second divided image data, for the second image data, in a wraparound manner; The image processing device according to claim 17.
20. the memory management unit stores, in a wraparound manner, output image data generated using the first divided image data of the first image data and the second image data in a third wraparound range of the memory, the third wraparound range being different from the first wraparound range and the second wraparound range. The image processing device according to claim 19.
Citation Information
Patent Citations
Device and method for processing image data
JP1999146196A
Arithmetic processing unit and its control method
JP2008310524A
Data reading and writing method and system for 3D image processing, storage medium and terminal
JP2022508028A
Image-processing device, image-processing method, and image-processing program
WO2022259574A1
Semiconductor device, image recognition system, and image processing method
JP2020005118A
