Method, device, equipment and storage medium for determining network model quantization strategy

By generating a quantization strategy search space and randomly generating codes, decoding and determining the quantization strategy, the problem of limited network model performance caused by hardware differences is solved, and the accuracy and adaptation effect of the network model on the target hardware are improved.

CN112149266BActive Publication Date: 2024-09-24SHANGHAI QUANTINFO TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011149553.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-23
Publication Date
2024-09-24
Estimated Expiration
2040-10-23

AI Technical Summary

Technical Problem

Quantification strategies for network models on different hardware vary greatly, and users cannot choose the quantization strategy on their own, resulting in limited performance and effects of the network model on the target hardware.

Method used

By generating a quantization strategy search space for the target hardware, randomly generating quantization strategy codes, decoding to obtain the candidate quantization strategy, and determining the target quantization strategy based on its quantization accuracy loss, it improves the accuracy and adaptation effect of the network model on the target hardware.

Benefits of technology

It implements a quantitative strategy for automatically searching target hardware, improves the accuracy and adaptation effect of the network model, and improves the performance of the hardware.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112149266B
    Figure CN112149266B
Patent Text Reader

Abstract

The embodiments of the present application disclose methods, devices, equipment and storage media for determining the quantization strategy of a network model, which relate to the fields of artificial intelligence technology such as computer vision and deep learning, and can be specifically used in image processing scenarios. The method includes: using the configuration information of the quantization strategy search space of the network model for the target hardware to generate a quantization strategy search space; using the quantization strategy search space to generate a quantization strategy encoding generator; using the quantization strategy encoding generator to randomly generate quantization strategy encoding; decoding the quantization strategy encoding to obtain a quantization strategy to be selected; determining the target quantization strategy for the network model for the target hardware based on the quantization accuracy loss of the network model corresponding to the quantization strategy to be selected, thereby improving the accuracy of the network model on the target hardware and improving the adaptation effect of the network model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, specifically to the field of artificial intelligence technology such as computer vision and deep learning, and can be specifically used in image processing scenarios, and in particular to methods, devices, equipment and storage media for determining network model quantization strategies. Background Art

[0002] Deep learning technology has achieved great success in many fields. In deep learning technology, the quantization of network models has a very important impact on the performance and effect of network models.

[0003] However, the quantization strategies of network models on different hardware vary greatly. Taking HiSilicon chips as an example, the network model chooses to use the default configuration of HiSilicon chips. The quantization strategy on the chip is a black box for users, and users cannot choose the quantization strategy themselves. Summary of the invention

[0004] Embodiments of the present application provide a method, apparatus, device, and storage medium for determining a network model quantization strategy.

[0005] In a first aspect, an embodiment of the present application provides a method for determining a quantization strategy of a network model, comprising: using configuration information of a quantization strategy search space for a network model of target hardware to generate a quantization strategy search space; using the quantization strategy search space to generate a quantization strategy code generator; using the quantization strategy code generator to randomly generate quantization strategy codes; decoding the quantization strategy codes to obtain a candidate quantization strategy; and determining a target quantization strategy for the network model of the target hardware based on the quantization accuracy loss of the network model corresponding to the candidate quantization strategy.

[0006] In a second aspect, an embodiment of the present application provides an apparatus for determining a quantization strategy of a network model, comprising: a quantization strategy search space generation module, configured to adopt the configuration information of the quantization strategy search space of the network model for the target hardware to generate a quantization strategy search space; an encoding module, configured to adopt the quantization strategy search space to generate a quantization strategy encoding generator; a quantization strategy encoding generation module, configured to adopt the quantization strategy encoding generator to randomly generate a quantization strategy encoding; a decoding module, configured to decode the quantization strategy encoding to obtain a candidate quantization strategy; a target quantization strategy determination module, configured to determine the target quantization strategy for the network model of the target hardware based on the quantization accuracy loss of the network model corresponding to the candidate quantization strategy.

[0007] In a third aspect, an embodiment of the present application proposes an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a method described in any implementation manner in the first aspect.

[0008] In a fourth aspect, an embodiment of the present application proposes a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to enable a computer to execute a method as described in any implementation manner in the first aspect.

