MaxPool2d hardware data processing method based on merged masks
By using a merge mask method to process MaxPool2d hardware data, the problems of resource waste and low efficiency caused by discontinuous effective data are solved, and efficient data processing is achieved.
Patent Information
- Application Number
- CN202511213744.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-28
- Publication Date
- 2025-12-02
AI Technical Summary
In the pooling layer operation of neural networks, the effective data is discontinuous when the dilation parameter is not 1 during the MaxPool2d calculation, resulting in wasted hardware resources and low data processing efficiency.
A merge mask-based approach is adopted, which obtains the data loading mask and the hole mask through a preset joint mask calculation method. Combined with MaxPool2d hardware processing, the target standard data loading joint mask is received in real time to remove invalid data and hole data.
It improves hardware data processing efficiency, reduces resource waste, simplifies processing steps, and increases the accuracy of data processing.
Smart Images

Figure CN121052307A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a MaxPool2d hardware data processing method based on a merge mask. Background Technology
[0002] In the pooling layer operations of neural networks, typically implemented in hardware as MaxPool2d, the data block fetched by a single instruction may contain both valid data required for a pooling calculation and irrelevant invalid data due to data alignment, data continuity, or other reasons. During the MaxPool2d calculation, when the dilation parameter is not 1, the valid data required for a single pooling calculation is not continuous and requires interval fetching, meaning there are gaps between the data.
[0003] In the process of developing this invention, the inventors discovered the following shortcomings in the existing technology: Currently, invalid data can be removed by manipulating the extracted data blocks. This can also generally be achieved through shifting or discrete data retrieval methods. However, due to the complexity of the hardware design's dilation parameter interval retrieval method, more hardware resources are used. In architectures with limited hardware resources, this is extremely difficult, severely impacting performance, leading to resource waste and low data processing efficiency. Summary of the Invention
[0004] This invention provides a MaxPool2d hardware data processing method based on a merge mask, which improves the efficiency of hardware data processing and reduces resource waste.
[0005] According to one aspect of the present invention, a MaxPool2d hardware data processing method based on a merge mask is provided, comprising:
[0006] Get the current block of data to be processed;
[0007] The system acquires and calculates the current data loading mask and the current hole mask based on the current hardware loading data block size and the pooled window joint description data, using a preset joint mask calculation method.
[0008] By using a pre-set AND operation processing method, the current data loading mask and the current hole mask are processed to obtain the target standard data loading joint mask;
[0009] The MaxPool2d hardware receives the target standard data loading joint mask in real time, processes the current data block to be processed according to the pre-set mask operation processing method, obtains the current standard valid data block, and feeds back the current standard valid data block to the user.
[0010] According to another aspect of the present invention, a MaxPool2d hardware data processing apparatus based on a merge mask is provided, comprising:
[0011] The current pending data block acquisition module is used to acquire the current pending data block;
[0012] The current data loading mask and current hole mask calculation module is used to obtain and calculate the current data loading mask and current hole mask based on the current hardware loading data block size and pooled window joint description data, using a preset joint mask calculation method.
[0013] The target standard data loading joint mask determination module is used to process the current data loading mask and the current hole mask through a pre-set AND operation processing method to obtain the target standard data loading joint mask;
[0014] The current standard valid data block determination and feedback module is used to receive the target standard data loading joint mask in real time through the MaxPool2d hardware, process the current data block to be processed according to the pre-set mask operation processing method, obtain the current standard valid data block, and feed back the current standard valid data block to the user.
[0015] According to another aspect of the present invention, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the MaxPool2d hardware data processing method based on a merge mask as described in any embodiment of the present invention.
[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the MaxPool2d hardware data processing method based on a merge mask as described in any embodiment of the present invention.
[0017] The technical solution of this invention involves: acquiring the current data block to be processed; acquiring and calculating the current data loading mask and the current hole mask based on the current hardware-loaded data block size and pooled window joint description data using a preset joint mask calculation method; processing the current data loading mask and the current hole mask using a preset AND operation processing method to obtain a target standard data loading joint mask; receiving the target standard data loading joint mask in real time through the MaxPool2d hardware, and processing the current data block to be processed according to the preset mask operation processing method to obtain a current standard valid data block, and then providing feedback on the current standard valid data block to the user. This solves the problems of wasted hardware data processing resources and low data processing efficiency in MaxPool2d, improves hardware data processing efficiency, and reduces resource waste.
[0018] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart of a MaxPool2d hardware data processing method based on a merging mask according to Embodiment 1 of the present invention;
[0021] Figure 2 This is a schematic diagram of the structure of a MaxPool2d hardware data processing device based on a merging mask according to Embodiment 2 of the present invention;
[0022] Figure 3 This is a schematic diagram of the structure of an electronic device provided according to Embodiment 3 of the present invention. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0024] It should be noted that the terms "target," "current," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0025] It is worth noting that the information collected in the technical solution of this application is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data all comply with the relevant laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse; if the user chooses to refuse, the process will proceed to the expert decision-making process.
[0026] Example 1
[0027] Figure 1 The flowchart of the MaxPool2d hardware data processing method based on merging mask is provided in Embodiment 1 of the present invention. This embodiment is applicable to the case of removing invalid data and hole data from MaxPool2d hardware data. The method can be executed by a MaxPool2d hardware data processing device based on merging mask, which can be implemented in hardware and / or software.
[0028] Correspondingly, such as Figure 1 As shown, the method includes:
[0029] S110. Obtain the current data block to be processed.
[0030] In this embodiment, the current data block to be processed can be obtained in real time. Assuming that the size of the current data block to be processed is 100*100, since the current data block to be processed is relatively large, it needs to be divided into corresponding sub-blocks for hardware data processing operations.
[0031] In this embodiment, the data in the current data block to be processed can be a 32-bit floating-point number.
[0032] S120. Obtain and calculate the current data loading mask and the current hole mask based on the current hardware loading data block size and the pooled window joint description data using a preset joint mask calculation method.
[0033] The current hardware-loaded data block size can be the size of the data block that the MaxPool2d hardware supports for processing in a single load. For example, the current hardware-loaded data block size can be set to 4*4.
[0034] The pooling window joint description data can include the pooling window size and the pooling window data. The pooling window size can be the size of the effective data; for example, the pooling window size can be set to kernel_size = 3, which is a 3*3 matrix.
[0035] Optionally, the step of acquiring and calculating the current data loading mask and the current hole mask based on the current hardware loading data block size and the pooling window joint description data using a preset joint mask calculation method includes: acquiring the dilation parameters corresponding to the MaxPool2d hardware; calculating the current data loading mask based on the current hardware loading data block size, the pooling window size, and the dilation parameters using a preset data loading mask generation method; and calculating the current hole mask based on the pooling window data using a preset hole mask generation method based on the dilation parameters.
[0036] In this embodiment, the current hardware load data block size is set to input_data; the pooling window size can be set to kernel_size to calculate the current data load mask kernel_mask.
[0037] Specifically, this is accomplished through software preprocessing. The target pooling window size during data loading is influenced by both the MaxPool2d hardware parameters kernel_size and dilation. In detail, this can be adjusted using the formula kernel_size′=(kernel_size-1)*dilation+1.
[0038] Additionally, the current data loading mask, `kernel_mask`, is composed of 0s and 1s. 0 indicates that the corresponding position in the data element block will be removed (i.e., it needs to be masked as -inf), and 1 indicates that the corresponding position in the data element block will be retained. By performing certain operations on the data element block and `kernel_mask`, data other than the target data element (the element at the position corresponding to 1 in `kernel_mask`) can be transformed into -inf (-inf represents negative infinity). The specific operation depends on the hardware capabilities supported by the architecture and is generally a bitwise AND operation or a multiply-accumulate operation.
[0039] Continuing from the previous example, since the current hardware loads a data block size of input_data of 4*4, and the pooling window size kernel_size can be set to a 3*3 matrix, the kernel_size can be padded with zeros according to the size of input_data to obtain kernel_mask, where kernel_mask is a 4*4 matrix.
[0040] Furthermore, the current hole mask (dilation_mask) corresponding to the target pooling window is determined based on the dilation parameter in the MaxPool2d hardware. Specifically, this process is completed through software preprocessing.
[0041] In detail, when the MaxPool2d hardware input parameters kernel_size = 2 and dilation = 2, according to the above formula kernel_size′ = (kernel_size - 1) * dilation + 1, the target pooling window size should be 3, and then dilation_mask is a 3*3 square matrix.
[0042] Specifically, `dilation_mask` consists of 0s and 1s. 0 indicates that the element at the corresponding position in the pooling window will be removed (i.e., it needs to be masked as -inf), and 1 indicates that the element at the corresponding position in the pooling window will be retained. Depending on the hardware architecture, the appropriate bitwise AND, OR, multiplication, and accumulation operation can be used to convert holes in the target pooling window to -inf.
[0043] S130. The current data loading mask and the current hole mask are processed by a pre-set AND operation processing method to obtain the target standard data loading joint mask.
[0044] Optionally, the step of processing the current data loading mask and the current hole mask using a pre-set AND operation processing method to obtain the target standard data loading joint mask includes: performing bitwise AND operations on the current data loading mask and the current hole mask respectively using the AND operation processing method to obtain the target data loading joint mask; and performing a bitwise transformation operation on each bit of the target data loading joint mask using a pre-set bitwise transformation method to obtain the target standard data loading joint mask.
[0045] Specifically, the bit-by-bit transformation method includes: transforming each data element of size 1 in the target data loaded into the joint mask into 0; transforming each data element of size 0 in the target data loaded into the joint mask into -inf.
[0046] In this embodiment, the calculated kernel_mask and dilation_mask are merged using a bitwise AND operation to obtain the target data loading joint mask, which can be abbreviated as final_mask. This calculation process is completed through software preprocessing.
[0047] Additionally, if the pooling window size is smaller than the size of the current hardware-loaded data block, the mask positions of the dilation_mask can be padded with 0s to make it the same size as the kernel_mask. Then, a bitwise AND operation is performed on each element of the two mask matrices to obtain the final_mask. The final_mask is also composed of 0s and 1s; 0 indicates that the value at the corresponding position in the data element block will be masked as -inf, and 1 indicates that the value at the corresponding position in the data element block will be preserved.
[0048] Furthermore, based on the hardware architecture, an appropriate operation is selected to perform calculations on the final_mask and the element block obtained by the hardware. Elements at positions corresponding to 0 in the mask are transformed into -inf, meaning that each data element of size 0 in the target data-loaded joint mask is transformed into -inf. This allows for a single step to remove elements other than valid data from the computation block and eliminate holes in the pooling window. It is also necessary to transform each data element of size 1 in the target data-loaded joint mask into 0. Then, the maximum value operation can begin on the pooling window.
[0049] S140. The target standard data loading joint mask is received in real time through the MaxPool2d hardware, and the current data block to be processed is processed according to the pre-set mask operation processing method to obtain the current standard valid data block, and the current standard valid data block is fed back to the user.
[0050] In this embodiment, the calculated target standard data loading joint mask needs to be sent to the MaxPool2d hardware, as does the target data loading joint mask. The MaxPool2d hardware can then use the received mask to process the current data block through mask operation methods, removing invalid and gapped data to obtain the required current standard valid data block.
[0051] Optionally, the step of processing the current data block to be processed according to a pre-set mask operation processing method to obtain a current standard valid data block includes: splitting the current data block to be processed to obtain at least one current hardware loading data sub-block; determining, according to the mask operation processing method, whether the MaxPool2d hardware supports mask operations when loading each of the current hardware loading data sub-blocks to be processed; if supported, then, according to the target data loading joint mask, performing invalid data and hole data removal operations on each of the sequentially obtained current hardware loading data sub-blocks to be processed during the loading process to obtain each current standard valid data sub-block; and sequentially combining each of the current standard valid data sub-blocks to obtain a current standard valid data block.
[0052] In this embodiment, the current data block to be processed is first divided according to the current hardware loading data block size to obtain multiple current hardware loading data sub-blocks to be processed.
[0053] Furthermore, if the MaxPool2d hardware supports masking operations when loading the currently processed hardware data sub-blocks, then `final_mask` can be directly set in the configuration parameters for loading the currently processed hardware data sub-blocks, and invalid data can be replaced with `-inf`. This allows for the extraction of pooled window elements and the removal of holes to be completed during data loading. In this process, invalid data removal requires no hardware computation, reducing hardware resource consumption and computational load, and improving the efficiency and accuracy of hardware data processing.
[0054] Optionally, after determining whether the MaxPool2d hardware supports masking operations when loading each of the currently pending hardware loading data sub-blocks according to the masking operation processing method, the method further includes: if not, sequentially acquiring one of the currently pending hardware loading data sub-blocks, and using a pre-set multiplication-addition formula combined with the target standard data loading joint mask to perform invalid and gapped data removal operations on the currently pending hardware loading data sub-blocks to obtain current standard valid data sub-blocks; determining whether all currently pending hardware loading data sub-blocks have been traversed; if yes, combining each of the current standard valid data sub-blocks to obtain the current standard valid data block; if no, returning to the step of sequentially acquiring one of the currently pending hardware loading data sub-blocks, and using a pre-set multiplication-addition formula combined with the target standard data loading joint mask to perform invalid data removal operations on the currently pending hardware loading data sub-blocks.
[0055] Optionally, by using a pre-set multiply-add formula and combining it with the target standard data loading joint mask, invalid and gapped data removal operations are performed on the current hardware loading data sub-block to be processed to obtain the current standard valid data sub-block. This includes: multiplying the current hardware loading data sub-block to be processed with the target data loading joint mask using the multiply-add formula to obtain the current intermediate multiplication result; and adding the target standard data loading joint mask with the current intermediate multiplication result to obtain the current standard valid data sub-block.
[0056] In this embodiment, if the MaxPool2d hardware does not support masking operations when loading the current hardware loading data sub-blocks, the final_mask is first modified in the software, that is, the internal elements 0 and 1 in the final_mask are adjusted to -inf and 0 respectively, thus obtaining the target standard data loading joint mask. The target standard data loading joint mask can be denoted as final_val. This calculation is completed by software preprocessing.
[0057] Furthermore, the current standard valid data sub-block res_val can be calculated using the multiplication-addition formula res_val = input_data * final_mask + final_val. This allows for the extraction of pooled window elements and hole removal from the currently processed hardware-loaded data sub-block to obtain the current standard valid data sub-block.
[0058] Accordingly, following the methods described above, pooling window element extraction and hole removal operations need to be performed on each currently pending hardware-loaded data sub-block. Then, the resulting currently standard valid data sub-blocks are combined to obtain the currently standard valid data block. Finally, the obtained currently standard valid data block can be provided to the user as feedback.
[0059] The technical solution of this invention involves acquiring the current data block to be processed; acquiring and calculating the current data loading mask and the current hole mask based on the current hardware-loaded data block size and pooled window joint description data using a preset joint mask calculation method; processing the current data loading mask and the current hole mask using a preset AND operation processing method to obtain a target standard data loading joint mask; receiving the target standard data loading joint mask in real time through the MaxPool2d hardware, and processing the current data block to be processed according to the preset mask operation processing method to obtain the current standard valid data block, and then providing feedback on the current standard valid data block to the user. This solves the problems of wasted hardware data processing resources and low data processing efficiency in MaxPool2d, improves the efficiency and accuracy of hardware data processing, reduces resource waste, and simplifies the hardware data processing steps.
[0060] Example 2
[0061] Figure 2 This is a schematic diagram of a MaxPool2d hardware data processing device based on a merge mask, provided in Embodiment 2 of the present invention. The MaxPool2d hardware data processing device based on a merge mask provided in this embodiment can be implemented through software and / or hardware, and can be configured in a terminal device or server to implement a MaxPool2d hardware data processing method based on a merge mask according to an embodiment of the present invention. Figure 2 As shown, the device includes: a current data block acquisition module 210, a current data loading mask and current hole mask calculation module 220, a target standard data loading joint mask determination module 230, and a current standard valid data block determination and feedback module 240.
[0062] Among them, the current data block acquisition module 210 is used to acquire the current data block to be processed;
[0063] The current data loading mask and current hole mask calculation module 220 is used to obtain and calculate the current data loading mask and current hole mask according to the current hardware loading data block size and pooled window joint description data through a preset joint mask calculation method.
[0064] The target standard data loading joint mask determination module 230 is used to process the current data loading mask and the current hole mask through a pre-set AND operation processing method to obtain the target standard data loading joint mask;
[0065] The current standard valid data block determination and feedback module 240 is used to receive the target standard data loading joint mask in real time through the MaxPool2d hardware, process the current data block to be processed according to a pre-set mask operation processing method, obtain the current standard valid data block, and provide feedback on the current standard valid data block to the user.
[0066] The technical solution of this invention involves acquiring the current data block to be processed; acquiring and calculating the current data loading mask and the current hole mask based on the current hardware-loaded data block size and pooled window joint description data using a preset joint mask calculation method; processing the current data loading mask and the current hole mask using a preset AND operation processing method to obtain a target standard data loading joint mask; receiving the target standard data loading joint mask in real time through the MaxPool2d hardware, and processing the current data block to be processed according to the preset mask operation processing method to obtain the current standard valid data block, and then providing feedback on the current standard valid data block to the user. This solves the problems of wasted hardware data processing resources and low data processing efficiency in MaxPool2d, improves the efficiency and accuracy of hardware data processing, reduces resource waste, and simplifies the hardware data processing steps.
[0067] Based on the above embodiments, the pooled window joint description data includes the pooled window size and the pooled window data.
[0068] Based on the above embodiments, the current data loading mask and current hole mask calculation module 220 can be specifically used to: obtain the dilation parameters corresponding to the MaxPool2d hardware; calculate the current data loading mask by using a pre-set data loading mask generation method based on the current hardware loading data block size, pooling window size, and dilation parameters; and calculate the current hole mask by using a pre-set hole mask generation method based on the dilation parameters for the pooling window data.
[0069] Based on the above embodiments, the target standard data loading joint mask determination module 230 can be specifically used to: perform bitwise AND operations on the current data loading mask and the current hole mask respectively through the AND operation processing method to obtain the target data loading joint mask; and perform deformation processing operation on each bit of the target data loading joint mask through a pre-set bitwise deformation method to obtain the target standard data loading joint mask.
[0070] Based on the above embodiments, the bit-by-bit deformation method includes: deforming each data element of the target data in the joint mask with a size of 1 to 0; and deforming each data element of the target data in the joint mask with a size of 0 to -inf.
[0071] Based on the above embodiments, the current standard valid data block determination and feedback module 240 may specifically include: a current hardware loading sub-block determination unit, which may be specifically used to: perform segmentation processing on the current data block to be processed to obtain at least one current hardware loading sub-block; a mask operation judgment unit, which may be specifically used to: determine whether the MaxPool2d hardware supports mask operation when loading each of the current hardware loading sub-blocks to be processed according to the mask operation processing method; a mask operation support processing unit, which may be specifically used to: if supported, perform invalid data and hole data removal operations on each of the sequentially obtained current hardware loading sub-blocks to be processed during the loading process according to the target data loading joint mask to obtain each current standard valid data sub-block; and a current standard valid data sub-block determination unit, which may be specifically used to: sequentially combine each of the current standard valid data sub-blocks to obtain a current standard valid data block.
[0072] Based on the above embodiments, the system further includes a mask operation processing unit, which can be specifically used for: after determining whether the MaxPool2d hardware supports mask operations when loading each of the currently processed hardware loading data sub-blocks according to the mask operation processing method, if it does not support mask operations, then sequentially acquiring one of the currently processed hardware loading data sub-blocks, and using a pre-set multiply-add formula combined with the target standard data loading joint mask to perform invalid data and hole data removal operations on the currently processed hardware loading data sub-blocks to obtain current standard valid data sub-blocks; determining whether all currently processed hardware loading data sub-blocks have been traversed, and if so, combining each of the current standard valid data sub-blocks to obtain the current standard valid data block; if not, returning to the step of sequentially acquiring one of the currently processed hardware loading data sub-blocks, and using a pre-set multiply-add formula combined with the target standard data loading joint mask to perform invalid data removal operations on the currently processed hardware loading data sub-blocks.
[0073] Based on the above embodiments, the mask operation-unsupporting processing unit can also be specifically used to: multiply the current hardware loading data sub-block to be processed with the target data loading joint mask using the multiplication-addition formula to obtain the current intermediate multiplication result; and add the target standard data loading joint mask with the current intermediate multiplication result to obtain the current standard valid data sub-block.
[0074] The MaxPool2d hardware data processing device based on merge mask provided in the embodiments of the present invention can execute the MaxPool2d hardware data processing method based on merge mask provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the method execution.
[0075] Example 3
[0076] Figure 3 A schematic diagram of an electronic device 10, which can be used to implement Embodiment 3 of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0077] like Figure 3As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0078] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0079] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the MaxPool2d hardware data processing method based on merge masking.
[0080] In some embodiments, the MaxPool2d hardware data processing method based on merge masking can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or mounted on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the MaxPool2d hardware data processing method based on merge masking described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the MaxPool2d hardware data processing method based on merge masking by any other suitable means (e.g., by means of firmware).
[0081] The method includes: acquiring the current data block to be processed; acquiring and calculating the current data loading mask and the current hole mask based on the current hardware-loaded data block size and pooled window joint description data using a preset joint mask calculation method; processing the current data loading mask and the current hole mask using a preset AND operation processing method to obtain a target standard data loading joint mask; receiving the target standard data loading joint mask in real time through the MaxPool2d hardware, and processing the current data block to be processed according to a preset mask operation processing method to obtain a current standard valid data block, and providing feedback of the current standard valid data block to the user.
[0082] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0083] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0084] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0085] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0086] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0087] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0088] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0089] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
[0090] Example 4
[0091] Embodiment 4 of the present invention also provides a computer-readable storage medium, wherein the computer-readable instructions, when executed by a computer processor, are used to perform a MaxPool2d hardware data processing method based on a merged mask. The method includes: acquiring a current data block to be processed; acquiring and calculating a current data loading mask and a current hole mask based on the current hardware-loaded data block size and pooling window joint description data using a preset joint mask calculation method; processing the current data loading mask and the current hole mask using a preset AND operation processing method to obtain a target standard data loading joint mask; receiving the target standard data loading joint mask in real time through the MaxPool2d hardware, and processing the current data block to be processed according to a preset mask operation processing method to obtain a current standard valid data block, and providing feedback of the current standard valid data block to the user.
[0092] Of course, the computer-executable instructions provided in the embodiments of the present invention, which include a computer-readable storage medium, are not limited to the method operations described above, but can also perform related operations in the MaxPool2d hardware data processing based on the merge mask provided in any embodiment of the present invention.
[0093] Based on the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented using software and necessary general-purpose hardware, and of course, it can also be implemented using hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk, or optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0094] It is worth noting that in the above embodiments of MaxPool2d hardware data processing based on merged masks, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the scope of protection of the present invention.
[0095] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A MaxPool2d hardware data processing method based on a merge mask, characterized in that, include: Get the current block of data to be processed; The system acquires and calculates the current data loading mask and the current hole mask based on the current hardware loading data block size and the pooled window joint description data, using a preset joint mask calculation method. By using a pre-set AND operation processing method, the current data loading mask and the current hole mask are processed to obtain the target standard data loading joint mask; The MaxPool2d hardware receives the target standard data loading joint mask in real time, processes the current data block to be processed according to the pre-set mask operation processing method, obtains the current standard valid data block, and feeds back the current standard valid data block to the user.
2. The method according to claim 1, characterized in that, The pooling window joint description data includes the pooling window size and the pooling window data; The process of acquiring and calculating the current data loading mask and the current hole mask based on the current hardware loaded data block size and the pooled window joint description data, using a preset joint mask calculation method, includes: Obtain the dilation parameters corresponding to the MaxPool2d hardware; Based on the current hardware data block size, pooling window size, and dilation parameter, the current data loading mask is calculated using a pre-set data loading mask generation method. The current hole mask is obtained by calculating the pooled window data based on the dilation parameter using a pre-set hole mask generation method.
3. The method according to claim 2, characterized in that, The process of processing the current data loading mask and the current hole mask using a pre-set AND operation method to obtain the target standard data loading joint mask includes: By performing bitwise AND operations on the current data loading mask and the current hole mask respectively using the AND operation processing method, a joint target data loading mask is obtained. By using a pre-set bit-by-bit deformation method, each bit of the target data loading joint mask is deformed to obtain the target standard data loading joint mask.
4. The method according to claim 3, characterized in that, The position-by-position deformation method includes: The target data is loaded into the joint mask, and each data element of size 1 is transformed to 0; The target data is loaded into a composite mask where each data element of size 0 is transformed into -inf.
5. The method according to claims 1-4, characterized in that, The step of processing the current data block to be processed according to a pre-set mask operation processing method to obtain the current standard valid data block includes: The current data block to be processed is segmented to obtain at least one current hardware loading data sub-block to be processed; Based on the mask operation processing method, determine whether the MaxPool2d hardware supports mask operations when loading each of the current hardware loading data sub-blocks; If supported, then according to the target data, load the joint mask, and perform invalid data and hole data removal operations on each of the current hardware data sub-blocks to be processed obtained in sequence during the loading process to obtain each current standard valid data sub-block; The current standard valid data sub-blocks are combined sequentially to obtain the current standard valid data block.
6. The method according to claim 5, characterized in that, After determining whether the MaxPool2d hardware supports masking operations when loading each of the currently processed hardware loading data sub-blocks according to the masking operation processing method, the method further includes: If not supported, then sequentially obtain one of the current hardware loading data sub-blocks to be processed, and perform invalid data and hole data removal operations on the current hardware loading data sub-blocks to be processed by using a pre-set multiplication and addition formula and the target standard data loading joint mask to obtain the current standard valid data sub-blocks; Determine whether all currently pending hardware loading data sub-blocks have been traversed. If yes, combine the currently standard valid data sub-blocks to obtain the currently standard valid data block. If no, return to the step of sequentially obtaining one of the currently pending hardware loading data sub-blocks and performing invalid data removal operation on the currently pending hardware loading data sub-block using a pre-set multiplication-addition formula and the target standard data loading joint mask.
7. The method according to claim 6, characterized in that, By using a pre-set multiplication-addition formula and the target standard data loading joint mask, invalid and gapped data removal operations are performed on the current hardware loading data sub-block to be processed, resulting in the current standard valid data sub-block, including: The multiplication formula is used to multiply the current hardware loading data sub-block to be processed with the target data loading joint mask to obtain the current intermediate multiplication result. The target standard data is loaded with a joint mask and then multiplied with the current intermediate data to obtain the current standard valid data sub-block.
8. A MaxPool2d hardware data processing device based on a merge mask, characterized in that, include: The current pending data block acquisition module is used to acquire the current pending data block; The current data loading mask and current hole mask calculation module is used to obtain and calculate the current data loading mask and current hole mask based on the current hardware loading data block size and pooled window joint description data, using a preset joint mask calculation method. The target standard data loading joint mask determination module is used to process the current data loading mask and the current hole mask through a pre-set AND operation processing method to obtain the target standard data loading joint mask; The current standard valid data block determination and feedback module is used to receive the target standard data loading joint mask in real time through the MaxPool2d hardware, process the current data block to be processed according to the pre-set mask operation processing method, obtain the current standard valid data block, and feed back the current standard valid data block to the user.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements a MaxPool2d hardware data processing method based on a merge mask as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute a MaxPool2d hardware data processing method based on a merge mask as described in any one of claims 1-7.