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

Method and device for maximum pooling operation Download PDF

Info

Publication number
CN115828079A
CN115828079A CN202210420612.0A CN202210420612A CN115828079A CN 115828079 A CN115828079 A CN 115828079A CN 202210420612 A CN202210420612 A CN 202210420612A CN 115828079 A CN115828079 A CN 115828079A
Authority
CN
China
Prior art keywords
index
pooling
size
dimensional
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.)
Granted
Application number
CN202210420612.0A
Other languages
Chinese (zh)
Other versions
CN115828079B (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

Images

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, performing continuous pooling operation on the one-dimensional pooling result in the second direction 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 of the embodiment can simultaneously obtain the maximum pooling result and the corresponding index value through hardware resource calculation in the chip, does not depend on a general control unit such as a GPU or a CPU, reduces the calculation amount and is easy to realize control logic.

Description

Method and device for maximum pooling operation
Technical Field
The present application relates to the field of integrated circuit technology design, and in particular, to a method and an apparatus for maximum pooling operation.
Background
The maximum pooling is an operation commonly used in a neural network, which can reduce the receptive field of an image and realize the dimension reduction of the image, and a pooling operation is usually added after the convolution operation, for example, the maximum pooling is a result for calculating the maximum pooling. However, the conventional maximum pooling operation cannot generate the maximum pooling index while obtaining the maximum pooling result, and the generation of the maximum 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 a huge amount of computation and complicated control.
Disclosure of Invention
An object of the embodiments of the present application is to provide a method and an apparatus for maximal pooling operation, so as to solve the problem that the existing maximal pooling operation cannot generate a maximal pooling index while obtaining a maximal pooling result.
The method for maximum 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 relative index;
obtaining a one-dimensional pooling index according to the one-dimensional pooling result and the one-time relative index;
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;
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, hardware resources in the chip may be used to calculate a one-dimensional maximum pooling result and a corresponding relative index, and since the hardware of the chip can only read data in one region first, calculate a maximum value in the region and obtain the relative index, the image is subjected to continuous pooling operation in the first direction to obtain a one-dimensional pooling result and a relative index, and then the one-dimensional pooling index is obtained by calculation. And then, performing continuous pooling operation on the one-dimensional pooling result in the second direction 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 present embodiment can obtain the maximum pooling result and the corresponding index value at the same time.
In some optional embodiments, obtaining the one-dimensional pooling index according to the one-dimensional pooling result and the one-time relative index includes:
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 and the first increment to obtain a one-dimensional pooling index.
In some optional embodiments, obtaining the index of the one-dimensional pooling index according to the two-dimensional pooling result and the quadratic relative index includes:
obtaining a second increment according to the size of the one-dimensional pooling result and the stepping value in the second direction; and
and adding the secondary relative index and the second increment to obtain the index of the one-dimensional pooling index.
In some optional embodiments, performing a continuous pooling operation in a first direction on the image to obtain a one-dimensional pooling result and a relative index, includes:
in the first pooling operation process, pooling operation is carried out on each divided area in the first direction, the stepping value in the first direction is offset _ y, and the size of a one-dimensional pooling result is obtained as sizey _ x × sizey _ y;
wherein, size _ x = size _ x, size _ y = (size _ y-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 for pooling, and offset _ y is the step value of the filter in the first direction for pooling.
In some optional embodiments, the enlarging the relative index once according to the size of the image in the second direction includes performing the following operations:
idx_hw=argmax_y×size_x
wherein idx _ hw is a relative index of one time after the width is enlarged, and argmax _ y is a relative index of one time.
In some optional embodiments, obtaining the first increment according to the image size and the first direction stepping value includes:
generating a first data sequence of 0 to size _ x × size _ y-1, totaling size _ x × size _ y data;
finding all data in the first data sequence that satisfy (n// size _ x)% offset _ y = =0, and as a first increment; wherein n is data in the first data sequence.
In some optional embodiments, performing a continuous pooling operation in the second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index includes:
in the second pooling operation process, pooling operation is performed on each divided area in the second direction, the stepping value in the second direction is offset _ x, and the size of the secondary relative index is obtained as sizey _ y × w _ idx _ x;
wherein w _ idx _ x = (size _ x-filter _ x)/offset _ x +1; filter _ x is the size of the filter for pooling in the second direction, and offset _ x is the step value of the filter for pooling in the second direction.
In some optional embodiments, obtaining the second increment according to the size of the one-dimensional pooling result and the second direction stepping value includes:
generating a second data sequence of 0 to sizey _ x × sizey _ y-1, totaling sizey _ x × sizey _ y data;
finding all data in the second data sequence that satisfy (n% sized _ x)// offset _ x = =0 and as a second increment; wherein n is data in the second data sequence.
The device of the biggest pooling operation that this application embodiment provided includes:
the continuous pooling operation module is used for carrying out continuous pooling operation on the image in a first direction to obtain a one-dimensional pooling result and a relative index; 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;
the stream data operation module is used for obtaining a one-dimensional pooling index according to the one-dimensional pooling result and the one-time 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, hardware resources in the chip are used to calculate a one-dimensional maximum pooling result and a corresponding relative index, and since the hardware of the chip can only read data in one region first, calculate a maximum value in the region and obtain the relative index, a continuous pooling operation module is used to perform continuous pooling operation in a first direction on the image to obtain the one-dimensional pooling result and one-time relative index. And then calculating by using a stream data operation module to obtain a one-dimensional pooling index. And then, utilizing a continuous pooling operation module to perform 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. And finally, obtaining a two-dimensional pooling index by utilizing a skip module according to the one-dimensional pooling index and the index of the one-dimensional pooling index. The maximum pooling operation of the embodiment can simultaneously obtain the maximum pooling result and the corresponding index value through hardware resource calculation in the chip, does not depend on a general control unit such as a GPU or a CPU, reduces the calculation amount and is easy to realize control logic.
In some optional 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 one-time relative index and the first increment to obtain a one-dimensional pooling index.
In some optional embodiments, the streaming data operation module is further configured to:
obtaining a second increment according to the size of the one-dimensional pooling result and the stepping value in the second direction; and
and adding the secondary relative index and the second increment to obtain the index of the one-dimensional pooling index.
In some optional 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 stepping value in the first direction is offset _ y, and the size of a one-dimensional pooling result is obtained as sizey _ x × sizey _ y;
wherein, size _ x = size _ x, size _ y = (size _ y-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 for pooling, and offset _ y is the step value of the filter in the first direction for pooling.
In some optional embodiments, the streaming data operation module is further configured to:
idx_hw=argmax_y×size_x
wherein idx _ hw is a relative index of the width after enlargement, and argmax _ y is a relative index of the width after enlargement.
In some optional embodiments, the streaming data operation module is further configured to:
generating a first data sequence of 0 to size _ x × size _ y-1, totaling size _ x × size _ y data;
finding all data in the first data sequence that satisfy (n// size _ x)% offset _ y = =0 as a first increment; wherein n is data in the first data sequence.
In some optional embodiments, the continuous pooling operation module is further configured to:
in the second pooling operation process, pooling operation is performed on each divided area in the second direction, the stepping value in the second direction is offset _ x, and the size of the secondary relative index is obtained as sizey _ y × w _ idx _ x;
wherein w _ idx _ x = (size _ x-filter _ x)/offset _ x +1; filter _ x is the size of the filter for pooling operation in the second direction, and offset _ x is the step value of the filter for pooling operation in the second direction.
In some optional embodiments, the streaming data operation module is further configured to:
generating a second data sequence of 0 to sizey _ x × sizey _ y-1, totaling sizey _ x × sizey _ y data;
finding all data in the second data sequence that satisfy (n% sized _ x)// offset _ x = =0 and as a second increment; wherein n is 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 required to be used 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 therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
FIG. 1 is a flowchart illustrating method steps for max-pooling operation according to an embodiment of the present disclosure;
FIG. 2 is a schematic diagram of an image, one-dimensional pooling results, and a one-time relative index according to an embodiment of the present application;
FIG. 3 is a diagram illustrating relative indexing after being magnified once according to an embodiment of the present application;
FIG. 4 is a diagram illustrating a first data sequence and a first increment provided by an embodiment of the present application;
FIG. 5 is a diagram illustrating a one-dimensional pooling index provided by an embodiment of the present application;
FIG. 6 is a schematic diagram of a quadratic 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 diagram illustrating an index of a one-dimensional pooling index and a two-dimensional pooling index provided by an embodiment of the present application;
fig. 9 is a functional block diagram of an apparatus for max-pooling operation according to an embodiment of the present application.
Icon: the system comprises a 1-continuous pooling operation module, a 2-streaming data operation module and a 3-skip module.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
Referring to fig. 1, fig. 1 is a flowchart illustrating steps of a method for max-pooling operation according to an embodiment of the present disclosure, including:
s1, performing continuous pooling operation on the image in a first direction to obtain a one-dimensional pooling result and a relative index;
s2, obtaining a one-dimensional pooling index according to the one-dimensional pooling result and the one-time relative index;
s3, 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;
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, hardware resources in a chip are used for calculating a one-dimensional maximum pooling result and a corresponding relative index, and since the hardware of the chip can only read data in one area first, calculate the maximum value in the area and obtain the relative index, continuous pooling operation in the first direction is performed on an image to obtain the one-dimensional pooling result and one relative index, and then the one-dimensional pooling index is obtained through calculation. And then, 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, 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 of the embodiment can simultaneously obtain the maximum pooling result and the corresponding index value through hardware resource calculation in the chip, does not depend on a general control unit such as a GPU or a CPU, reduces the calculation amount and is easy to realize control logic.
It should be clear that, in some optional 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 maximum pooling of filter sizes of filter _ y =3, filter_x =3, step values of offset _ y =3, and offset_x =3 will be exemplified.
In some optional embodiments, performing a continuous pooling operation in a first direction on the image to obtain a one-dimensional pooling result and a relative index, includes:
in the first pooling operation process, pooling operation is carried out on each divided area in the first direction, the stepping value in the first direction is offset _ y, and the size of a one-dimensional pooling result is obtained as sizey _ x × sizey _ y;
wherein, size _ x = size _ x, size _ y = (size _ y-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 for pooling, and offset _ y is the step value of the filter in the first direction for pooling.
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, in which a continuous pooling operation in a first direction (y-axis direction) is performed on an image with size _ y × size _ x (i.e. 6 × 6), i.e. maximal pooling is performed on each 3 × 1 region, all 3 × 1 regions constitute the entire image, e.g. starting from the 3 × 1 region containing a0, a1, a2 in the upper left corner, a3 × 1 region shifted to the right is maximal pooled in sequence, and after the maximal pooling of the 3 × 1 region containing a5, a11, a17 in the upper right corner is completed, a3 × 1 region containing a18, a24, a30 adjacent to the 3 × 1 region of a0, a1, a2 (i.e. in the lower left corner) is maximal pooling sequentially performed on the 3 × 1 region shifted to the right, until the maximal pooling of the 3 × 1 area containing a23, a29, a35 in the bottom right corner is completed, a one-dimensional pooling result data _ y is obtained, the size of the one-dimensional pooling result data _ y is size _ x × size _ y, where size _ x =6, i.e. the image width size _ x before calculation, size _ y is the size of the image after calculation, the calculation formula is size _ y = (size _ y-filter _ y)/offset _ y +1=2, where size _ y represents the size of the original image in the y direction (value 6), filter _ y is the size of the filter performing the pooling operation in the y direction (value 3), offset _ y is the step value of the filter performing the pooling operation in the y direction (value 3), and a relative index armax _ y of the same size is obtained, and one of the values 0-11, 0 of the one relative index armax _ y is 0, 11, 2, ay0-ay11 denote indices within each 3 × 1 region, respectively, so ay0-ay11 are referred to as a one-time relative index argmax _ y.
In some optional embodiments, obtaining the one-dimensional pooling index according to the one-dimensional pooling result and the one-time relative index includes:
s21, amplifying the primary relative index according to the size of the image in the second direction;
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 and the first increment to obtain a one-dimensional pooling index.
In some optional embodiments, the enlarging the relative index once according to the size of the image in the second direction includes performing the following operations:
idx_hw=argmax_y×size_x
wherein idx _ hw is a relative index of the width after enlargement, and argmax _ y is a relative index of the width after enlargement.
Referring to fig. 3, fig. 3 is a schematic diagram of the first relative index provided by the embodiment of the present application after being enlarged, where each data in the first relative index argmax _ y is multiplied by a size _ x of the image in the x direction by using a streaming data operation module, for example, hw0= ay0 × 6.
In some optional embodiments, obtaining the first increment according to the image size and the first direction stepping value includes:
generating a first data sequence of 0 to size _ x × size _ y-1, totaling size _ x × size _ y data;
finding all data in the first data sequence that satisfy (n// size _ x)% offset _ y = =0, and as a first increment; wherein n is 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 present application. A group of data sequences is generated by software, the data sequences are from 0 to size _ x × size _ y-1, and the size _ x × size _ y data are counted, in this embodiment, a first data sequence of 0 to 35 is generated, and data meeting conditions are all taken out to form a new data sequence and serve as a first increment hwe, wherein the judgment conditions are as follows: assuming that the data is n, if n satisfies (n// size _ x)% offset _ y =0, where// is integer division operation,% is remainder operation, for example, when n =2, (2// 6)% 3=0, satisfies the requirement, the corresponding data is selected.
Referring to fig. 5, fig. 5 is a schematic diagram of a one-dimensional pooling index according to an embodiment of the present disclosure. The amplified primary relative index idx _ hw is added to the first increment hwe to obtain a one-dimensional pooling index offset _ h, and the value of each datum in the obtained one-dimensional pooling index offset _ h is one of 0 to 35, and the one-dimensional pooling index offset _ h is an index representing the first maximum pooling of the image.
In some optional embodiments, performing a continuous pooling operation in the second direction on the one-dimensional pooling result to obtain a two-dimensional pooling result and a secondary relative index includes:
in the second pooling operation process, pooling operation is performed on each divided area in the second direction, the stepping value in the second direction is offset _ x, and the size of the secondary relative index is obtained as sizey _ y × w _ idx _ x;
wherein w _ idx _ x = (size _ x-filter _ x)/offset _ x +1; filter _ x is the size of the filter for pooling in the second direction, and offset _ x is the step value of the filter for pooling in the second direction.
Referring to fig. 6, fig. 6 is a schematic diagram of a secondary relative index provided in the embodiment of the present application. Performing continuous pooling operation in the x direction on the one-dimensional pooling result data _ y, namely performing maximal pooling on each 1 × 3 area,
all the 1 × 3 regions constitute the whole one-dimensional pooling result data _ y, for example, starting from the 1 × 3 region containing b0, b1, b2 at the upper left corner, performing maximum pooling on the rightward shifted 1 × 3 regions in sequence, after the maximum pooling of the 1 × 3 region containing b3, b4, b5 at the upper right corner is completed, performing maximum pooling on the rightward shifted 1 × 3 region starting from the 1 × 3 region containing b6, b7, b8 adjacent to (i.e. at the lower left corner) the 3 × 1 region of b0, b1, b2 until the maximum pooling of the 1 × 3 region containing b9, b10, b11 at the lower right corner is completed, obtaining a quadratic relative index w _ idx, wherein the obtained quadratic relative index w _ idx has a y-direction size (2), the X-direction size w _ idx _ X = (size _ X-X)/X _ X + 2, and the obtained quadratic relative index w _ idx is a filter size (X-X) which represents a value of 0, 2, and thus the filter data obtained by performing a step operation on each of the quadratic relative index w _ 3 and the filter.
In some optional embodiments, obtaining the index of the one-dimensional pooling index according to the two-dimensional pooling result and the quadratic relative index includes:
s41, obtaining a second increment according to the size of the one-dimensional pooling result and the stepping value in the second direction;
and 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 second-direction step value, including:
generating a second data series of 0 to size _ x × size _ y-1, totaling size _ x × size _ y data;
finding all data in the second data sequence that satisfy (n% sized _ x)// offset _ x = =0 and as a second increment; wherein n is 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 present application. A set of data sequences is generated by software, from 0 to sizey _ x × sizey _ y-1, and sizey _ x × sizey _ y data are summed, and the data meeting the conditions are taken out to form a new data sequence as the second increment hwc, wherein sizey _ x =6 and sizey _y =2 in the embodiment. The judgment conditions are as follows: assuming that the data is n, if n satisfies (n% sizey _ x)// offset _ x = =0, where// is an integer division,% is a remainder operation, the corresponding data is selected to obtain the second increment hwc, for example, when sizey _ x =6, offset \\/u x =3, and n =3, the condition is satisfied, that is, the data needs to be selected.
Referring to fig. 8, fig. 8 is a schematic diagram of an index of a one-dimensional pooling index and a two-dimensional pooling index provided in an embodiment of the present application. And adding the secondary relative index w _ idx and the second increment hwc to obtain the index sg _ idx of the one-dimensional pooling index. All the data with the index value sg _ idx are extracted from the data of the one-dimensional pooling result offset _ h, i.e. the data are the two-dimensional pooling indexes finally needed, for example, assuming that the data of sg _ idx are 2,5,8, and 9, the data at the corresponding positions in the one-dimensional pooling result offset _ h are extracted, i.e. oh2, oh5, oh8, and oh9.
Referring to fig. 9, fig. 9 is a functional block diagram of an apparatus for maximum pooling operation according to an embodiment of the present disclosure, where the apparatus 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 performing continuous pooling operation on the image in a first direction to obtain a one-dimensional pooling result and a one-time relative index; 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. The stream data operation module 2 is used for obtaining a one-dimensional pooling index according to the one-dimensional pooling result and the one-time 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 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 present application, hardware resources in a chip are used to calculate a one-dimensional maximum pooling result and a corresponding relative index, and since hardware of the chip can only read data in one region first, calculate a maximum value in the region and obtain the relative index, a continuous pooling operation module 1 is used to perform continuous pooling operation in a first direction on an image to obtain a one-dimensional pooling result and a one-time relative index. And then a one-dimensional pooling index is calculated by utilizing the stream data operation module 2. And then, utilizing the continuous pooling operation module 1 to perform 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. And finally, 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. The maximum pooling operation of the embodiment can simultaneously obtain the maximum pooling result and the corresponding index value through hardware resource calculation in the chip, does not depend on a general control unit such as a GPU or a CPU, reduces the calculation amount and is easy to realize control logic.
In some optional 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 one-time relative index and the first increment to obtain a one-dimensional pooling index.
In some optional embodiments, the streaming data operation module 2 is further configured to: obtaining a second increment according to the size of the one-dimensional pooling result and the stepping value in the second direction; and adding the secondary 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 employs a unit capable of performing one-dimensional pooling operation, and may obtain one-dimensional pooled indexes. The streaming data arithmetic block 2 uses FMA (means capable of arithmetic on streaming data) and can perform logical operations such as addition, subtraction, multiplication, division, and the like. The skip module 3 employs rdma (direct memory access DMA for reading) supporting a skip function.
In some optional 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 stepping value in the first direction is offset _ y, and the size of a one-dimensional pooling result is obtained as sizey _ x × sizey _ y; wherein, size _ x = size _ x, size _ y = (size _ y-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 for pooling, and offset _ y is the step value of the filter in the first direction for pooling.
In some optional embodiments, the streaming data operation module is further configured to: idx _ hw = argmax _ y × size _ x. Wherein idx _ hw is a relative index of the width after enlargement, and argmax _ y is a relative index of the width after enlargement.
In some optional embodiments, the streaming data operation module is further configured to: generating a first data sequence of 0 to size _ x × size _ y-1, totaling size _ x × size _ y data; finding all data in the first data sequence that satisfy (n// size _ x)% offset _ y = =0, and as a first increment; wherein n is data in the first data sequence.
In some optional embodiments, the continuous pooling operation module is further configured to: in the second pooling operation process, pooling operation is performed on each divided area in the second direction, the stepping value in the second direction is offset _ x, and the size of the secondary relative index is obtained as sizey _ y × w _ idx _ x; wherein w _ idx _ x = (size _ x-filter _ x)/offset _ x +1; filter _ x is the size of the filter for pooling in the second direction, and offset _ x is the step value of the filter for pooling in the second direction.
In some optional embodiments, the streaming data operation module is further configured to: generating a second data series of 0 to size _ x × size _ y-1, totaling size _ x × size _ y data; finding all data in the second data sequence that satisfy (n% sized _ x)// offset _ x = =0 and as a second increment; wherein n is 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 ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be through some communication interfaces, indirect coupling or communication connection between devices or units, and may be in an electrical, mechanical or other form.
In addition, units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
Furthermore, the functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
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 changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (11)

1. A method of max-pooling operations, comprising:
carrying out continuous pooling operation on the image in a first direction to obtain a one-dimensional pooling result and a relative index;
obtaining a one-dimensional pooling index according to the one-dimensional pooling result and the primary relative index;
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;
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
and obtaining a two-dimensional pooling index according to the one-dimensional pooling index and the index of the one-dimensional pooling index.
2. The method of claim 1, wherein performing successive pooling operations on the image in a first direction to obtain a one-dimensional pooling result and a relative index comprises:
in the first pooling operation process, pooling operation is carried out on each divided area in the first direction, the stepping value in the first direction is offset _ y, and the size of a one-dimensional pooling result is obtained as sizey _ x × sizey _ y;
wherein, the size _ x is equal to the size of the image in the second direction, and the size _ y is calculated by the size of the image in the first direction, the size of the filter for performing the pooling operation in the first direction and the step value of the filter for performing the pooling operation in the first direction.
3. The method of claim 1, wherein obtaining a one-dimensional pooling index based on the one-dimensional pooling result and the one-dimensional 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 and the first increment to obtain a one-dimensional pooling index.
4. The method of claim 3, wherein said magnifying the relative index one time according to a size of the image in the second direction comprises:
idx_hw=argmax_y×size_x
wherein idx _ hw is a relative index of the first time after the width is enlarged, argmax _ y is the relative index of the first time, and size _ x is the size of the image in the second direction.
5. The method of claim 3, wherein obtaining the first increment based on the image size and the first directional step value comprises:
generating a first data sequence of 0 to size _ x × size _ y-1, totaling size _ x × size _ y data;
finding all data in the first data sequence that satisfy (n// size _ x)% offset _ y = =0, and 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 for pooling operation in the first direction.
6. The method of claim 2, wherein performing successive pooling operations in a second direction on the one-dimensional pooled result to obtain a two-dimensional pooled result and a quadratic relative index comprises:
in the second pooling operation process, pooling operation is performed on each divided area in the second direction, the stepping value in the second direction is offset _ x, and the size of the secondary relative index is obtained as sizey _ y × w _ idx _ x;
wherein 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 step value of the filter for pooling operation in the second direction.
7. The method of claim 6, wherein obtaining the index of the one-dimensional pooling index based on the two-dimensional pooling result and the quadratic relative index comprises:
obtaining a second increment according to the size of the one-dimensional pooling result and the stepping value in the second direction; and
and adding the secondary relative index and the second increment to obtain the index of the one-dimensional pooling index.
8. The method of claim 7, wherein obtaining the second increment based on the size of the one-dimensional pooling result and the second directional step value comprises:
generating a second data sequence of 0 to sizey _ x × sizey _ y-1, totaling sizey _ x × sizey _ y data;
finding all data in the second data sequence that satisfy (n% sized _ x)// offset _ x = =0 and as a second increment; wherein n is data in the second data sequence.
9. An apparatus for max-pooling operations, comprising:
the continuous pooling operation module is used for carrying out continuous pooling operation on the image in a first direction to obtain a one-dimensional pooling result and a relative index; 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;
the stream data operation module is used for obtaining a one-dimensional pooling index according to the one-dimensional pooling result and the one-time 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 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.
10. The apparatus of claim 9, 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 one-time relative index and the first increment to obtain a one-dimensional pooling index.
11. The apparatus of claim 9, wherein the streaming data operation module is further to:
obtaining a second increment according to the size of the one-dimensional pooling result and the stepping value in the second direction; and
and adding the secondary 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 true CN115828079A (en) 2023-03-21
CN115828079B 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 (2)

* Cited by examiner, † Cited by third party
Title
G. E. SPOORTHI等: "PhaseNet: A Deep Convolutional Neural Network for Two-Dimensional Phase Unwrapping", 《IEEE SIGNAL PROCESSING LETTERS 》, vol. 26, no. 1, pages 54 - 58, XP011702800, DOI: 10.1109/LSP.2018.2879184 *
张海利等: "基于批次图像化的卷积自编码故障监测方法", 《控制与决策》, vol. 36, no. 6, pages 1361 - 1367 *

Also Published As

Publication number Publication date
CN115828079B (en) 2023-08-11

Similar Documents

Publication Publication Date Title
CN111143446A (en) Data structure conversion processing method and device of data object and electronic equipment
CN111476718A (en) Image amplification method and device, storage medium and terminal equipment
CN113486612A (en) Integrated circuit design method, device, electronic equipment and readable storage medium
CN111476017B (en) Webpage form editing method and device and electronic equipment
US10895919B2 (en) Gesture control method and apparatus for display screen
CN115828079A (en) Method and device for maximum pooling operation
CN112991274A (en) Crowd counting method and device, computer equipment and storage medium
CN109324838B (en) Execution method and execution device of single chip microcomputer program and terminal
CN115935909A (en) File generation method and device and electronic equipment
CN116109481A (en) Scaling method, chip, storage medium and electronic device
CN116594589B (en) Method, device and arithmetic logic unit for floating point number multiplication calculation
Tseng et al. Obstacle-aware longest-path routing with parallel milp solvers
CN113313492A (en) Electronic certificate generation method and related device
CN111552478A (en) Apparatus, method and storage medium for generating CUDA program
CN115185503B (en) Front-end low-code development method and device, electronic equipment and medium
CN117094268B (en) Inter-grid data transmission method and device, storage medium and electronic equipment
CN111756997B (en) Pixel storage method and device, computer equipment and readable storage medium
CN117112446B (en) Editor debugging method and device, electronic equipment and medium
WO2021161532A1 (en) Device, method and program for loop unrolling processing
US20240135495A1 (en) Optimized image processing filter
US20140143740A1 (en) Polygon recovery for vlsi mask correction
CN113220456A (en) Bill data processing method and related device
CN114296674A (en) Screen adaptation method and device, computer equipment and storage medium
US20190303102A1 (en) Output value generator circuit, processor, output value generation method and non-transitory computer readable medium
CN114547412A (en) Crawler code 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