[0009] The method, apparatus, device and storage medium for determining the quantization strategy of a network model provided in the embodiments of the present application first use the configuration information of the quantization strategy search space of the network model for the target hardware to generate a quantization strategy search space; secondly use the quantization strategy search space to generate a quantization strategy code generator; then use the quantization strategy code generator to randomly generate quantization strategy codes; then decode the quantization strategy codes to obtain a candidate quantization strategy; finally, determine the target quantization strategy for the network model for the target hardware based on the quantization accuracy loss of the network model corresponding to the candidate quantization strategy, thereby improving the accuracy of the network model on the target hardware and improving the adaptation effect of the network model.

[0010] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Other features, purposes and advantages of the present application will become more apparent by reading the detailed description of the non-limiting embodiments made with reference to the following drawings. The drawings are used to better understand the present solution and do not constitute a limitation of the present application. Among them:

[0012] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0013] Figure 2 is a flowchart of an embodiment of a method for determining a network model quantization strategy according to the present application;

[0014] Figure 3 It is a schematic diagram of an application scenario of an embodiment of a method for determining a network model quantization strategy according to the present application;

[0015] Figure 4 It is a structural schematic diagram of an embodiment of the device for determining the network model quantization strategy of the present application;

[0016] Figure 5 It is a block diagram of an electronic device used to implement the method for determining a network model quantization strategy in an embodiment of the present application. DETAILED DESCRIPTION

[0017] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It should also be noted that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.

[0018] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0019] Figure 1 An exemplary system architecture 100 is shown to which an embodiment of a method for determining a network model quantization strategy or an apparatus for determining a network model quantization strategy of the present application can be applied.

[0020] like Figure 1 As shown, the system architecture 100 may include a terminal device 101, a network 102, and a server 103. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links, or optical fiber cables.

[0021] The terminal device 101 may interact with the server 103 via the network 102. The terminal device 101 may provide configuration information of the quantization strategy search space for the target hardware, including but not limited to a database, a user terminal, and the like.

[0022] The server 103 can provide various services. For example, the server 103 can analyze and process data such as configuration information of the quantization strategy search space for the target hardware obtained from the terminal device 101 to generate processing results (such as target quantization strategies for the target hardware).

[0023] It should be noted that the server 103 can be hardware or software. When the server 103 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server 103 is software, it can be implemented as multiple software or software modules (for example, for providing distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.

[0024] It should be noted that the method for determining the network model quantization strategy provided in the embodiment of the present application is generally executed by the server 103, and accordingly, the device for determining the network model quantization strategy is generally set in the server 103.

[0025] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0026] Continue to refer Figure 2 , shows a process 200 of an embodiment of a method for determining a network model quantization strategy according to the present application. The method comprises the following steps:

[0027] Step 201 : Generate a quantization strategy search space using configuration information of a quantization strategy search space for a network model of target hardware.

[0028] In this embodiment, the execution subject of the method for determining the network model quantization strategy (for example Figure 1 The server 103 shown may generate a quantization strategy search space using configuration information of a quantization strategy search space for a network model of target hardware.

[0029] Among them, the configuration information of the quantization strategy search space for the target hardware can be information set by the user for determining the quantization strategy search space. For example, it is known that the configuration information of the quantization strategy search space on chip A is to convert the parameters in the neural network model to 8 bits, then the set of all strategies or fitting strategies for 8-bit quantization can be obtained to obtain the search space for 8-bit quantization strategies. It is worth mentioning that not all configuration information of the quantization strategy search space of the target hardware is known. If the quantization strategy of the target hardware is a completely unknown black box to the user, the default quantization strategy search space can be generated based on the default configuration information (for example, converting the parameters in the neural network model to 8 bits).

[0030] Among them, the quantization strategy includes a quantization method and a quantization position. The quantization method refers to a method for quantizing the parameters in the neural network model. Taking 8-bit quantization as an example, the methods for converting the parameters of the neural network model into 8-bit types include extreme value, exponentiation, statistical distribution, etc. The quantization position refers to the position of the quantized parameters in the neural network model. Exemplarily, if the parameter values ​​belonging to the same layer in a certain neural network model are distributed in a smaller interval (for example, between -10 and 30), then the minimum and maximum values ​​can be recorded. In the case of 8-bit quantization, all parameters of the same layer can be linearly mapped to the closest number of 255 8-bit integers between the interval [-10, 30]. Among them, the position of the specific layer in the neural network model to which these parameters belong is the quantization position, and the quantization method is extreme value.

[0031] The quantization methods in the quantization strategy search space may be all known quantization methods in the prior art and new quantization methods that may appear in the future with the development of technology. The quantization positions in the quantization strategy search space may be all known quantization positions in the prior art and new quantization positions that may appear in the future with the development of technology.

[0032] Among them, a quantization strategy consisting of any quantization method and any quantization position can be searched from the quantization strategy search space. These quantization strategies can be either quantization strategies known in the prior art or fitting of existing quantization strategies.

[0033] Step 202: Use the quantization strategy search space to generate a quantization strategy code generator.

[0034] In this embodiment, the execution entity may encode the quantization strategy search space into a quantization strategy encoding generator.

[0035] Among them, encoding the quantization strategy search space can be encoding the quantization method and quantization position in the search space. For example, suppose there are 10 quantization methods in the search space, and there are 10 different quantization positions. Then each quantization method can be encoded to obtain 10 encoding values ​​corresponding to the 10 quantization methods. At the same time, the 10 different quantization positions are encoded to obtain 10 encoding values ​​corresponding to the 10 different quantization positions. Since each quantization position can have 10 different quantization methods to choose from, the search space can have 100,000 different quantization strategies. Each quantization strategy has a unique corresponding encoding value, so that a quantization strategy encoding generator can be obtained.

[0036] By encoding the quantitative strategies in the search space, the quantitative strategies can be converted into a language that can be recognized by computers, thereby realizing machine-automatic search for quantitative strategies.

[0037] Step 203: Use a quantization strategy code generator to randomly generate a quantization strategy code.

[0038] In this embodiment, the execution entity may use a quantization strategy code generator to randomly generate a quantization strategy code.

[0039] The quantization strategy code generator can randomly generate a set of codes representing a quantization strategy. The set of quantization strategy codes can be composed of any quantization method code and any quantization position code.

[0040] Step 204: decode the quantization strategy code to obtain a candidate quantization strategy.

[0041] In this embodiment, the execution subject can decode the quantization strategy code to obtain a candidate quantization strategy. Since each set of quantization strategy codes can correspond to a unique quantization strategy, after decoding the set of quantization strategy codes, a candidate quantization strategy can be obtained. The existing encoding / decoding technology can be used to implement the encoding and decoding of the quantization strategy.

[0042] Step 205 , determining a target quantization strategy for the network model of the target hardware according to the quantization accuracy loss of the network model corresponding to the candidate quantization strategy.

[0043] In this embodiment, the execution subject may determine the target quantization strategy for the network model of the target hardware according to the quantization accuracy loss of the network model corresponding to the candidate quantization strategy.

[0044] Among them, you can first obtain the training script (such as network structure, initial parameters, activation function, loss function, etc.) of the network model using the default quantization strategy of the target hardware. Then execute the training script on the training set to train the network model. Subsequently, use the candidate quantization strategy to quantize the trained network model, and test the effect of the quantized network model on the validation set (such as accuracy loss). If the test effect meets the requirements, the candidate quantization strategy can be used as the quantization strategy or approximate quantization strategy of the target hardware.

[0045] The method for determining the quantization strategy of a network model provided in the above-mentioned embodiment of the present application can obtain the quantization strategy or approximate quantization strategy on the target hardware by automatic search, thereby improving the accuracy of the network model on the target hardware and improving the adaptation effect of the network model.

[0046] In some optional implementations of this embodiment, the above step 205 also includes: in response to the quantization accuracy loss of the network model of the candidate quantization strategy being less than a predetermined threshold, determining the candidate quantization strategy as the target quantization strategy for the target hardware.

[0047] Specifically, the method includes the following steps: quantizing the network model for the target hardware based on the candidate quantization strategy; evaluating the quantization accuracy loss of the quantized network model; and determining the candidate quantization strategy as the target quantization strategy for the target hardware in response to the quantization accuracy loss of the network model being less than a predetermined threshold. In this embodiment, by setting the termination condition of the automatic search of the quantization strategy (the quantization accuracy loss of the network model is less than a predetermined threshold), the quantization strategy that meets the requirements can be screened out.

[0048] In some optional implementations of this embodiment, the above-mentioned step 205 also includes: in response to the quantization accuracy loss of the network model of the candidate quantization strategy being greater than a predetermined threshold, using the quantization strategy code generator to generate a new set of quantization strategy codes, and decoding the new set of quantization strategy codes to obtain a new candidate quantization strategy; determining the target quantization strategy for the target hardware based on the quantization accuracy loss corresponding to the new candidate quantization strategy.

[0049] Specifically, the method includes the following steps: quantizing a network model for target hardware based on a candidate quantization strategy; evaluating the quantization accuracy loss of the quantized network model; in response to the quantization accuracy loss of the network model being greater than a predetermined threshold, generating a new set of quantization strategy codes according to a quantization strategy code generator, and decoding the new set of quantization strategy codes to obtain a new candidate quantization strategy; determining the target quantization strategy for the target hardware according to the quantization accuracy loss corresponding to the new candidate quantization strategy. In this embodiment, by setting the loop condition for automatic search of quantization strategies (the quantization accuracy loss of the network model is greater than a predetermined threshold), the optimal target quantization strategy can be found from the quantization strategy search space. Preferably, a termination condition can also be set for the loop condition for automatic search of quantization strategies, such as when the number of updates of the quantization strategy code generator reaches a predetermined threshold. Wherein, each update of the quantization strategy code generator can generate a new set of quantization strategy codes.

[0050] In some optional implementations of this embodiment, the selected quantization strategy includes an offline quantization strategy and an online quantization strategy. The method for determining the network model quantization strategy provided in this embodiment can be applied to both offline quantization and online quantization. Offline quantization is applicable to the case where the quantization strategy of the target hardware is a black box to the user, and online quantization is generally applicable to the case where the quantization strategy of the target hardware is a white box to the user.

[0051] In some optional implementations of this embodiment, when the user's terminal device has the corresponding device processing capability, the above-mentioned execution subject can return the target quantization strategy to the user's terminal device. At this time, the user's terminal device can first obtain a training sample set, and use the training sample set for training to obtain an initial model, and then use the target quantization strategy to quantize the initial model to obtain a target model.

[0052] In the case where the user's terminal device does not have the corresponding device processing capability, the execution subject may obtain a training sample set, and use the training sample set for training to obtain an initial model, and then use the target quantization strategy to quantize the initial model to obtain a target model. Subsequently, the execution subject may return the target quantization strategy and the target model to the user's terminal device.

[0053] It is worth mentioning that the initial model in this embodiment can be any kind of artificial neural network model, including but not limited to classification models, recognition models, detection models, and the like. The target model using the target quantization strategy in the embodiment of the present application has improved running speed and accuracy on the target hardware, thereby improving the product competitiveness of the target model and the target hardware. At the same time, with the same accuracy, the use of the target model can reduce the cost of the product. Among them, the initial model can be an image processing model applied to the target hardware. The image processing model is quantized using the target quantization strategy in the embodiment of the present application, which can significantly improve the accuracy of the image processing model, which is equivalent to using a smaller model to achieve the same accuracy, that is, significantly improving the speed of the image processing model. The hardware benefit is that the image processing model processes images faster on the hardware, reduces the cost of the product, and improves the core competitiveness of the product.

[0054] In some optional implementations of this embodiment, the quantization strategy to be selected includes at least one of the following: 16-bit quantization, 8-bit quantization, 4-bit quantization, and 2-bit quantization.

[0055] For ease of understanding, the following provides an application scenario in which the method for determining the network model quantization strategy of the embodiment of the present application can be implemented, specifically as follows: Figure 3 As shown:

[0056] Step 301: Generate a quantization strategy search space based on the configuration information of the quantization strategy search space of the HiSilicon chip.

[0057] Step 302: Encode the quantization strategy search space to generate a quantization strategy encoding generator.

[0058] Step 303: Generate quantization strategy code through a quantization strategy code generator.

[0059] Step 304: Decode the quantization strategy in step 303 into a quantization strategy.

[0060] Step 305: Use the quantization strategy in step 304 to quantize the trained neural network model.

[0061] Step 306: If the quantization accuracy loss of the neural network model is greater than the predetermined threshold, execute step 303; if the quantization accuracy loss of the neural network model is less than the predetermined threshold, do not perform any operation.

[0062] Further references Figure 4 As an implementation of the methods shown in the above figures, the present application provides an embodiment of determining a network model quantization strategy. The device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0063] like Figure 4 As shown, the apparatus 400 for determining the quantization strategy of a network model in this embodiment may include: a quantization strategy search space generation module 401, an encoding module 402, a quantization strategy code generation module 403, a decoding module 404, and a target quantization strategy determination module 405. Among them, the quantization strategy search space generation module 401 is configured to use the configuration information of the quantization strategy search space for the network model of the target hardware to generate a quantization strategy search space; the encoding module 402 is configured to use the quantization strategy search space to generate a quantization strategy code generator; the quantization strategy code generation module 403 is configured to use the quantization strategy code generator to randomly generate a quantization strategy code; the decoding module 404 is configured to decode the quantization strategy code to obtain a candidate quantization strategy; the target quantization strategy determination module 405 is configured to determine the target quantization strategy for the network model of the target hardware according to the quantization accuracy loss of the network model corresponding to the candidate quantization strategy.

[0064] In this embodiment, in the device 400 for determining the quantization strategy of the network model, the specific processing of the quantization strategy search space generation module 401, the encoding module 402, the quantization strategy encoding generation module 403, the decoding module 404, and the target quantization strategy determination module 405 and the technical effects thereof can be referred to respectively. Figure 2 The relevant descriptions of steps 201 - 205 in the corresponding embodiment are not repeated here.

[0065] In some optional implementations of this embodiment, the target quantization strategy determination module is further configured to: in response to the quantization accuracy loss of the network model of the candidate quantization strategy being less than a predetermined threshold, determine the candidate quantization strategy as the target quantization strategy for the target hardware.

[0066] In some optional implementations of this embodiment, the target quantization strategy determination module is further configured to: in response to the quantization accuracy loss of the network model of the candidate quantization strategy being greater than a predetermined threshold, use the quantization strategy code generator to generate a new set of quantization strategy codes, and decode the new set of quantization strategy codes to obtain a new candidate quantization strategy; determine the target quantization strategy for the target hardware based on the quantization accuracy loss corresponding to the new candidate quantization strategy.

[0067] In some optional implementations of this embodiment, the to-be-selected quantization strategies include an offline quantization strategy and an online quantization strategy.

[0068] In some optional implementations of this embodiment, it also includes: a training sample acquisition module, configured to acquire a training sample set; an initial model training module, configured to use the training sample set to train a network model for target hardware to obtain an initial model; an initial model quantization module, configured to use the target quantization strategy to quantize the initial model to obtain a target model.

