CN115828079B - Method and device for maximum pooling operation - Google Patents

Method and device for maximum pooling operation Download PDF

Info

Publication number
CN115828079B
CN115828079B CN202210420612.0A CN202210420612A CN115828079B CN 115828079 B CN115828079 B CN 115828079B CN 202210420612 A CN202210420612 A CN 202210420612A CN 115828079 B CN115828079 B CN 115828079B
Authority
CN
China
Prior art keywords
index
pooling
dimensional
size
result
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210420612.0A
Other languages
Chinese (zh)
Other versions
CN115828079A (en
Inventor
王务仑
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Aixin Technology Co ltd
Original Assignee
Beijing Aixin Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Aixin Technology Co ltd filed Critical Beijing Aixin Technology Co ltd
Priority to CN202210420612.0A priority Critical patent/CN115828079B/en
Publication of CN115828079A publication Critical patent/CN115828079A/en
Application granted granted Critical
Publication of CN115828079B publication Critical patent/CN115828079B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Image Processing (AREA)

Abstract

The application provides a method and a device for maximum pooling operation, which adopt hardware resources in a chip to calculate a one-dimensional maximum pooling result and a corresponding relative index. And then, carrying out continuous pooling operation in a second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index, calculating to obtain an index of the one-dimensional pooling index, and finally obtaining the two-dimensional pooling index according to the one-dimensional pooling index and the index of the one-dimensional pooling index. The maximum pooling operation in the embodiment can obtain the maximum pooling result and the corresponding index value simultaneously through hardware resource calculation in the chip, is independent of general control units such as a GPU (graphics processing unit) or a CPU (Central processing Unit), reduces the calculated amount and is easy to realize control logic.

Description

Method and device for maximum pooling operation
Technical Field
The application relates to the technical design field of integrated circuits, in particular to a method and a device for maximum pooling operation.
Background
The maximum pooling is a common operation in a neural network, and can reduce the receptive field of an image and the dimension of the image, and a pooling operation is usually added behind the convolution operation, for example, the maximum pooling is used for calculating the result of the maximum pooling, and in some special network models, the position of the result of the maximum pooling in an original image needs to be obtained while the result of the maximum pooling is obtained, so that the data is restored to the dimension of the original image. However, the existing max-pooling operation cannot generate the max-pooling index while obtaining the max-pooling result, and to generate the max-pooling index is usually implemented by using a hardware design scheme of a general-purpose computing unit such as a CPU or a GPU, which results in huge calculation amount and complex control.
Disclosure of Invention
The embodiment of the application aims to provide a method and a device for maximizing pooling operation, which are used for solving the problem that the existing maximizing pooling operation can not obtain the maximizing pooling result and generate the maximizing pooling index.
The method for maximizing the pooling operation provided by the embodiment of the application comprises the following steps:
carrying out continuous pooling operation on the image in a first direction to obtain a one-dimensional pooling result and a one-time relative index;
obtaining a one-dimensional pooling index according to the one-dimensional pooling result and the primary relative index;
carrying out continuous pooling operation in a second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index;
obtaining an index of the one-dimensional pooling index according to the two-dimensional pooling result and the secondary relative index; wherein the index of the one-dimensional pooling index is used for indicating the two-dimensional pooling index; and
and obtaining a two-dimensional pooling index according to the one-dimensional pooling index and the index of the one-dimensional pooling index.
In the above technical solution, the hardware resources in the chip may be used to calculate the one-dimensional maximum pooling result and the corresponding relative index, and since the hardware of the chip can only read the data in one area first, calculate the maximum value in the area and obtain the relative index, the image is subjected to continuous pooling operation in the first direction to obtain the one-dimensional pooling result and the one-time relative index, and then calculate to obtain the one-dimensional pooling index. And then, carrying out continuous pooling operation in a second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index, calculating to obtain an index of the one-dimensional pooling index, and finally obtaining the two-dimensional pooling index according to the one-dimensional pooling index and the index of the one-dimensional pooling index. Therefore, the maximum pooling operation method of the embodiment can obtain the maximum pooling result and the corresponding index value at the same time.
In some alternative embodiments, obtaining the one-dimensional pooled index from the one-dimensional pooled result and the one-time relative index comprises:
amplifying the primary relative index according to the size of the image in the second direction;
obtaining a first increment according to the image size and the first direction stepping value; and
and adding the amplified primary relative index with the first increment to obtain a one-dimensional pooling index.
In some alternative embodiments, obtaining the index of the one-dimensional pooled index from the two-dimensional pooled result and the secondary relative index comprises:
obtaining a second increment according to the dimension of the one-dimensional pooling result and the step value in the second direction; and
and adding the second relative index and the second increment to obtain the index of the one-dimensional pooling index.
In some alternative embodiments, performing a continuous pooling operation in a first direction on the image to obtain a one-dimensional pooled result and a primary relative index, including:
in the first pooling operation process, pooling operation is carried out on each divided area in the first direction, the step value in the first direction is offset_y, and the size of a one-dimensional pooling result is sizey_x×sizey_y;
where sizey_x=sizejx, sizejy= (sizejy-filter_y)/offset_y+1; size_x is the size of the image in the second direction, size_y is the size of the image in the first direction, filter_y is the size of the filter in the first direction, and offset_y is the step value of the filter in the first direction.
In some alternative embodiments, the one-time relative index is enlarged according to the size of the image in the second direction, including performing the following operations:
idx_hw=argmax_y×size_x
where idx_hw is a primary relative index with an enlarged width, and argmax_y is a primary relative index.
In some alternative embodiments, deriving the first increment from the image size and the first direction step value includes:
generating a first data sequence of 0 to size_x×size_y-1 for a total of size_x×size_y data;
finding all data satisfying (n// size_x)% offset_y= 0 in the first data sequence as a first increment; where n is the data in the first data sequence.
In some alternative embodiments, performing a continuous pooling operation in a second direction on the one-dimensional pooled result to obtain a two-dimensional pooled result and a secondary relative index, including:
in the second pooling operation process, pooling operation is carried out on each divided area in the second direction, the step value in the second direction is offset_x, and the size of the secondary relative index is sizey_y×w_idx_x;
wherein w_idx_x= (size_x-filter_x)/offset_x+1; filter_x is the dimension of the pooling filter in the second direction, and offset_x is the step value of the pooling filter in the second direction.
In some alternative embodiments, obtaining the second increment based on the dimension of the one-dimensional pooling result and the second direction step value includes:
generating a second data sequence of 0 to sizey_x x sizey_y-1 for a total of sizey_x sizey_y data;
finding all data satisfying (n% sizey_x)// offset_x= 0 in the second data sequence as a second increment; where n is the data in the second data sequence.
The device for maximum pooling operation provided by the embodiment of the application comprises:
the continuous pooling operation module is used for carrying out continuous pooling operation on the image in the first direction to obtain a one-dimensional pooling result and a one-time relative index; carrying out continuous pooling operation in a second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index;
the stream data operation module is used for obtaining a one-dimensional pooling index according to the one-dimensional pooling result and the primary relative index; obtaining an index of the one-dimensional pooling index according to the two-dimensional pooling result and the secondary relative index; wherein the index of the one-dimensional pooling index is used for indicating the two-dimensional pooling index;
and the skip module is used for obtaining the two-dimensional pooling index according to the one-dimensional pooling index and the index of the one-dimensional pooling index.
In the above technical solution, the hardware resources in the chip are used to calculate the one-dimensional maximum pooling result and the corresponding relative index, and because the hardware of the chip can only read the data in one area first, calculate the maximum value in the area and obtain the relative index, the continuous pooling operation module is used to perform the continuous pooling operation of the first direction on the image, so as to obtain the one-dimensional pooling result and the one-time relative index. And then calculating by using a stream data operation module to obtain a one-dimensional pooling index. And then, carrying out continuous pooling operation in a second direction on the one-dimensional pooling result by utilizing a continuous pooling operation module to obtain a two-dimensional pooling result and a secondary relative index. And calculating by using a stream data operation module to obtain an index of the one-dimensional pooling index, and finally obtaining a two-dimensional pooling index by using a skip module according to the one-dimensional pooling index and the index of the one-dimensional pooling index. The maximum pooling operation in the embodiment can obtain the maximum pooling result and the corresponding index value simultaneously through hardware resource calculation in the chip, is independent of general control units such as a GPU (graphics processing unit) or a CPU (Central processing Unit), reduces the calculated amount and is easy to realize control logic.
In some alternative embodiments, the streaming data operation module is further configured to:
amplifying the primary relative index according to the size of the image in the second direction;
obtaining a first increment according to the image size and the first direction stepping value;
and adding the amplified primary relative index with the first increment to obtain a one-dimensional pooling index.
In some alternative embodiments, the streaming data operation module is further configured to:
obtaining a second increment according to the dimension of the one-dimensional pooling result and the step value in the second direction; and
and adding the second relative index and the second increment to obtain the index of the one-dimensional pooling index.
In some alternative embodiments, the continuous pooling operation module is further configured to:
in the first pooling operation process, pooling operation is carried out on each divided area in the first direction, the step value in the first direction is offset_y, and the size of a one-dimensional pooling result is sizey_x×sizey_y;
where sizey_x=sizejx, sizejy= (sizejy-filter_y)/offset_y+1; size_x is the size of the image in the second direction, size_y is the size of the image in the first direction, filter_y is the size of the filter in the first direction, and offset_y is the step value of the filter in the first direction.
In some alternative embodiments, the streaming data operation module is further configured to:
idx_hw=argmax_y×size_x
where idx_hw is a primary relative index with an enlarged width, and argmax_y is a primary relative index.
In some alternative embodiments, the streaming data operation module is further configured to:
generating a first data sequence of 0 to size_x×size_y-1 for a total of size_x×size_y data;
finding all data satisfying (n// size_x)% offset_y= 0 in the first data sequence as a first increment; where n is the data in the first data sequence.
In some alternative embodiments, the continuous pooling operation module is further configured to:
in the second pooling operation process, pooling operation is carried out on each divided area in the second direction, the step value in the second direction is offset_x, and the size of the secondary relative index is sizey_y×w_idx_x;
wherein w_idx_x= (size_x-filter_x)/offset_x+1; filter_x is the dimension of the pooling filter in the second direction, and offset_x is the step value of the pooling filter in the second direction.
In some alternative embodiments, the streaming data operation module is further configured to:
generating a second data sequence of 0 to sizey_x x sizey_y-1 for a total of sizey_x sizey_y data;
finding all data satisfying (n% sizey_x)// offset_x= 0 in the second data sequence as a second increment; where n is the data in the second data sequence.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and should not be considered as limiting the scope, and other related drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of the method steps of a max-pooling operation according to an embodiment of the present application;
FIG. 2 is a diagram of an image, a one-dimensional pooling result, and a primary relative index according to an embodiment of the present application;
FIG. 3 is a schematic diagram of the embodiment of the present application after one relative index enlargement;
FIG. 4 is a schematic diagram of a first data sequence and a first increment according to an embodiment of the application;
FIG. 5 is a schematic diagram of a one-dimensional pooled index according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a secondary relative index provided by an embodiment of the present application;
FIG. 7 is a schematic illustration of a second increment provided by an embodiment of the present application;
FIG. 8 is a schematic diagram of an index of a one-dimensional pooled index and a two-dimensional pooled index provided by an embodiment of the present application;
fig. 9 is a functional block diagram of an apparatus for maximizing pooling operation according to an embodiment of the present application.
Icon: 1-a continuous pooling operation module, 2-a stream data operation module and 3-a skip reading module.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application.
Referring to fig. 1, fig. 1 is a flowchart of a method step of a max-pooling operation according to an embodiment of the present application, including:
s1, carrying out continuous pooling operation in a first direction on an image to obtain a one-dimensional pooling result and a one-time relative index;
s2, obtaining a one-dimensional pooling index according to the one-dimensional pooling result and the primary relative index;
s3, carrying out continuous pooling operation in a second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index;
s4, obtaining an index of the one-dimensional pooling index according to the two-dimensional pooling result and the secondary relative index; wherein the index of the one-dimensional pooling index is used for indicating the two-dimensional pooling index; and
and S5, obtaining a two-dimensional pooling index according to the one-dimensional pooling index and the index of the one-dimensional pooling index.
In the embodiment of the application, the hardware resource in the chip is adopted to calculate the one-dimensional maximum pooling result and the corresponding relative index, and because the hardware of the chip can only read the data in one area firstly, the maximum value in the area is calculated and the relative index is obtained, the continuous pooling operation in the first direction is carried out on the image to obtain the one-dimensional pooling result and the one-time relative index, and then the one-dimensional pooling index is obtained by calculation. And then, carrying out continuous pooling operation in a second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index, calculating to obtain an index of the one-dimensional pooling index, and finally obtaining the two-dimensional pooling index according to the one-dimensional pooling index and the index of the one-dimensional pooling index. The maximum pooling operation in the embodiment can obtain the maximum pooling result and the corresponding index value simultaneously through hardware resource calculation in the chip, is independent of general control units such as a GPU (graphics processing unit) or a CPU (Central processing Unit), reduces the calculated amount and is easy to realize control logic.
It should be clear that, in some alternative embodiments, the calculation process of the above steps is implemented by using a general purpose computing unit such as a GPU or a CPU, and the method of this embodiment can also obtain the maximum pooling result and the corresponding index value.
For convenience of description, in one or more embodiments below, the filter size is filter_y=3, filter_x=3, and the maximum pooling of the step values offset_y=3, offset_x=3 will be described as an example.
In some alternative embodiments, performing a continuous pooling operation in a first direction on the image to obtain a one-dimensional pooled result and a primary relative index, including:
in the first pooling operation process, pooling operation is carried out on each divided area in the first direction, the step value in the first direction is offset_y, and the size of a one-dimensional pooling result is sizey_x×sizey_y;
where sizey_x=sizejx, sizejy= (sizejy-filter_y)/offset_y+1; size_x is the size of the image in the second direction, size_y is the size of the image in the first direction, filter_y is the size of the filter in the first direction, and offset_y is the step value of the filter in the first direction.
Referring to fig. 2, fig. 2 is a schematic diagram of an image, a one-dimensional pooling result and a relative index according to an embodiment of the present application, performing a continuous pooling operation in a first direction (y-axis direction) on an image with size of size_y×size_x (i.e. 6×6), that is, performing a maximum pooling on each 3×1 region, where all 3×1 regions form the whole image, for example, starting from the 3×1 region including a0, a1, a2 in the upper left corner, sequentially performing a maximum pooling on the 3×1 region shifted to the right, and after completing the maximum pooling of the 3×1 region including a5, a11, a17 in the upper right corner, sequentially performing a maximum pooling on the 3×1 region including a18, a24, a30 in the right corner, starting from the 3×1 region adjacent to the 3×1 region (i.e. the lower left corner) of a0, a1, a2, until the maximum pooling of the 3×1 area including a23, a29, a35 in the lower right corner is completed, a one-dimensional pooling result data_y is obtained, the size of the one-dimensional pooling result data_y is sizey_x×sizey_y, where sizey_x=sizejx=6, that is, the image width before calculation is still sizejx, sizejy is the size of the calculated image, the calculation formula is sizejy= (sizejy-filter_y)/offset_y+1=2, where sizejy represents the size of the original image in the y direction (value is 6), filter_y is the step value (value is 3) of the filter performing the pooling operation in the y direction, offset_y is the step value (value is 3) of the filter performing the pooling operation in the y direction, and the relative index argmax_y of the same size is obtained, the value of a0-ay 11 in one of 0,1,2, ay0 to ay11 represent indexes within each 3×1 area, respectively, so ay0 to ay11 are referred to as a relative index argmax_y.
In some alternative embodiments, obtaining the one-dimensional pooled index from the one-dimensional pooled result and the one-time relative index comprises:
s21, amplifying the primary relative index according to the size of the image in the second direction;
step S22, obtaining a first increment according to the image size and the first direction stepping value; and
and S23, adding the amplified primary relative index with the first increment to obtain a one-dimensional pooling index.
In some alternative embodiments, the one-time relative index is enlarged according to the size of the image in the second direction, including performing the following operations:
idx_hw=argmax_y×size_x
where idx_hw is a primary relative index with an enlarged width, and argmax_y is a primary relative index.
Referring to fig. 3, fig. 3 is a schematic diagram of a primary relative index after being enlarged, in which a streaming data operation module is used to multiply each data in a primary relative index argmax_y by a size_x of an image in an x direction, for example hw0=ay 0×6.
In some alternative embodiments, deriving the first increment from the image size and the first direction step value includes:
generating a first data sequence of 0 to size_x×size_y-1 for a total of size_x×size_y data;
finding all data satisfying (n// size_x)% offset_y= 0 in the first data sequence as a first increment; where n is the data in the first data sequence.
Referring to fig. 4, fig. 4 is a schematic diagram of a first data sequence and a first increment according to an embodiment of the application. The software generates a set of data sequences from 0 to size_x×size_y-1, and totals size_x×size_y data, the embodiment generates a first data sequence of 0 to 35, and all the data meeting the conditions are extracted to form a new data sequence and serve as a first increment hwe, wherein the judging conditions are as follows: assuming that the data is n, if n satisfies (n// size_x)% offset_y= 0, where// is integer division operation and% is remainder operation, for example, when n=2, (2// 6)% 3=0, the corresponding data is selected as required.
Referring to fig. 5, fig. 5 is a schematic diagram of a one-dimensional pooling index according to an embodiment of the present application. The amplified primary relative index idx_hw is added to the first increment hwe to obtain a one-dimensional pooled index offset_h, and the value of each data in the obtained one-dimensional pooled index offset_h is one of 0-35, and the one-dimensional pooled index offset_h represents the index of the first maximum pooling of the image.
In some alternative embodiments, performing a continuous pooling operation in a second direction on the one-dimensional pooled result to obtain a two-dimensional pooled result and a secondary relative index, including:
in the second pooling operation process, pooling operation is carried out on each divided area in the second direction, the step value in the second direction is offset_x, and the size of the secondary relative index is sizey_y×w_idx_x;
wherein w_idx_x= (size_x-filter_x)/offset_x+1; filter_x is the dimension of the pooling filter in the second direction, and offset_x is the step value of the pooling filter in the second direction.
Referring to fig. 6, fig. 6 is a schematic diagram of a secondary relative index according to an embodiment of the application. Carrying out continuous pooling operation in x direction on the one-dimensional pooling result data_y, namely carrying out maximum pooling on each 1X 3 area,
all 1×3 regions constitute the whole one-dimensional pooling result data_y, for example, the 1×3 regions including b0, b1, b2 in the upper left corner are sequentially maximally pooled, the 1×3 regions including b3, b4, b5 in the upper right corner are maximally pooled, the 1×3 regions including b6, b7, b8 in the adjacent (i.e., lower left corner) region to the 3×1 regions including b0, b1, b2 are sequentially maximally pooled, until the 1×3 regions including b9, b10, b11 in the lower right corner are maximally pooled, after completion of the maximum pooling of the 1×3 regions including b3, b4, b5, a secondary relative index w_idx is obtained, the y-direction dimension of the obtained secondary relative index w_idx is sizey_y (the value is 2), the X-direction dimension w_idx_x= (size_x-filter_x)/offset_x+1=2, wherein size_x represents the dimension of the image in the X-direction (the value is 6), filter_x is the dimension of the filter performing the pooling operation in the X-direction (the value is 3), offset_x is the step value of the filter performing the pooling operation in the y-direction (the value is 3), the obtained secondary relative index w_idx is 2×2 data, the value of each data in the secondary relative index w_idx is one of 0,1,2, and wi0-wi3 represents the index in each 1×3 region, so wi0-wi3 are called as secondary relative index w_idx.
In some alternative embodiments, obtaining the index of the one-dimensional pooled index from the two-dimensional pooled result and the secondary relative index comprises:
step S41, obtaining a second increment according to the size of the one-dimensional pooling result and the step value of the second direction;
and step S42, adding the secondary relative index and the second increment to obtain the index of the one-dimensional pooling index.
In step S41, obtaining a second increment according to the size of the one-dimensional pooling result and the step value in the second direction, including:
generating a second data sequence of 0 to sizey_x x sizey_y-1 for a total of sizey_x sizey_y data;
finding all data satisfying (n% sizey_x)// offset_x= 0 in the second data sequence as a second increment; where n is the data in the second data sequence.
Referring to fig. 7, fig. 7 is a schematic diagram of a second increment according to an embodiment of the application. A set of data sequences is generated by the software, from 0 to sizey_x x sizey_y-1, totaling sizey_x sizey_y data, and the eligible data therein is extracted, forming a new data sequence and as a second increment hwc, sizey_x=6 in this embodiment, sizey_y=2. The judgment conditions are as follows: assuming that the data is n, if n satisfies (n% sizey_x)// offset_x= 0, where// is integer and% is remainder, the corresponding data is selected to obtain a second increment hwc, for example, sizey_x=6, offset_x=3, and n=3, where the condition is satisfied, that is, the selection is required.
Referring to fig. 8, fig. 8 is a schematic diagram of an index of a one-dimensional pooled index and a two-dimensional pooled index according to an embodiment of the present application. The second relative index w_idx is added to the second increment hwc to yield the index sg_idx of the one-dimensional pooled index. And (3) taking out all the data with the index value of sg_idx from the data of the one-dimensional pooling result offset_h, namely the final required two-dimensional pooling index, for example, taking out the data of the corresponding position in the one-dimensional pooling result offset_h if the data of sg_idx is 2,5,8,9, namely oh2, oh5, oh8 and oh9.
Referring to fig. 9, fig. 9 is a functional block diagram of a device for maximizing pooling operation according to an embodiment of the present application, where the device includes a continuous pooling operation module 1, a streaming data operation module 2, and a skip module 3. The continuous pooling operation module 1 is used for carrying out continuous pooling operation on the image in a first direction to obtain a one-dimensional pooling result and a one-time relative index; and carrying out continuous pooling operation in a second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index. The stream data operation module 2 is used for obtaining a one-dimensional pooling index according to the one-dimensional pooling result and the primary relative index; obtaining an index of the one-dimensional pooling index according to the two-dimensional pooling result and the secondary relative index; wherein the index of the one-dimensional pooling index is used to indicate the two-dimensional pooling index. And the skip module 3 is used for obtaining the two-dimensional pooling index according to the one-dimensional pooling index and the index of the one-dimensional pooling index.
In the embodiment of the application, the hardware resource in the chip is adopted to calculate the one-dimensional maximum pooling result and the corresponding relative index, and the hardware of the chip can only read the data in one area firstly, calculate the maximum value in the area and obtain the relative index, so that the continuous pooling operation module 1 is utilized to carry out the continuous pooling operation of the first direction on the image, and the one-dimensional pooling result and the one-time relative index are obtained. And then calculating by using the streaming data operation module 2 to obtain a one-dimensional pooling index. And then, carrying out continuous pooling operation in a second direction on the one-dimensional pooling result by using the continuous pooling operation module 1 to obtain a two-dimensional pooling result and a secondary relative index. And calculating by using the streaming data operation module 2 to obtain an index of the one-dimensional pooling index, and finally obtaining the two-dimensional pooling index by using the skip module 3 according to the one-dimensional pooling index and the index of the one-dimensional pooling index. The maximum pooling operation in the embodiment can obtain the maximum pooling result and the corresponding index value simultaneously through hardware resource calculation in the chip, is independent of general control units such as a GPU (graphics processing unit) or a CPU (Central processing Unit), reduces the calculated amount and is easy to realize control logic.
In some alternative embodiments, the streaming data operation module 2 is further configured to: amplifying the primary relative index according to the size of the image in the second direction; obtaining a first increment according to the image size and the first direction stepping value; and adding the amplified primary relative index with the first increment to obtain a one-dimensional pooling index.
In some alternative embodiments, the streaming data operation module 2 is further configured to: obtaining a second increment according to the dimension of the one-dimensional pooling result and the step value in the second direction; and adding the second relative index and the second increment to obtain the index of the one-dimensional pooling index.
In some alternative embodiments, the continuous pooling operation module 1 adopts a unit capable of performing one-dimensional pooling operation, and a one-dimensional pooled index can be obtained. The streaming data operation module 2 employs FMA (a unit capable of operating on streaming data) which can perform logical operations such as addition, subtraction, multiplication, and division. The skip module 3 employs rdma (direct memory access DMA for reading) supporting the skip function.
In some alternative embodiments, the continuous pooling operation module is further configured to: in the first pooling operation process, pooling operation is carried out on each divided area in the first direction, the step value in the first direction is offset_y, and the size of a one-dimensional pooling result is sizey_x×sizey_y; where sizey_x=sizejx, sizejy= (sizejy-filter_y)/offset_y+1; size_x is the size of the image in the second direction, size_y is the size of the image in the first direction, filter_y is the size of the filter in the first direction, and offset_y is the step value of the filter in the first direction.
In some alternative embodiments, the streaming data operation module is further configured to: idx_hw=argmax_y×size_x. Where idx_hw is a primary relative index with an enlarged width, and argmax_y is a primary relative index.
In some alternative embodiments, the streaming data operation module is further configured to: generating a first data sequence of 0 to size_x×size_y-1 for a total of size_x×size_y data; finding all data satisfying (n// size_x)% offset_y= 0 in the first data sequence as a first increment; where n is the data in the first data sequence.
In some alternative embodiments, the continuous pooling operation module is further configured to: in the second pooling operation process, pooling operation is carried out on each divided area in the second direction, the step value in the second direction is offset_x, and the size of the secondary relative index is sizey_y×w_idx_x; wherein w_idx_x= (size_x-filter_x)/offset_x+1; filter_x is the dimension of the pooling filter in the second direction, and offset_x is the step value of the pooling filter in the second direction.
In some alternative embodiments, the streaming data operation module is further configured to: generating a second data sequence of 0 to sizey_x x sizey_y-1 for a total of sizey_x sizey_y data; finding all data satisfying (n% sizey_x)// offset_x= 0 in the second data sequence as a second increment; where n is the data in the second data sequence.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
Further, the units described as separate units may or may not be physically separate, and units displayed as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
Furthermore, functional modules in various embodiments of the present application may be integrated together to form a single portion, or each module may exist alone, or two or more modules may be integrated to form a single portion.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and variations will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (8)

1. A method of maximizing a pooling operation, comprising:
carrying out continuous pooling operation on the image in a first direction to obtain a one-dimensional pooling result and a one-time relative index;
obtaining a one-dimensional pooling index according to the one-dimensional pooling result and the primary relative index;
carrying out continuous pooling operation in a second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index;
obtaining an index of the one-dimensional pooling index according to the two-dimensional pooling result and the secondary relative index; wherein the index of the one-dimensional pooling index is used for indicating a two-dimensional pooling index; and
obtaining a two-dimensional pooling index according to the one-dimensional pooling index and the index of the one-dimensional pooling index;
the continuous pooling operation in the first direction is carried out on the image to obtain a one-dimensional pooling result and a one-time relative index, and the method comprises the following steps:
in the first pooling operation process, pooling operation is carried out on each divided area in the first direction, the step value in the first direction is offset_y, and the size of a one-dimensional pooling result is sizey_x×sizey_y;
the size of the sizey_x is equal to the size of the image in the second direction, and the sizey_y is calculated by the size of the image in the first direction, the size of the filter for carrying out pooling operation in the first direction and the stepping value of the filter for carrying out pooling operation in the first direction;
and performing continuous pooling operation in a second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index, wherein the continuous pooling operation comprises the following steps:
in the second pooling operation process, pooling operation is carried out on each divided area in the second direction, the step value in the second direction is offset_x, and the size of the secondary relative index is sizey_y×w_idx_x;
the w_idx_x is calculated by the size of the image in the second direction, the size of the filter for pooling operation in the second direction and the stepping value of the filter for pooling operation in the second direction;
the obtaining the index of the one-dimensional pooling index according to the two-dimensional pooling result and the secondary relative index comprises the following steps:
obtaining a second increment according to the dimension of the one-dimensional pooling result and the step value in the second direction; and
and adding the second relative index and the second increment to obtain the index of the one-dimensional pooling index.
2. The method of claim 1, wherein the obtaining the one-dimensional pooling index based on the one-dimensional pooling result and the one-time relative index comprises:
amplifying the primary relative index according to the size of the image in the second direction;
obtaining a first increment according to the image size and the first direction stepping value; and
and adding the amplified primary relative index with the first increment to obtain a one-dimensional pooling index.
3. The method of claim 2, wherein the amplifying the primary relative index according to the size of the image in the second direction comprises:
idx_hw=argmax_y×size_x
where idx_hw is a primary relative index with an enlarged width, argmax_y is the primary relative index, and size_x is the size of the image in the second direction.
4. The method of claim 2, wherein the obtaining a first increment based on the image size and the first direction step value comprises:
generating a first data sequence of 0 to size_x×size_y-1 for a total of size_x×size_y data;
finding all data satisfying (n// size_x)% offset_y= 0 in the first data sequence as a first increment; where n is the data in the first data sequence, size_x is the size of the image in the second direction, size_y is the size of the image in the first direction, and offset_y is the step value of the filter in the first direction for pooling operation.
5. The method of claim 1, wherein the obtaining a second increment based on the dimension of the one-dimensional pooling result and the second direction step value comprises:
generating a second data sequence of 0 to sizey_x x sizey_y-1 for a total of sizey_x sizey_y data;
finding all data satisfying (n% sizey_x)// offset_x= 0 in the second data sequence as a second increment; where n is the data in the second data sequence.
6. An apparatus for maximizing a pooling operation, comprising:
the continuous pooling operation module is used for carrying out continuous pooling operation on the image in the first direction to obtain a one-dimensional pooling result and a one-time relative index; carrying out continuous pooling operation in a second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index; the continuous pooling operation in the first direction is carried out on the image to obtain a one-dimensional pooling result and a one-time relative index, and the method comprises the following steps:
in the first pooling operation process, pooling operation is carried out on each divided area in the first direction, the step value in the first direction is offset_y, and the size of a one-dimensional pooling result is sizey_x×sizey_y;
the size of the sizey_x is equal to the size of the image in the second direction, and the sizey_y is calculated by the size of the image in the first direction, the size of the filter for carrying out pooling operation in the first direction and the stepping value of the filter for carrying out pooling operation in the first direction;
and performing continuous pooling operation in a second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index, wherein the continuous pooling operation comprises the following steps:
in the second pooling operation process, pooling operation is carried out on each divided area in the second direction, the step value in the second direction is offset_x, and the size of the secondary relative index is sizey_y×w_idx_x;
the w_idx_x is calculated by the size of the image in the second direction, the size of the filter for pooling operation in the second direction and the stepping value of the filter for pooling operation in the second direction;
the stream data operation module is used for obtaining a one-dimensional pooling index according to the one-dimensional pooling result and the primary relative index; obtaining an index of the one-dimensional pooling index according to the two-dimensional pooling result and the secondary relative index; wherein the index of the one-dimensional pooling index is used for indicating a two-dimensional pooling index; the obtaining the index of the one-dimensional pooling index according to the two-dimensional pooling result and the secondary relative index comprises the following steps:
obtaining a second increment according to the dimension of the one-dimensional pooling result and the step value in the second direction; and
adding the second relative index and the second increment to obtain an index of the one-dimensional pooling index
And the skip module is used for obtaining the two-dimensional pooling index according to the one-dimensional pooling index and the index of the one-dimensional pooling index.
7. The apparatus of claim 6, wherein the streaming data operation module is further to:
amplifying the primary relative index according to the size of the image in the second direction;
obtaining a first increment according to the image size and the first direction stepping value; and
and adding the amplified primary relative index with the first increment to obtain a one-dimensional pooling index.
8. The apparatus of claim 6, wherein the streaming data operation module is further to:
obtaining a second increment according to the dimension of the one-dimensional pooling result and the step value in the second direction; and
and adding the second relative index and the second increment to obtain the index of the one-dimensional pooling index.
CN202210420612.0A 2022-04-20 2022-04-20 Method and device for maximum pooling operation Active CN115828079B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210420612.0A CN115828079B (en) 2022-04-20 2022-04-20 Method and device for maximum pooling operation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210420612.0A CN115828079B (en) 2022-04-20 2022-04-20 Method and device for maximum pooling operation

Publications (2)

Publication Number Publication Date
CN115828079A CN115828079A (en) 2023-03-21
CN115828079B true CN115828079B (en) 2023-08-11

Family

ID=85522486

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210420612.0A Active CN115828079B (en) 2022-04-20 2022-04-20 Method and device for maximum pooling operation

Country Status (1)

Country Link
CN (1) CN115828079B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019085709A1 (en) * 2017-11-01 2019-05-09 腾讯科技(深圳)有限公司 Pooling method and system applied to convolutional neural network
CN110503193A (en) * 2019-07-25 2019-11-26 福州瑞芯微电子股份有限公司 A kind of pond operation method and circuit based on ROI
CN111028235A (en) * 2019-11-11 2020-04-17 东北大学 Image segmentation method for enhancing edge and detail information by utilizing feature fusion
CN112115793A (en) * 2020-08-19 2020-12-22 河海大学 Remote sensing image change detection method based on improved Segnet
CN112395008A (en) * 2019-08-13 2021-02-23 上海寒武纪信息科技有限公司 Operation method, operation device, computer equipment and storage medium
CN112395009A (en) * 2019-08-13 2021-02-23 上海寒武纪信息科技有限公司 Operation method, operation device, computer equipment and storage medium
CN113242433A (en) * 2021-04-27 2021-08-10 中国科学院国家空间科学中心 Image compression method and image compression system based on ARM multi-core heterogeneous processor

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019085709A1 (en) * 2017-11-01 2019-05-09 腾讯科技(深圳)有限公司 Pooling method and system applied to convolutional neural network
CN110503193A (en) * 2019-07-25 2019-11-26 福州瑞芯微电子股份有限公司 A kind of pond operation method and circuit based on ROI
CN112395008A (en) * 2019-08-13 2021-02-23 上海寒武纪信息科技有限公司 Operation method, operation device, computer equipment and storage medium
CN112395009A (en) * 2019-08-13 2021-02-23 上海寒武纪信息科技有限公司 Operation method, operation device, computer equipment and storage medium
CN111028235A (en) * 2019-11-11 2020-04-17 东北大学 Image segmentation method for enhancing edge and detail information by utilizing feature fusion
CN112115793A (en) * 2020-08-19 2020-12-22 河海大学 Remote sensing image change detection method based on improved Segnet
CN113242433A (en) * 2021-04-27 2021-08-10 中国科学院国家空间科学中心 Image compression method and image compression system based on ARM multi-core heterogeneous processor

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于批次图像化的卷积自编码故障监测方法;张海利等;《控制与决策》;第第36卷卷(第第6期期);第1361-1367页 *

Also Published As

Publication number Publication date
CN115828079A (en) 2023-03-21

Similar Documents

Publication Publication Date Title
US11609968B2 (en) Image recognition method, apparatus, electronic device and storage medium
US20220114708A1 (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN111862251B (en) Method, device, storage medium and electronic equipment for medical image reconstruction technology
US11822900B2 (en) Filter processing device and method of performing convolution operation at filter processing device
CN115828079B (en) Method and device for maximum pooling operation
CN114936633B (en) Data processing unit for transposition operation and image transposition operation method
CN112991274A (en) Crowd counting method and device, computer equipment and storage medium
CN112163949A (en) Intelligent contract generation method and device based on contract component imaging
CN111966473A (en) Operation method and device of linear regression task and electronic equipment
CN110662188B (en) Charging method and system
CN111083479A (en) Video frame prediction method and device and terminal equipment
CN113905066B (en) Networking method of Internet of things, networking device of Internet of things and electronic equipment
CN113657408B (en) Method and device for determining image characteristics, electronic equipment and storage medium
CN115147297A (en) Image processing method and device
CN115809959A (en) Image processing method and device
CN114003859A (en) Convolution operation method, readable medium and electronic device
CN113326404A (en) Data flow graph processing method, device, equipment and storage medium
CN116152043B (en) Memory management method and device based on image processing and electronic equipment
CN116009792B (en) Data reading and writing device and method in image processing and electronic equipment
CN113591764B (en) Gesture recognition method and device, storage medium and electronic equipment
CN111325117B (en) Training method and device for target object recognition model and electronic equipment
CN116994002B (en) Image feature extraction method, device, equipment and storage medium
CN112669212B (en) Face image super-resolution reconstruction method, device, computer equipment and medium
CN113220456A (en) Bill data processing method and related device
CN114970415A (en) Circuit generation method and device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant