Picture zooming fusion operator execution method and device, and storage medium
By executing the image scaling and fusion operator at one time and using the on-chip cache for operation, the problem of low image scaling and fusion efficiency in the existing technology is solved, and the efficiency and performance of multi-image scaling and fusion are improved.
Patent Information
- Application Number
- CN202410718725.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-09-06
AI Technical Summary
When the existing technology executes image processing operators multiple times, the efficiency of image scaling and fusion is low, resulting in large time overhead and low efficiency.
By loading and executing a picture scaling and fusion operator, the film and multiple original pictures are read from the video memory for scaling processing, and fused with the film, and the on-chip cache is used for operations to reduce the performance loss caused by discontinuous memory access. , improve efficiency.
It effectively reduces the additional time-consuming of multiple calls to execute image scaling and fusion operators, improves the efficiency and performance of multi-image scaling and fusion, and reduces the performance loss caused by discontinuous reading and writing of video memory.
Smart Images

Figure CN118608376A
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of artificial intelligence technology, and in particular to a method, device and storage medium for executing an image scaling and fusion operator. Background Art
[0002] Artificial intelligence models usually refer to neural network models that are trained to perform inference and prediction, such as image inference models, speech inference models, etc. In practical applications, artificial intelligence chips are used to implement the operations of artificial intelligence models. The operations of artificial intelligence models can be implemented by operators in the computation graph. Operators refer to various operations performed on tensors at each layer in the artificial intelligence model, such as image processing operators that perform operations on images.
[0003] In the technical fields of machine vision and image processing, artificial intelligence chips can scale and fuse multiple images by executing image processing operators multiple times to obtain a fused image, and then further process the fused image. However, the efficiency of scaling and fusing images by executing image processing operators multiple times is low. Summary of the invention
[0004] The embodiments of the present application provide a method, device and storage medium for executing an image scaling and fusion operator, which are used to reduce the time overhead of operator calls and improve the efficiency of multi-image scaling and fusion.
[0005] On the one hand, an embodiment of the present application provides a method for executing a picture scaling fusion operator, including:
[0006] Load the image scaling fusion operator and execute the image scaling fusion operator, wherein the execution process includes the following steps:
[0007] Read the film and multiple original images from video memory;
[0008] Respectively scaling the multiple original images to obtain corresponding target images;
[0009] The obtained multiple target images are fused with the negative film to obtain a fused image.
[0010] On the one hand, an embodiment of the present application provides an execution device of an image scaling and fusion operator, including:
[0011] The first loading module is used to load the image scaling and fusion operator;
[0012] The first execution module is used to execute the image scaling and fusion operator, wherein the execution process includes the following steps:
[0013] Read the film and multiple original images from video memory;
[0014] Respectively scaling the multiple original images to obtain corresponding target images;
[0015] The obtained multiple target images are fused with the negative film to obtain a fused image.
[0016] Optionally, the first execution module is specifically configured to:
[0017] The negative film and the plurality of original pictures are loaded from the video memory into an on-chip cache respectively.
[0018] Optionally, the first execution module is specifically configured to:
[0019] The negative film and the plurality of original pictures are loaded from the video memory into the on-chip cache respectively in a continuous memory access manner.
[0020] Optionally, the first execution module is specifically configured to:
[0021] For the multiple original pictures, perform the following operations respectively:
[0022] The one original picture is read from the on-chip cache, and scaling processing is performed on the one original picture to obtain a corresponding target picture.
[0023] Optionally, the first execution module is specifically configured to:
[0024] Determining a first memory access mode based on the scaling ratio and the type of the scaling algorithm;
[0025] The one original picture is read from the on-chip cache in accordance with the first memory access mode, and scaling processing is performed on the one original picture to obtain a corresponding target picture.
[0026] Optionally, the first execution module is specifically configured to:
[0027] The multiple target images are respectively written out to the base film in the on-chip cache to obtain the fused image.
[0028] Optionally, the first execution module is specifically configured to:
[0029] Determine a second memory access mode for each target image based on a size relationship between a width of each target image and a width of the negative film;
[0030] According to the second memory access mode of each target image, each target image is written out to the base film in the on-chip cache to obtain the fused image.
[0031] Optionally, the first execution module is further used for:
[0032] The multiple target images are respectively written out to the base film in the on-chip cache, and after the fused image is obtained, the fused image is written out from the on-chip cache to the video memory in a continuous memory access manner.
[0033] On the one hand, an embodiment of the present application provides a method for executing a picture scaling fusion operator, including:
[0034] Load the image scaling fusion operator and execute the image scaling fusion operator, wherein the execution process includes the following steps:
[0035] Read multiple original images from video memory;
[0036] Respectively scaling the multiple original images to obtain corresponding target images;
[0037] The obtained multiple target images are written onto the film in the video memory to obtain a fused image.
[0038] On the one hand, an embodiment of the present application provides an execution device of an image scaling and fusion operator, including:
[0039] The second loading module is used to load the image scaling and fusion operator;
[0040] The second execution module is used to execute the image scaling and fusion operator, wherein the execution process includes the following steps:
[0041] Read multiple original images from video memory;
[0042] Respectively scaling the multiple original images to obtain corresponding target images;
[0043] The obtained multiple target images are written onto the film in the video memory to obtain a fused image.
[0044] Optionally, the second execution module is specifically configured to:
[0045] Determining a third memory access mode based on the scaling ratio and the type of the scaling algorithm;
[0046] A plurality of original pictures are read from the video memory according to the third memory access mode.
[0047] Optionally, the second execution module is specifically configured to:
[0048] Determining a fourth memory access mode for each target image based on a size relationship between a width of each target image and a width of the negative film;
[0049] According to the fourth memory access mode of each target image, each target image is written onto the film in the video memory to obtain the fused image.
[0050] On the one hand, an embodiment of the present application provides a computer device, including a memory, an artificial intelligence chip, and a computer program stored in the memory and executable on the artificial intelligence chip, wherein the artificial intelligence chip implements the steps of the execution method of the above-mentioned image scaling and fusion operator when executing the computer program.
[0051] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program executable by a computer device. When the computer program runs on the computer device, the computer device executes the steps of the execution method of the above-mentioned image scaling and fusion operator.
[0052] On the one hand, an embodiment of the present application provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer device, the computer device executes the steps of the execution method of the above-mentioned image scaling and fusion operator.
[0053] In an embodiment of the present application, by loading and executing a picture scaling and fusion operator, the negative film and multiple original pictures are read from the video memory, and the multiple original pictures are scaled and fused with the negative film to obtain a fused picture. This effectively reduces the extra time consumed by multiple calls to execute the picture scaling and fusion operator, thereby improving the efficiency of multi-picture scaling and fusion.
[0054] Secondly, the negative film and the original image are loaded from the video memory into the on-chip cache in a continuous memory access mode. The high bandwidth on the chip is used to perform scaling and fusion operations on the negative film and the original image, and the obtained fused image is written out to the video memory in a continuous memory access mode, which effectively reduces the performance loss caused by non-continuous reading and writing of the video memory, thereby improving the performance of the multi-image scaling and fusion operator. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0056] Figure 1 A schematic diagram of the structure of an artificial intelligence chip provided in an embodiment of the present application;
[0057] Figure 2AA flowchart of calling and executing image processing operators provided for related technologies;
[0058] Figure 2B A flowchart of calling and executing image processing operators provided for related technologies;
[0059] Figure 2C A flowchart of calling and executing image processing operators provided for related technologies;
[0060] Figure 2D A flowchart of calling and executing image processing operators provided for related technologies;
[0061] Figure 3A A flowchart of a method for executing an image scaling and fusion operator provided in an embodiment of the present application;
[0062] Figure 3B A flowchart of a method for image scaling processing provided for related technologies;
[0063] Figure 3C A schematic diagram of a flow chart of a method for image fusion provided in an embodiment of the present application;
[0064] Figure 3D A schematic diagram of a flow chart of a method for image fusion provided in an embodiment of the present application;
[0065] Figure 4A A schematic diagram of the effect of multiple images before scaling and fusion provided in an embodiment of the present application;
[0066] Figure 4B A schematic diagram of the effect of scaling and fusion of multiple images provided in an embodiment of the present application;
[0067] Figure 5 A flowchart of a method for executing an image scaling and fusion operator provided in an embodiment of the present application;
[0068] Fig. 6A A flowchart of a method for executing an image scaling and fusion operator provided in an embodiment of the present application;
[0069] Figure 6B A flowchart of a method for executing an image scaling and fusion operator provided in an embodiment of the present application;
[0070] Fig. 7A A schematic diagram of the structure of an execution device of an image scaling and fusion operator provided in an embodiment of the present application;
[0071] Figure 7B A schematic diagram of the structure of an execution device of an image scaling and fusion operator provided in an embodiment of the present application;
[0072] Figure 8 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0073] In order to make the purpose, technical solution and beneficial effects of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0074] refer to Figure 1 , which is a structural diagram of an artificial intelligence chip applicable to an embodiment of the present application, the artificial intelligence chip 100 at least includes: a video memory 101, a plurality of programmable multiprocessors 102, wherein the programmable multiprocessor 102 can be a streaming processing cluster (SPC for short).
[0075] Each programmable multiprocessor 102 includes: an on-chip cache 103 and multiple computing units 104 . The multiple computing units 104 inside the programmable multiprocessor 102 share the on-chip cache 103 . Each computing unit 104 includes multiple execution units 105 .
[0076] The video memory 101 may be a high bandwidth memory (HBM) or other types of memory. The on-chip cache 103 is a temporary memory, which has a smaller capacity than the video memory 101 but a faster data exchange speed than the video memory 101. The on-chip cache 103 may be a general matrix main buffer (GMB).
[0077] In addition to the above-mentioned structure, the artificial intelligence chip 100 in the present application may also include other structures, which are not specifically limited in the present application.
[0078] The artificial intelligence chip 100 may be: a graphics processing unit (GPU), a general-purpose graphics processing unit (GPGPU), a domain specific architecture (DSA), etc.
[0079] In the technical fields of machine vision and image processing, artificial intelligence chips often need to scale and fuse multiple images to obtain a fused image, and then further process the fused image. In order to achieve the above-mentioned multi-image scaling and fusion operations, the relevant technology calls and executes the image processing operator, performs scaling calculations on an image, and fuses the scaled image onto the film. By calling and executing multiple image processing operators, multiple images can be scaled and fused to obtain a fused image.
[0080] For example, in the scenario where picture 1, picture 2, picture 3, and picture 4 are scaled and fused, the multi-picture scaling and fusion operation of the related art is specifically as follows:
[0081] See also Figure 2A At time 1, the image processing operator is called and executed for the first time. The execution unit loads the pixels in image 1 from the video memory, and performs scaling calculation based on the loaded pixels to obtain the scaled image 11. Then, image 11 is written out to a specific position of the film in the video memory.
[0082] See also Figure 2B At time 2, the image processing operator is called and executed for the second time. The execution unit loads the pixels in image 2 from the video memory, and performs scaling calculation based on the loaded pixels to obtain the scaled image 22. Then, image 22 is written to a specific position of the film in the video memory.
[0083] See also Figure 2C At time 3, the image processing operator is called and executed for the third time. The execution unit loads the pixels in image 3 from the video memory, and performs scaling calculation based on the loaded pixels to obtain the scaled image 33. Then, image 33 is written to a specific position of the film in the video memory.
[0084] See also Figure 2D At time 4, the image processing operator is called and executed for the fourth time. The execution unit loads the pixels in image 4 from the video memory, and performs scaling calculation based on the loaded pixels to obtain scaled image 44. Then, image 44 is written to a specific position of the film in the video memory to obtain a fused image.
[0085] It can be seen that the above solution needs to call and execute the image processing operator multiple times. Each execution of the image processing operator will bring additional time overhead for calling the operator in addition to the execution time of the operator itself, resulting in low efficiency of multi-image scaling and fusion.
[0086] In view of this, this application is based on Figure 1 The architecture diagram of the artificial intelligence chip shown in FIG. 1 provides a flow chart of an execution method of an image scaling fusion operator. Figure 3A As shown, the process of the method is executed by an artificial intelligence chip and includes the following steps:
[0087] Step 301: load the image scaling and fusion operator and execute the image scaling and fusion operator.
[0088] In this application, the image scaling and fusion operator only needs to be called and executed once to complete the scaling and fusion effect of multiple images.
[0089] In a specific implementation, the execution process of the image scaling fusion operator includes the following steps 3011 to 3013:
[0090] Step 3011, read the film and multiple original pictures from the video memory.
[0091] In the present application, the negative film and the original image may be images in different image formats, including but not limited to: GRAY format, RGB format, RGBP format, BGRP format, and NV format.
[0092] The artificial intelligence chip can read the film and multiple original images from the video memory in parallel through multiple execution units, or can read the film and multiple original images sequentially through one execution unit. This application does not make specific limitations on this.
[0093] In some embodiments, the negative film and the plurality of original pictures are loaded from the video memory into the on-chip cache respectively.
[0094] Specifically, a cache space of a set size is allocated in advance in the on-chip cache for the image scaling and fusion operator. When the image scaling and fusion operator is executed, the negative film and multiple original images are loaded from the video memory into the cache space in the on-chip cache.
[0095] Step 3012, scaling the multiple original images respectively to obtain corresponding target images.
[0096] Specifically, the scaling process refers to the process of adjusting the size of the original image, including enlarging the original image according to the adjustment ratio and reducing the original image according to the adjustment ratio. The scaling process includes the nearest neighbor interpolation algorithm, the bilinear interpolation algorithm, the bicubic interpolation algorithm, and the like.
[0097] Step 3013, merging the obtained multiple target images with the negative film to obtain a fused image.
[0098] Specifically, the obtained multiple target images are fused to the designated positions (ie, fusion positions) on the film to obtain a fused image. In the actual fusion process, the fusion positions corresponding to different target images on the film may have overlapping areas or may not overlap at all.
[0099] For example, it is necessary to perform multi-image scaling and fusion on the negative film, picture 1, picture 2, picture 3, and picture 4. The schematic diagram of the negative film and the four pictures before multi-image scaling and fusion is as follows: Figure 4A As shown; the effect diagram of the fused image after scaling and fusion of multiple images is as follows Figure 4B As shown, picture 11 is the picture obtained after scaling picture 1, picture 22 is the picture obtained after scaling picture 2, picture 33 is the picture obtained after scaling picture 3, and picture 44 is the picture obtained after scaling picture 4.
[0100] In an embodiment of the present application, by loading and executing a picture scaling and fusion operator, the negative film and multiple original pictures are read from the video memory, and the multiple original pictures are scaled and fused with the negative film to obtain a fused picture. This effectively reduces the extra time consumed by multiple calls to execute the picture scaling and fusion operator, thereby improving the efficiency of multi-picture scaling and fusion.
[0101] In some embodiments, in the process of executing the image scaling and fusion operator in the related technology, the execution unit needs to load the pixel data of the image from the video memory according to the scaling ratio and the type of scaling algorithm. That is, when the execution unit reads the pixels in the image from the video memory, the order of reading the pixels is determined by the scaling ratio and the type of scaling algorithm, rather than by the storage location of the pixels in the video memory.
[0102] If the pixels read sequentially are not continuous on the video memory according to the scaling ratio and the type of scaling algorithm, in this case, when the execution unit loads the image from the video memory, there are operations of non-continuously reading and writing the video memory.
[0103] For an example of the nearest neighbor interpolation scaling algorithm, see Figure 3B , set the original image to include: pixel 1, pixel 2, pixel 3, pixel 4, pixel 5, pixel 6, pixel 7, pixel 8. The pixels in the original image are stored continuously in the video memory. Assume that the original image needs to be reduced by half to obtain the target image.
[0104] Based on the proportional relationship between the target image and the original image, the pixel mapping relationship between the target image and the original image can be obtained. Based on the above pixel mapping relationship, the first pixel point in the target image corresponds to pixel point 1 in the original image, so pixel point 1 is read from the video memory. Based on the above pixel mapping relationship, the second pixel point in the target image corresponds to pixel point 3 in the original image, so pixel point 3 is read from the video memory. And so on, pixel points 1, pixel point 3, pixel point 5, and pixel point 7 of the original image are read from the video memory in sequence to form the target image.
[0105] Since pixel 1, pixel 3, pixel 5, and pixel 7 are not continuous in the video memory, there are operations of discontinuously accessing the video memory, which results in low memory access efficiency.
[0106] In view of this, the present application proposes to load the negative film and multiple original pictures from the video memory into the on-chip cache respectively in a continuous memory access manner.
[0107] Specifically, each pixel point in the film is continuous in the video memory, therefore, the present application loads all the pixel points on the film from the video memory into the on-chip cache in a continuous memory access manner.
[0108] Similarly, each pixel in each original image is continuous in the video memory, so the present application also loads all the pixel points on the original image from the video memory to the on-chip cache in a continuous memory access manner.
[0109] In an embodiment of the present application, all pixels on the film and the original image are loaded from the video memory to the on-chip cache in a continuous memory access manner. This can effectively utilize the advantages of hardware memory access merging to improve memory access efficiency, thereby effectively reducing the pressure on the cache and memory access.
[0110] In some embodiments, for multiple original pictures in the on-chip cache, the following operations are performed respectively: an original picture is read from the on-chip cache, and scaling is performed on the original picture to obtain a corresponding target picture.
[0111] Specifically, when the execution unit reads pixels in the image from the on-chip cache, the order in which the pixels are read is determined by the scaling ratio and the type of scaling algorithm, rather than by the storage location of the pixels in the on-chip cache. When the scaling ratio and the type of scaling algorithm are different, the memory access method for reading the original image from the on-chip cache is also different.
[0112] In view of this, the present application determines a first memory access mode based on the scaling ratio and the type of scaling algorithm, then reads an original image from the on-chip cache according to the first memory access mode, and performs scaling processing on the original image to obtain a corresponding target image.
[0113] Specifically, the first memory access mode is a continuous memory access mode or a non-continuous memory access mode.
[0114] If the pixels read sequentially are not continuous in the on-chip cache according to the scaling ratio and the type of scaling algorithm, the first memory access mode is a non-continuous memory access mode. That is, in the scaling process, the non-continuous memory access mode is adopted to read the pixels in the original image from the on-chip cache to the execution unit, and the execution unit performs scaling calculation based on the read pixels to obtain the corresponding target image.
[0115] If the pixels read sequentially are continuous on the on-chip cache according to the scaling ratio and the type of scaling algorithm, the first memory access mode is a continuous memory access mode. That is, in the scaling process, the continuous memory access mode is adopted to read the pixels in the original image from the on-chip cache to the execution unit, and the execution unit performs scaling calculation based on the read pixels to obtain the corresponding target image.
[0116] In an embodiment of the present application, a film and multiple original images are first loaded from a video memory to an on-chip cache, and then pixels in the original images are loaded from the on-chip cache to an execution unit for scaling. Compared with a path for loading pixels in the original image from a video memory to an execution unit, a path for loading pixels from an on-chip cache to an execution unit is shorter, and therefore memory access is more efficient.
[0117] In some embodiments, when the base image is located in the on-chip cache, the plurality of target images are respectively written out to the base image in the on-chip cache to obtain a fused image.
[0118] Specifically, based on the size relationship between the width of each target image and the width of the negative film, the second memory access mode of each target image is determined. Then, according to the second memory access mode of each target image, each target image is written to the negative film in the on-chip cache to obtain a fused image.
[0119] The second memory access mode is a continuous memory access mode or a non-continuous memory access mode.
[0120] If the width of the target image is smaller than the width of the negative film, then after the target image is written out to the negative film in the on-chip cache, the rows of the target image are not continuous in the on-chip cache.
[0121] For example, see Figure 3C , the target image includes: pixel 1, pixel 3, pixel 5, pixel 7. The width of the target image is smaller than the width of the film, so after the target image is written to the film in the on-chip cache, pixel 3 (located in the first row) and pixel 5 (located in the second row) in the target image are discontinuous in the on-chip cache.
[0122] In this case, the second memory access mode is a non-continuous memory access mode, that is, the present application adopts a non-continuous memory access mode to write the pixels in the target image to a designated position on the film in the on-chip cache to obtain a fused image.
[0123] If the width of the target image is equal to the width of the negative film, then after the target image is written out to the negative film in the on-chip cache, the rows of the target image are continuous in the on-chip cache.
[0124] For example, see Figure 3D , the target image includes: pixel 1, pixel 3, pixel 5, pixel 7. The width of the target image is equal to the width of the film, so after the target image is written out to the film in the on-chip cache, pixel 3 (located in the first row) and pixel 5 (located in the second row) in the target image are continuous in the on-chip cache.
[0125] In this case, the second memory access mode is a continuous memory access mode, that is, the present application adopts a continuous memory access mode to write the pixels in the target image to a specified position on the film in the on-chip cache to obtain a fused image.
[0126] In the embodiment of the present application, the original image, the negative image and the fused image are buffered by using the on-chip cache, and the scaling and fusion operation is performed by using the on-chip high bandwidth, thereby improving the performance of the image scaling and fusion operator.
[0127] In some embodiments, multiple target images are written to the film in the on-chip cache respectively, and after the fused image is obtained, the fused image is written from the on-chip cache to the video memory in a continuous memory access manner.
[0128] Specifically, each pixel point in the fused image is continuous in the video memory. Therefore, the present application writes all the pixel points on the fused image from the on-chip cache to the video memory in a continuous memory access manner.
[0129] For example, see Figure 5 , it is set that the negative film, picture 1, picture 2, picture 3, and picture 4 need to be scaled and fused.
[0130] The execution unit loads the negative film, picture 1, picture 2, picture 3, and picture 4 from the video memory into the on-chip cache in a continuous memory access manner.
[0131] The execution unit reads the pixels in image 1 from the on-chip cache in a non-continuous memory access manner, and performs scaling calculations based on the read pixels to obtain image 11; then writes the pixels in image 11 to a specified location in the film stored in the on-chip cache in a non-continuous memory access manner.
[0132] In the same way, the scaling calculation is performed on the image 2 to obtain the image 22, and the image 22 is written to the specified position in the negative film; in the same way, the scaling calculation is performed on the image 3 to obtain the image 33, and the image 33 is written to the specified position in the negative film; in the same way, the scaling calculation is performed on the image 4 to obtain the image 44, and the image 44 is written to the specified position in the negative film. At this point, the fused image of the negative film, the image 11, the image 22, the image 33, and the image 44 can be obtained.
[0133] The execution unit writes the pixels in the fused image to the video memory in a continuous memory access manner.
[0134] In the embodiment of the present application, the effect of multi-image scaling and fusion is achieved by loading and executing the image scaling and fusion operator once, which effectively reduces the extra time consumed by multiple calls to execute the image scaling and fusion operator, thereby improving the efficiency of multi-image scaling and fusion.
[0135] Secondly, the negative film and the original image are loaded from the video memory into the on-chip cache in a continuous memory access mode. The high bandwidth on the chip is used to perform scaling and fusion operations on the negative film and the original image, and the obtained fused image is written out to the video memory in a continuous memory access mode, which effectively reduces the performance loss caused by non-continuous reading and writing of the video memory, thereby improving the performance of the multi-image scaling and fusion operator.
[0136] This application is based on Figure 1 The architecture diagram of the artificial intelligence chip shown in FIG. 1 provides a flow chart of another execution method of the image scaling fusion operator, such as Fig. 6A As shown, the process of the method is executed by an artificial intelligence chip and includes the following steps:
[0137] Step 601, load the image scaling fusion operator and execute the image scaling fusion operator.
[0138] In this application, the image scaling and fusion operator only needs to be called and executed once to complete the scaling and fusion effect of multiple images.
[0139] In a specific implementation, the execution process of the image scaling fusion operator includes the following steps 6011 to 6013:
[0140] Step 6011, read multiple original pictures from the video memory.
[0141] Step 6012, scaling the multiple original images respectively to obtain corresponding target images.
[0142] In the present application, the original image may be an image in different image formats, including but not limited to: GRAY format, RGB format, RGBP format, BGRP format, and NV format.
[0143] The artificial intelligence chip can read multiple original images from the video memory in parallel through multiple execution units; it can also read multiple original images sequentially through one execution unit. This application does not make any specific limitations on this.
[0144] Scaling refers to the process of adjusting the size of the original image, including enlarging the original image according to the adjustment ratio and reducing the original image according to the adjustment ratio. Scaling methods include: nearest neighbor interpolation algorithm, bilinear interpolation algorithm, bicubic interpolation algorithm, etc.
[0145] In some embodiments, a third memory access method is determined based on the scaling ratio and the type of scaling algorithm; and a plurality of original images are read from a video memory according to the third memory access method.
[0146] Specifically, the third memory access mode is a continuous memory access mode or a non-continuous memory access mode.
[0147] If the pixels read sequentially are not continuous on the video memory according to the scaling ratio and the type of scaling algorithm, the third memory access mode is a non-continuous memory access mode. That is, in the process of performing the scaling process, the non-continuous memory access mode is adopted to read the pixels in the original image from the video memory to the execution unit, and the execution unit performs scaling calculation based on the read pixels to obtain the corresponding target image.
[0148] If the pixels read sequentially are continuous on the video memory according to the scaling ratio and the type of scaling algorithm, the third memory access mode is a continuous memory access mode. In the process of performing the scaling process, the continuous memory access mode is adopted to read the pixels in the original image from the video memory to the execution unit, and the execution unit performs scaling calculation based on the read pixels to obtain the corresponding target image.
[0149] Step 6013, write the obtained multiple target images to the film in the video memory to obtain a fused image.
[0150] In some embodiments, based on the size relationship between the width of each target image and the width of the negative film, the fourth memory access mode of each target image is determined. According to the fourth memory access mode of each target image, each target image is written to the negative film in the video memory to obtain a fused image.
[0151] Specifically, the fourth memory access mode is a continuous memory access mode or a non-continuous memory access mode.
[0152] If the width of the target image is smaller than the width of the film, then after the target image is written to the film in the video memory, the rows of the target image are not continuous in the video memory (see the example for details). Figure 3C ), therefore, the fourth memory access mode is a non-continuous memory access mode. That is, the present application adopts a non-continuous memory access mode to write the pixel points in the target image to the specified position on the film in the video memory to obtain a fused image.
[0153] If the width of the target image is equal to the width of the film, then after the target image is written to the film in the video memory, the rows of the target image are continuous in the video memory (see the example for details). Figure 3D ), therefore, the fourth memory access mode is a continuous memory access mode. That is, the present application adopts a continuous memory access mode to write the pixel points in the target image to the specified position on the negative film in the video memory to obtain a fused image.
[0154] In the actual fusion process, the corresponding fusion positions of different target images on the film may have overlapping areas, or may not overlap at all.
[0155] For example, see Figure 6B , it is set that the negative film, picture 1, picture 2, picture 3, and picture 4 need to be scaled and fused.
[0156] The execution unit reads pictures 1, 2, 3, and 4 from the video memory in a non-continuous memory access mode, performs scaling calculation on the pixels in picture 1, and obtains picture 11; and writes the pixels in picture 11 to a specified position in the film stored in the video memory in a non-continuous memory access mode.
[0157] In the same way, the scaling calculation is performed on the image 2 to obtain the image 22, and the image 22 is written to the specified position in the negative film; in the same way, the scaling calculation is performed on the image 3 to obtain the image 33, and the image 33 is written to the specified position in the negative film; in the same way, the scaling calculation is performed on the image 4 to obtain the image 44, and the image 44 is written to the specified position in the negative film. At this point, the fused image of the negative film, the image 11, the image 22, the image 33, and the image 44 can be obtained.
[0158] In an embodiment of the present application, by loading and executing a picture scaling and fusion operator once, multiple original pictures are read from the video memory, and after the multiple original pictures are scaled, the scaling results are written to the film in the video memory to obtain a fused picture. This effectively reduces the extra time consumed by multiple calls to execute the picture scaling and fusion operator, thereby improving the efficiency of multi-picture scaling and fusion.
[0159] Based on the same technical concept, the embodiment of the present application provides a structural diagram of an execution device of an image scaling and fusion operator, such as Fig. 7A As shown, the execution device of the image scaling fusion operator includes:
[0160] The first loading module 701 is used to load the image scaling and fusion operator;
[0161] The first execution module 702 is used to execute the picture scaling and fusion operator, wherein the execution process includes the following steps:
[0162] Read the film and multiple original images from video memory;
[0163] Respectively scaling the multiple original images to obtain corresponding target images;
[0164] The obtained multiple target images are fused with the negative film to obtain a fused image.
[0165] Optionally, the first execution module 702 is specifically configured to:
[0166] The negative film and the plurality of original pictures are loaded from the video memory into an on-chip cache respectively.
[0167] Optionally, the first execution module 702 is specifically configured to:
[0168] The negative film and the plurality of original pictures are loaded from the video memory into the on-chip cache respectively in a continuous memory access manner.
[0169] Optionally, the first execution module 702 is specifically configured to:
[0170] For the multiple original pictures, perform the following operations respectively:
[0171] The one original picture is read from the on-chip cache, and scaling processing is performed on the one original picture to obtain a corresponding target picture.
[0172] Optionally, the first execution module 702 is specifically configured to:
[0173] Determining a first memory access mode based on the scaling ratio and the type of the scaling algorithm;
[0174] The one original picture is read from the on-chip cache in accordance with the first memory access mode, and scaling processing is performed on the one original picture to obtain a corresponding target picture.
[0175] Optionally, the first execution module 702 is specifically configured to:
[0176] The multiple target images are respectively written out to the base film in the on-chip cache to obtain the fused image.
[0177] Optionally, the first execution module 702 is specifically configured to:
[0178] Determine a second memory access mode for each target image based on a size relationship between a width of each target image and a width of the negative film;
[0179] According to the second memory access mode of each target image, each target image is written out to the base film in the on-chip cache to obtain the fused image.
[0180] Optionally, the first execution module 702 is further configured to:
[0181] The multiple target images are respectively written out to the base film in the on-chip cache, and after the fused image is obtained, the fused image is written out from the on-chip cache to the video memory in a continuous memory access manner.
[0182] In an embodiment of the present application, by loading and executing a picture scaling and fusion operator, the negative film and multiple original pictures are read from the video memory, and the multiple original pictures are scaled and fused with the negative film to obtain a fused picture. This effectively reduces the extra time consumed by multiple calls to execute the picture scaling and fusion operator, thereby improving the efficiency of multi-picture scaling and fusion.
[0183] Secondly, the negative film and the original image are loaded from the video memory into the on-chip cache in a continuous memory access mode. The high bandwidth on the chip is used to perform scaling and fusion operations on the negative film and the original image, and the obtained fused image is written out to the video memory in a continuous memory access mode, which effectively reduces the performance loss caused by non-continuous reading and writing of the video memory, thereby improving the performance of the multi-image scaling and fusion operator.
[0184] Based on the same technical concept, the embodiment of the present application provides a structural diagram of an execution device of an image scaling and fusion operator, such as Figure 7B As shown, the execution device of the image scaling fusion operator includes:
[0185] The second loading module 703 is used to load the image scaling and fusion operator;
[0186] The second execution module 704 is used to execute the picture scaling and fusion operator, wherein the execution process includes the following steps:
[0187] Read multiple original images from video memory;
[0188] Respectively scaling the multiple original images to obtain corresponding target images;
[0189] The obtained multiple target images are written onto the film in the video memory to obtain a fused image.
[0190] Optionally, the second execution module 704 is specifically configured to:
[0191] Determining a third memory access mode based on the scaling ratio and the type of the scaling algorithm;
[0192] A plurality of original pictures are read from the video memory according to the third memory access mode.
[0193] Optionally, the second execution module 704 is specifically configured to:
[0194] Determining a fourth memory access mode for each target image based on a size relationship between a width of each target image and a width of the negative film;
[0195] According to the fourth memory access mode of each target image, each target image is written onto the film in the video memory to obtain the fused image.
[0196] Based on the same technical concept, the embodiment of the present application provides a computer device, such as Figure 8 As shown, it includes at least one artificial intelligence chip 100 and a memory 801 connected to the at least one artificial intelligence chip 100. The specific connection medium between the artificial intelligence chip 100 and the memory 801 is not limited in the embodiment of the present application. Figure 8 In the example, the artificial intelligence chip 100 and the memory 801 are connected via a bus. The bus can be divided into an address bus, a data bus, a control bus, etc.
[0197] In an embodiment of the present application, the memory 801 stores instructions that can be executed by at least one artificial intelligence chip 100. At least one artificial intelligence chip 100 can execute the steps of the execution method of the above-mentioned image scaling and fusion operator by executing the instructions stored in the memory 801.
[0198] Among them, the artificial intelligence chip 100 is the control center of the computer device, and various interfaces and lines can be used to connect various parts of the computer device, and the execution of the picture scaling fusion operator is realized by running or executing instructions stored in the memory 801 and calling the data stored in the memory 801. Optionally, the artificial intelligence chip 100 may include one or more processing units, and the artificial intelligence chip 100 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application program, etc., and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the artificial intelligence chip 100. In some embodiments, the artificial intelligence chip 100 and the memory 801 can be implemented on the same chip, and in some embodiments, they can also be implemented separately on separate chips.
[0199] The artificial intelligence chip 100 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware processor, or can be executed by a combination of hardware and software modules in the processor.
[0200] Memory 801, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules. Memory 801 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (Random Access Memory, RAM), static random access memory (Static Random Access Memory, SRAM), programmable read-only memory (Programmable Read Only Memory, PROM), read-only memory (Read Only Memory, ROM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), magnetic storage, disk, optical disk, etc. Memory 801 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer device, but is not limited thereto. The memory 801 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0201] Based on the same inventive concept, an embodiment of the present application provides a computer-readable storage medium storing a computer program executable by a computer device. When the computer program runs on the computer device, the computer device executes the steps of the execution method of the above-mentioned image scaling and fusion operator.
[0202] Based on the same inventive concept, an embodiment of the present application provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer device, the computer device executes the steps of the execution method of the above-mentioned image scaling and fusion operator.
[0203] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0204] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer device or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0205] These computer program instructions may also be stored in a computer readable memory capable of directing a computer device or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0206] These computer program instructions can also be loaded onto a computer device or other programmable data processing device so that a series of operation steps are executed on the computer device or other programmable device to produce a process implemented by the computer device, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0207] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0208] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for executing a picture scaling fusion operator, characterized in that: include: Load the image scaling fusion operator and execute the image scaling fusion operator, wherein the execution process includes the following steps: Read the film and multiple original images from video memory; Respectively scaling the multiple original images to obtain corresponding target images; The obtained multiple target images are fused with the negative film to obtain a fused image.
2. The method according to claim 1, characterized in that The reading of the negative film and the plurality of original images from the video memory includes: The negative film and the plurality of original pictures are loaded from the video memory into an on-chip cache respectively.
3. The method according to claim 2, characterized in that The step of loading the negative film and the plurality of original pictures from the video memory into an on-chip cache comprises: The negative film and the plurality of original pictures are loaded from the video memory into the on-chip cache respectively in a continuous memory access manner.
4. The method according to claim 2, characterized in that The step of respectively performing scaling processing on the multiple original images to obtain corresponding target images includes: For the multiple original pictures, perform the following operations respectively: The one original picture is read from the on-chip cache, and scaling processing is performed on the one original picture to obtain a corresponding target picture.
5. The method according to claim 4, characterized in that The step of reading the original picture from the on-chip cache and performing scaling processing on the original picture to obtain a corresponding target picture includes: Determining a first memory access mode based on the scaling ratio and the type of the scaling algorithm; The one original picture is read from the on-chip cache in accordance with the first memory access mode, and scaling processing is performed on the one original picture to obtain a corresponding target picture.
6. The method according to claim 4, characterized in that The step of fusing the obtained multiple target images with the negative film to obtain a fused image includes: The multiple target images are respectively written out to the base film in the on-chip cache to obtain the fused image.
7. The method according to claim 6, characterized in that The step of writing the plurality of target images to the base film in the on-chip cache to obtain the fused image comprises: Determine a second memory access mode for each target image based on a size relationship between a width of each target image and a width of the negative film; According to the second memory access mode of each target image, each target image is written out to the base film in the on-chip cache to obtain the fused image.
8. The method according to claim 6, characterized in that After the plurality of target images are written out to the base film in the on-chip cache respectively to obtain the fused image, the method further comprises: The fused image is written out from the on-chip cache to the video memory in a continuous memory access manner.
9. A method for executing a picture scaling fusion operator, characterized in that: include: Load the image scaling fusion operator and execute the image scaling fusion operator, wherein the execution process includes the following steps: Read multiple original images from video memory; Respectively scaling the multiple original images to obtain corresponding target images; The obtained multiple target images are written onto the film in the video memory to obtain a fused image.
10. The method according to claim 9, characterized in that The step of reading a plurality of original images from a video memory includes: Determining a third memory access mode based on the scaling ratio and the type of the scaling algorithm; A plurality of original pictures are read from the video memory according to the third memory access mode.
11. The method according to claim 9, characterized in that Writing the obtained multiple target images onto the film in the video memory to obtain a fused image includes: Determining a fourth memory access mode for each target image based on a size relationship between a width of each target image and a width of the negative film; According to the fourth memory access mode of each target image, each target image is written onto the film in the video memory to obtain the fused image.
12. A computer device comprising a memory, an artificial intelligence chip, and a computer program stored in the memory and executable on the artificial intelligence chip, characterized in that: When the artificial intelligence chip executes the computer program, the steps of any method described in claims 1 to 11 are implemented.
13. A computer-readable storage medium, characterized in that: It stores a computer program executable by a computer device. When the computer program is run on the computer device, the computer device executes the steps of any method described in claims 1 to 11.
14. A computer program product, characterized in that The computer program product comprises a computer program stored on a computer-readable storage medium, wherein the computer program comprises program instructions, and when the program instructions are executed by a computer device, the computer device is caused to execute the steps of the method according to any one of claims 1 to 11.