[0069] In some optional implementations of this embodiment, the to-be-selected quantization strategy includes at least one of the following: 16-bit quantization, 8-bit quantization, 4-bit quantization, and 2-bit quantization.

[0070] like Figure 5 As shown, it is a block diagram of an electronic device for determining a method for quantizing a network model strategy according to an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, 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 processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.

[0071] like Figure 5 As shown, the electronic device includes: one or more processors 501, a memory 502, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 5 A processor 501 is taken as an example.

[0072] The memory 502 is a non-transitory computer-readable storage medium provided in the present application. The memory stores instructions executable by at least one processor to enable the at least one processor to perform the method for determining the network model quantization strategy provided in the present application. The non-transitory computer-readable storage medium of the present application stores computer instructions, which are used to enable a computer to perform the method for determining the network model quantization strategy provided in the present application.

[0073] The memory 502 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as the program instructions / modules corresponding to the method for determining the network model quantization strategy in the embodiment of the present application (for example, the attached Figure 4 The processor 501 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 502, that is, the method for determining the quantization strategy of the network model in the above method embodiment is implemented.

[0074] The memory 502 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required by at least one function; the data storage area may store data created by the use of an electronic device according to the method for determining a network model quantization strategy, etc. In addition, the memory 502 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 502 may optionally include a memory remotely disposed relative to the processor 501, and these remote memories may be connected to the electronic device of the method for determining a network model quantization strategy via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0075] The electronic device of the method for determining the network model quantization strategy may also include: an input device 503 and an output device 504. The processor 501, the memory 502, the input device 503 and the output device 504 may be connected via a bus or other means. Figure 5 The example of connecting through bus is taken in the following.

[0076] The input device 503 can receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device of the method for determining the network model quantization strategy, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a trackball, a joystick and other input devices. The output device 504 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display and a plasma display. In some embodiments, the display device may be a touch screen.

[0077] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0078] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.

[0079] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer 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 can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the 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 acoustic input, voice input, or tactile input).

[0080] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0081] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.

[0082] According to the technical solution of the present application, first, the configuration information of the quantization strategy search space of the network model for the target hardware is used to generate a quantization strategy search space; secondly, the quantization strategy search space is used to generate a quantization strategy code generator; then, the quantization strategy code generator is used to randomly generate quantization strategy codes; then, the quantization strategy codes are decoded to obtain a candidate quantization strategy; finally, based on the quantization accuracy loss of the network model corresponding to the candidate quantization strategy, the target quantization strategy of the network model for the target hardware is determined, thereby improving the accuracy of the network model on the target hardware and improving the adaptation effect of the network model.

[0083] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in the present application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in the present application can be achieved, and this document is not limited here.

[0084] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art 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 application should be included in the protection scope of this application.

Claims

1. A method for determining a network model quantization strategy, comprising: Generate a quantization strategy search space by using configuration information of the quantization strategy search space of the network model for the target hardware; Using the quantization strategy search space, generating a quantization strategy code generator; Using the quantization strategy code generator to randomly generate quantization strategy codes; Decoding the quantization strategy code to obtain a quantization strategy to be selected; Determine a target quantization strategy for the network model of the target hardware according to the quantization accuracy loss of the network model corresponding to the candidate quantization strategy; The target quantization strategy is used to quantize the initial model to obtain a target model, wherein the initial model is an image processing model applied to the target hardware.

2. According to the method of claim 1, determining the target quantization strategy applied to the target hardware according to the quantization accuracy loss of the network model corresponding to the selected quantization strategy comprises: In response to the quantization accuracy loss of the network model of the candidate quantization strategy being less than a predetermined threshold, the candidate quantization strategy is determined as a target quantization strategy for the target hardware.

3. According to the method of claim 1 or 2, determining the target quantization strategy applied to the target hardware according to the quantization accuracy loss of the network model corresponding to the selected quantization strategy comprises: In response to the quantization accuracy loss of the network model of the candidate quantization strategy being greater than a predetermined threshold, using the quantization strategy code generator to generate a new set of quantization strategy codes, and decoding the new set of quantization strategy codes to obtain a new candidate quantization strategy; A target quantization strategy for target hardware is determined according to the quantization accuracy loss corresponding to the new candidate quantization strategy. 4 . The method according to claim 1 , wherein the selected quantization strategies include an offline quantization strategy and an online quantization strategy.

5. The method according to claim 1, further comprising: Obtain a training sample set; Using the training sample set to train a network model for target hardware to obtain an initial model; The target quantization strategy is used to quantize the initial model to obtain a target model.

6. According to the method according to any one of claims 1-5, the selected quantization strategy comprises any one of the following: 16-bit quantization, 8-bit quantization, 4-bit quantization and 2-bit quantization.

7. A device for determining a network model quantization strategy, characterized in that: The device comprises: A quantization strategy search space generation module is configured to generate a quantization strategy search space using configuration information of the quantization strategy search space of the network model for the target hardware; An encoding module, configured to adopt the quantization strategy search space to generate a quantization strategy encoding generator; A quantization strategy code generation module is configured to randomly generate a quantization strategy code using the quantization strategy code generator; A decoding module is configured to decode the quantization strategy code to obtain a quantization strategy to be selected; The target quantization strategy determination module is configured to determine the target quantization strategy of the network model for the target hardware according to the quantization accuracy loss of the network model corresponding to the selected quantization strategy, and to quantize the initial model using the target quantization strategy to obtain the target model, wherein the initial model is an image processing model applied to the target hardware.

8. The device according to claim 7, wherein: The target quantization strategy determination module is further configured to: In response to the quantization accuracy loss of the network model of the candidate quantization strategy being less than a predetermined threshold, the candidate quantization strategy is determined as a target quantization strategy for the target hardware.

9. The device according to claim 7 or 8, wherein: The target quantization strategy determination module is further configured to: In response to the quantization accuracy loss of the network model of the candidate quantization strategy being greater than a predetermined threshold, using the quantization strategy code generator to generate a new set of quantization strategy codes, and decoding the new set of quantization strategy codes to obtain a new candidate quantization strategy; A target quantization strategy for target hardware is determined according to the quantization accuracy loss corresponding to the new candidate quantization strategy.

10. The device according to claim 7, wherein: The candidate quantization strategies include offline quantization strategies and online quantization strategies.

11. The apparatus according to claim 7, further comprising: A training sample acquisition module is configured to acquire a training sample set; An initial model training module is configured to train a network model for target hardware using the training sample set to obtain an initial model; The initial model quantization module is configured to quantize the initial model using the target quantization strategy to obtain a target model.

12. The device according to any one of claims 7 to 11, wherein the selected quantization strategy comprises at least one of the following: 16-bit quantization, 8-bit quantization, 4-bit quantization and 2-bit quantization.

13. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.

14. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the method of any one of claims 1 to 6.