CN111598219A - Quantization method, device, equipment and medium for depth separable convolution - Google Patents
Quantization method, device, equipment and medium for depth separable convolution Download PDFInfo
- Publication number
- CN111598219A CN111598219A CN202010387381.9A CN202010387381A CN111598219A CN 111598219 A CN111598219 A CN 111598219A CN 202010387381 A CN202010387381 A CN 202010387381A CN 111598219 A CN111598219 A CN 111598219A
- Authority
- CN
- China
- Prior art keywords
- result
- depth
- convolution
- quantization
- layer
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000013139 quantization Methods 0.000 title claims abstract description 150
- 238000000034 method Methods 0.000 title claims abstract description 53
- 238000012545 processing Methods 0.000 claims description 17
- 238000005457 optimization Methods 0.000 claims description 14
- 238000010586 diagram Methods 0.000 description 18
- 230000006870 function Effects 0.000 description 10
- 230000008569 process Effects 0.000 description 10
- 230000006872 improvement Effects 0.000 description 9
- 238000003860 storage Methods 0.000 description 9
- 238000004590 computer program Methods 0.000 description 7
- 238000007667 floating Methods 0.000 description 7
- 238000004364 calculation method Methods 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 5
- 230000004913 activation Effects 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 238000003062 neural network model Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000003213 activating effect Effects 0.000 description 1
- 238000013528 artificial neural network Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000009826 distribution Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000005055 memory storage Effects 0.000 description 1
- 229920001296 polysiloxane Polymers 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 238000012549 training Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- General Health & Medical Sciences (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- Computational Linguistics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Evolutionary Computation (AREA)
- Artificial Intelligence (AREA)
- Molecular Biology (AREA)
- Computing Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Health & Medical Sciences (AREA)
- Image Processing (AREA)
Abstract
The application discloses a quantization method, device, equipment and medium for depth separable convolution, which comprises the following steps: determining a first quantization factor corresponding to the input feature map of the depth convolutional layer according to the maximum value of the input feature map of the depth convolutional layer, and determining a first result according to the input feature map of the depth convolutional layer and the first quantization factor; determining a second quantization factor corresponding to the depth convolutional layer convolutional kernel according to the maximum value of the absolute value of the depth convolutional layer convolutional kernel, and determining a second result according to the depth convolutional layer convolutional kernel and the second quantization factor; performing depth convolution on the first result and the second result to determine a third result; and quantizing the third result into preset first format data according to the quantization coefficient corresponding to each channel of the predetermined depth convolution layer.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a quantization method, apparatus, device, and medium for depth separable convolution.
Background
The depth separable convolution module is a standardized convolution deformation combination in a convolution neural network model, and one depth separable convolution module comprises one depth convolution layer and one point-by-point convolution layer. Typically, the input to the depth separable convolution module is a standard convolution layer.
In the prior art, the deep separable convolution still has the defects, and more resources are consumed during application.
Disclosure of Invention
In view of this, embodiments of the present application provide a quantization method, an apparatus, a device, and a medium for depth separable convolution, so as to solve the problem in the prior art that depth separable convolution consumes more resources when applied.
The embodiment of the application adopts the following technical scheme:
the embodiment of the application provides a quantization method of depth separable convolution, which comprises the following steps:
determining a first quantization factor corresponding to the input feature map of the depth convolutional layer according to the maximum value of the input feature map of the depth convolutional layer, and determining a first result according to the input feature map of the depth convolutional layer and the first quantization factor;
determining a second quantization factor corresponding to the depth convolutional layer convolutional kernel according to the maximum value of the absolute value of the depth convolutional layer convolutional kernel, and determining a second result according to the depth convolutional layer convolutional kernel and the second quantization factor;
performing depth convolution on the first result and the second result to determine a third result;
and quantizing the third result into preset first format data according to the quantization coefficient corresponding to each channel of the predetermined depth convolution layer.
Further, the determining a first result according to the depth convolution layer input feature map and the first quantization factor specifically includes:
and multiplying the depth convolution layer input feature map by the first quantization factor to obtain a first result.
Further, after the multiplying the depth convolution layer input feature map by the first quantization factor to obtain a first result, the method further includes:
performing first optimization processing on the first result to obtain an optimized first result, wherein the first optimization processing is to limit the first result within a preset threshold;
and converting the optimized first result into preset second format data.
Further, the determining a second result according to the absolute value of the depth convolution layer convolution kernel and the second quantization factor specifically includes:
and multiplying the depth convolution layer convolution kernel by the second quantization factor to obtain a second result.
Further, after the multiplying the depth convolution layer convolution kernel by the second quantization factor to obtain a second result, the method further includes:
performing second optimization processing on the second result to obtain an optimized second result, wherein the second optimization processing is to limit the second result within a second preset threshold;
and converting the optimized second result into preset third format data.
Further, the depth convolution is performed on the first result and the second result to determine a third result, which specifically includes:
and performing depth convolution on the second format data and the third format data to determine a third result.
Further, before the step of convolution of the corresponding quantized coefficients according to the predetermined point-by-point, the method further includes:
determining a quantization factor of each channel of the depth convolution layer according to the maximum value of each channel of the depth convolution layer;
and multiplying the reciprocal of the product of the first quantization factor and the second quantization factor by the quantization factor of each channel of the depth convolution layer to obtain the quantization coefficient corresponding to each channel of the depth convolution layer.
The embodiment of the present application further provides a quantization apparatus for depth separable convolution, the apparatus includes:
the first result unit is used for determining a first quantization factor corresponding to the input feature map of the depth convolutional layer according to the maximum value of the input feature map of the depth convolutional layer and determining a first result according to the input feature map of the depth convolutional layer and the first quantization factor;
the second result unit is used for determining a second quantization factor corresponding to the depth convolutional layer convolutional kernel according to the maximum value of the absolute value of the depth convolutional layer convolutional kernel, and determining a second result according to the depth convolutional layer convolutional kernel and the second quantization factor;
a third result unit, configured to perform depth convolution on the first result and the second result to determine a third result;
and the quantization unit is used for quantizing the third result into preset first format data according to the quantization coefficient corresponding to each channel of the predetermined depth convolution layer.
An embodiment of the present application further provides a quantization apparatus for depth separable convolution, where the apparatus includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
determining a first quantization factor corresponding to the input feature map of the depth convolutional layer according to the maximum value of the input feature map of the depth convolutional layer, and determining a first result according to the input feature map of the depth convolutional layer and the first quantization factor;
determining a second quantization factor corresponding to the depth convolutional layer convolutional kernel according to the maximum value of the absolute value of the depth convolutional layer convolutional kernel, and determining a second result according to the depth convolutional layer convolutional kernel and the second quantization factor;
performing depth convolution on the first result and the second result to determine a third result;
and quantizing the third result into preset first format data according to the quantization coefficient corresponding to each channel of the predetermined depth convolution layer.
An embodiment of the present application further provides a quantization medium for depth separable convolution, in which computer-executable instructions are stored, and the computer-executable instructions are set to:
determining a first quantization factor corresponding to the input feature map of the depth convolutional layer according to the maximum value of the input feature map of the depth convolutional layer, and determining a first result according to the input feature map of the depth convolutional layer and the first quantization factor;
determining a second quantization factor corresponding to the depth convolutional layer convolutional kernel according to the maximum value of the absolute value of the depth convolutional layer convolutional kernel, and determining a second result according to the depth convolutional layer convolutional kernel and the second quantization factor;
performing depth convolution on the first result and the second result to determine a third result;
and quantizing the third result into preset first format data according to the quantization coefficient corresponding to each channel of the predetermined depth convolution layer.
The embodiment of the application adopts at least one technical scheme which can achieve the following beneficial effects: according to the embodiment of the application, the resource consumed by the depth convolution layer during application is reduced by quantizing the feature map and the convolution kernel of the depth convolution layer.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a schematic diagram of a depth separable convolution module;
fig. 2 is a flowchart illustrating a quantization method for depth separable convolution according to an embodiment of the present disclosure;
fig. 3 is a flowchart illustrating a quantization method for depth separable convolution according to a second embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a depth separable convolution quantization apparatus provided in the third embodiment of this specification.
Detailed Description
The depth separable convolution module is a standardized convolution deformation combination in a convolution neural network model, and one depth separable convolution module comprises one depth convolution layer and one point-by-point convolution layer. Typically, the input to the depth separable convolution module is a standard convolution layer. In the modern main deep neural network convolution model, a standard convolution layer and a deep separable convolution module form a sub-module, and the sub-module is stacked together to form the feature extractor of the convolution model. In such a submodule, the convolution kernel size of the standard convolution layer is set to 1 × 1, and the input feature map is subjected to channel expansion; the convolution kernel size of the depth convolution layer is set to be 3x3, and independent convolution transformation is carried out on each channel of the feature map, so that the number of the channels is kept unchanged; the convolution kernel size of the point-wise convolutional layer was set to 1x1, which is calculated in accordance with the standard convolution, but is a linear convolutional layer, so there is no activation function within the point-wise convolutional layer. As shown in fig. 1, the dotted line is a depth separable convolution module, and three layers of convolutions form a sub-module. The sub-module inputs the feature map, and assumes that the height width and the channel number are H, W and C respectively, the standard convolution layer has the input channel expansion coefficient t, the convolution kernel moving step length of the depth convolution is 1 or 2, when the step length is 1, the height and the width of the output feature map are unchanged, and when the step length is 2, the height and the width of the output feature map become half of the original height and width. After the point-by-point convolution layer, the number of the feature map channels is C'.
The depth separable convolution module is characterized by small calculated amount, and compared with a standard convolution layer of 3x3, the depth separable convolution module reduces the calculated amount to be 1/9-1/8, so that the depth separable convolution module is mainly applied to equipment with limited calculation resources, such as an embedded end and the like, for example, a face detection and recognition model of a mobile phone. However, the deep separable convolution module, although computationally inexpensive, still uses 32-bit floating point numbers for computational reasoning, and still consumes significant computational and memory resources.
In order to make the objects, technical solutions and advantages of the present application more apparent, the technical solutions of the present application will be described in detail and completely with reference to the following specific embodiments of the present application and the accompanying drawings. It should be apparent that the described embodiments are only some of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Fig. 2 is a flowchart illustrating a quantization method for depth separable convolution according to an embodiment of the present disclosure, which specifically includes:
step S101, the depth separable convolution quantization system determines a first quantization factor corresponding to a depth convolution layer input feature map according to the maximum value of the depth convolution layer input feature map, and determines a first result according to the depth convolution layer input feature map and the first quantization factor.
Step S102, the depth separable convolution quantization system determines a second quantization factor corresponding to the depth convolution layer convolution kernel according to the maximum value of the absolute value of the depth convolution layer convolution kernel, and determines a second result according to the depth convolution layer convolution kernel and the second quantization factor.
Step S103, the depth separable convolution quantization system performs depth convolution on the first result and the second result to determine a third result.
And step S104, quantizing the third result into preset first format data by the depth separable convolution quantizing system according to the predetermined quantized coefficient corresponding to each channel of the depth convolution layer.
According to the embodiment of the application, the resource consumed by the depth convolution layer during application is reduced by quantizing the feature map and the convolution kernel of the depth convolution layer.
Correspondingly to the embodiment of the present specification, fig. 3 is a schematic flowchart of a quantization method for depth separable convolution according to a second embodiment of the present specification, and specifically includes:
in step S201, the depth separable convolution quantization system determines a first quantization factor corresponding to the depth convolution layer input feature map according to a maximum value of the depth convolution layer input feature map, and determines a first result according to the depth convolution layer input feature map and the first quantization factor.
Determining a first result according to the depth convolution layer input feature map and the first quantization factor, specifically comprising:
and multiplying the depth convolution layer input feature map by the first quantization factor to obtain a first result.
After the multiplying the depth convolution layer input feature map by the first quantization factor to obtain a first result, the method further includes:
performing first optimization processing on the first result to obtain an optimized first result, wherein the first optimization processing is to limit the first result within a preset threshold;
and converting the optimized first result into preset second format data.
The first optimization process may be rounding the first result and then limiting the value exceeding 255 to 255, and the second format data may be unsigned 8-bit integer.
Step S202, the depth separable convolution quantization system determines a second quantization factor corresponding to the depth convolution layer convolution kernel according to the maximum value of the absolute value of the depth convolution layer convolution kernel, and determines a second result according to the depth convolution layer convolution kernel and the second quantization factor.
Determining a second result according to the absolute value of the convolution kernel of the depth convolution layer and the second quantization factor, which specifically comprises:
and multiplying the depth convolution layer convolution kernel by the second quantization factor to obtain a second result.
After the multiplying the depth convolution layer convolution kernel by the second quantization factor to obtain a second result, the method further includes:
performing second optimization processing on the second result to obtain an optimized second result, wherein the second optimization processing is to limit the second result within a second preset threshold;
and converting the optimized second result into preset third format data.
The second optimization process may be rounding the product result, then limiting the value exceeding 127 to 127, changing the value less than-127 to-127, and the third format data may be signed 8-bit integer.
Step S203, the quantization system of depth separable convolution performs depth convolution on the first result and the second result to determine a third result.
Performing depth convolution on the first result and the second result to determine a third result, which specifically includes:
and performing depth convolution on the second format data and the third format data to determine a third result.
The above step may be deep convolving the feature map of the unsigned 8-bit integer with the convolution kernel of the signed 8-bit integer, and the third result is represented by the signed 32-bit integer. If the result is divided by the product of two quantization factors and multiplied by the quantization factor for each channel, then activation is performed, the result being the quantized input to the point-by-point convolutional layer. However, the quantization factors are all floating point numbers, and the operations still involve floating point number operations, so that equivalent calculation is required to avoid the floating point number operations. Before this, the quantized coefficients for each channel of the depth convolution layer need to be determined.
Step S204, the quantization system of depth separable convolution quantizes the third result into the preset first format data according to the predetermined quantization coefficient corresponding to each channel of the depth convolution layer.
Because each convolution kernel in the convolution kernels of the depth convolution layer has only one channel, the data distribution deviation in each channel of the feature map output by the depth convolution layer is large, and therefore, the output of the layer needs to be divided according to the channels, and the data in each channel needs to be quantized independently. The quantization is first limited to a range, which is statistically derived by the training process, using the maximum and minimum values that may occur. The quantized feature map may be represented by unsigned 8-bit integer values. First, a quantization factor for each channel may be calculated based on the maximum value of each channel, and the quantization factor may be represented using 64-bit floating point numbers. The value of each channel in the feature map is multiplied by the quantization factor corresponding to that channel, the product result can be rounded, then the value exceeding 255 can be changed to 255, and finally all values can be converted into 8-bit integer without sign.
Further, before the step of convolution of the corresponding quantized coefficients according to the predetermined point-by-point, the method further includes:
determining a quantization factor of each channel of the depth convolution layer according to the maximum value of each channel of the depth convolution layer;
and multiplying the reciprocal of the product of the first quantization factor and the second quantization factor by the quantization factor of each channel of the depth convolution layer to obtain the quantization coefficient corresponding to each channel of the depth convolution layer.
The method specifically comprises the following steps: multiply by 2 or divide by 2 a number of times until the quantization factor is between 0.5,1.0), and then multiply by 231And converted to signed 32-bit integers. Multiplying each channel of the signed 32-bit feature map output by the depth convolution layer by the corresponding coefficient of the channel, storing the result as a signed 64-bit floating point number, and then carrying out shift operation to eliminate the influence caused by adjusting the coefficient. And activating the shifted result, and then converting the result into an unsigned 8-bit integer to obtain the output of the depth convolution layer.
The fifth, sixth, and seventh layers of the depth separable convolution model mobilonetv 2 are exemplified. The input is a 112x112x16 feature map, the fifth layer is a standard 1x1 convolutional layer, the input channel is expanded six times, the sixth layer is 3x3 depth separable convolution with the step size of 2, the seventh layer is 1x1 point-by-point convolution, and the output is a 56x56x24 feature map.
First, the fifth layer output, which is the input of the convolution layer with the sixth layer depth, is countedMaximum value of the feature map of (1), is recorded asFind the maximum of the absolute value of the convolution kernel in the sixth layer, which is recorded asCounting the maximum value of each channel on the feature map output by the sixth layer and recording the maximum valuei represents the ith channel; the maximum value of the absolute value of the convolution kernel of the seventh layer point-by-point convolution layer is counted and recorded asLet Q be the quantization factor, the quantization factor calculation formula of the convolution kernel is Q127/RwThe calculation formula of the quantization factor of each channel of the characteristic diagram or the characteristic diagram is that Q is 255/Ra. Respectively calculating the quantization factors of the convolution kernel and the characteristic diagram or the channel according to a quantization factor calculation formula, wherein the quantization factor of the sixth layer input characteristic diagram isThe sixth layer has a convolution kernel quantization factor ofThe quantization factor of each channel on the characteristic diagram output by the sixth layer is
Calculating coefficients for each channelIf M isiGreater than or equal to 1, then calculating the positive integer niSo thatIf M isi<1, then calculating a non-positive integer niSo thatThen orderNamely, it is
The method of the embodiment of the present specification is applied to quantize the input and convolution kernel of the sixth layer depth convolution layer, and then depth convolution is performed on the quantized convolution kernel and the quantized input, so as to obtain a signed 32-bit feature map. And the value and corresponding M on each channel of the signed 32-bit feature mapiMultiplying and then shifting right by a shift of 31-n bitsiAfter the shift operation, the result is converted to an unsigned 8 bit value. Inputting the result into a seventh layer point-by-point convolution layer, and carrying out convolution operation on the result and a quantized convolution kernel to obtain a characteristic diagram with a sign 32-bit integer.
The characteristic diagram of signed 32-bit integer output by the seventh layer of point-by-point convolution layer can be converted into floating point numbers and input into the next layer, and the integer input into the next layer can also be continuously kept.
Corresponding to the second embodiment of the present specification, fig. 4 is a schematic structural diagram of a quantization apparatus for depth separable convolution according to the third embodiment of the present specification, and specifically includes: a first result unit 1, a second result unit 2, a third result unit 3 and a quantization unit 4.
The first result unit 1 is configured to determine a first quantization factor corresponding to a depth convolutional layer input feature map according to a maximum value of the depth convolutional layer input feature map, and determine a first result according to the depth convolutional layer input feature map and the first quantization factor;
the second result unit 2 is configured to determine a second quantization factor corresponding to the depth convolutional layer convolutional kernel according to a maximum value of an absolute value of the depth convolutional layer convolutional kernel, and determine a second result according to the depth convolutional layer convolutional kernel and the second quantization factor;
the third result unit 3 is configured to perform depth convolution on the first result and the second result to determine a third result;
the quantization unit 4 is configured to quantize the third result into preset first format data according to the quantization coefficient corresponding to each channel of the predetermined depth convolution layer.
An embodiment of the present application further provides a quantization apparatus for depth separable convolution, where the apparatus includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
determining a first quantization factor corresponding to the input feature map of the depth convolutional layer according to the maximum value of the input feature map of the depth convolutional layer, and determining a first result according to the input feature map of the depth convolutional layer and the first quantization factor;
determining a second quantization factor corresponding to the depth convolutional layer convolutional kernel according to the maximum value of the absolute value of the depth convolutional layer convolutional kernel, and determining a second result according to the depth convolutional layer convolutional kernel and the second quantization factor;
performing depth convolution on the first result and the second result to determine a third result;
and quantizing the third result into preset first format data according to the quantization coefficient corresponding to each channel of the predetermined depth convolution layer.
An embodiment of the present application further provides a quantization medium for depth separable convolution, in which computer-executable instructions are stored, and the computer-executable instructions are set to:
determining a first quantization factor corresponding to the input feature map of the depth convolutional layer according to the maximum value of the input feature map of the depth convolutional layer, and determining a first result according to the input feature map of the depth convolutional layer and the first quantization factor;
determining a second quantization factor corresponding to the depth convolutional layer convolutional kernel according to the maximum value of the absolute value of the depth convolutional layer convolutional kernel, and determining a second result according to the depth convolutional layer convolutional kernel and the second quantization factor;
performing depth convolution on the first result and the second result to determine a third result;
and quantizing the third result into preset first format data according to the quantization coefficient corresponding to each channel of the predetermined depth convolution layer.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Furthermore, nowadays, instead of manually making an integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Language Description Language), traffic, pl (core unified Programming Language), HDCal, JHDL (Java Hardware Description Language), langue, Lola, HDL, laspam, hardsradware (Hardware Description Language), vhjhd (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium which can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims (10)
1. A method of quantizing a depth separable convolution, the method comprising:
determining a first quantization factor corresponding to the input feature map of the depth convolutional layer according to the maximum value of the input feature map of the depth convolutional layer, and determining a first result according to the input feature map of the depth convolutional layer and the first quantization factor;
determining a second quantization factor corresponding to the depth convolutional layer convolutional kernel according to the maximum value of the absolute value of the depth convolutional layer convolutional kernel, and determining a second result according to the depth convolutional layer convolutional kernel and the second quantization factor;
performing depth convolution on the first result and the second result to determine a third result;
and quantizing the third result into preset first format data according to the quantization coefficient corresponding to each channel of the predetermined depth convolution layer.
2. The method of claim 1, wherein the determining a first result according to the depth convolution layer input feature map and the first quantization factor comprises:
and multiplying the depth convolution layer input feature map by the first quantization factor to obtain a first result.
3. The method of quantization for depth separable convolution of claim 2, wherein after multiplying the depth convolution layer input feature map by the first quantization factor to obtain a first result, the method further comprises:
performing first optimization processing on the first result to obtain an optimized first result, wherein the first optimization processing is to limit the first result within a preset threshold;
and converting the optimized first result into preset second format data.
4. The method of claim 3, wherein determining a second result according to the absolute value of the depth convolution layer convolution kernel and the second quantization factor comprises:
and multiplying the depth convolution layer convolution kernel by the second quantization factor to obtain a second result.
5. The method of quantizing depth separable convolutions according to claim 4, wherein after multiplying the depth convolution layer convolution kernel by the second quantization factor to obtain a second result, the method further comprises:
performing second optimization processing on the second result to obtain an optimized second result, wherein the second optimization processing is to limit the second result within a second preset threshold;
and converting the optimized second result into preset third format data.
6. The method for quantizing depth-separable convolutions according to claim 5, wherein the depth-convolving the first result with the second result to determine a third result specifically comprises:
and performing depth convolution on the second format data and the third format data to determine a third result.
7. The method of quantizing depth-separable convolutions according to claim 1, wherein said method further comprises, prior to concatenating corresponding quantized coefficients according to a predetermined point-by-point, the method comprising:
determining a quantization factor of each channel of the depth convolution layer according to the maximum value of each channel of the depth convolution layer;
and multiplying the reciprocal of the product of the first quantization factor and the second quantization factor by the quantization factor of each channel of the depth convolution layer to obtain the quantization coefficient corresponding to each channel of the depth convolution layer.
8. An apparatus for depth separable convolution quantization, the apparatus comprising:
the first result unit is used for determining a first quantization factor corresponding to the input feature map of the depth convolutional layer according to the maximum value of the input feature map of the depth convolutional layer and determining a first result according to the input feature map of the depth convolutional layer and the first quantization factor;
the second result unit is used for determining a second quantization factor corresponding to the depth convolutional layer convolutional kernel according to the maximum value of the absolute value of the depth convolutional layer convolutional kernel, and determining a second result according to the depth convolutional layer convolutional kernel and the second quantization factor;
a third result unit, configured to perform depth convolution on the first result and the second result to determine a third result;
and the quantization unit is used for quantizing the third result into preset first format data according to the quantization coefficient corresponding to each channel of the predetermined depth convolution layer.
9. An apparatus for depth separable convolution quantization, the apparatus comprising:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to:
determining a first quantization factor corresponding to the input feature map of the depth convolutional layer according to the maximum value of the input feature map of the depth convolutional layer, and determining a first result according to the input feature map of the depth convolutional layer and the first quantization factor;
determining a second quantization factor corresponding to the depth convolutional layer convolutional kernel according to the maximum value of the absolute value of the depth convolutional layer convolutional kernel, and determining a second result according to the depth convolutional layer convolutional kernel and the second quantization factor;
performing depth convolution on the first result and the second result to determine a third result;
and quantizing the third result into preset first format data according to the quantization coefficient corresponding to each channel of the predetermined depth convolution layer.
10. A depth separable convolved quantization medium storing computer-executable instructions configured to:
determining a first quantization factor corresponding to the input feature map of the depth convolutional layer according to the maximum value of the input feature map of the depth convolutional layer, and determining a first result according to the input feature map of the depth convolutional layer and the first quantization factor;
determining a second quantization factor corresponding to the depth convolutional layer convolutional kernel according to the maximum value of the absolute value of the depth convolutional layer convolutional kernel, and determining a second result according to the depth convolutional layer convolutional kernel and the second quantization factor;
performing depth convolution on the first result and the second result to determine a third result;
and quantizing the third result into preset first format data according to the quantization coefficient corresponding to each channel of the predetermined depth convolution layer.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010387381.9A CN111598219A (en) | 2020-05-09 | 2020-05-09 | Quantization method, device, equipment and medium for depth separable convolution |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010387381.9A CN111598219A (en) | 2020-05-09 | 2020-05-09 | Quantization method, device, equipment and medium for depth separable convolution |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111598219A true CN111598219A (en) | 2020-08-28 |
Family
ID=72191181
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010387381.9A Pending CN111598219A (en) | 2020-05-09 | 2020-05-09 | Quantization method, device, equipment and medium for depth separable convolution |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111598219A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113344200A (en) * | 2021-06-17 | 2021-09-03 | 阿波罗智联(北京)科技有限公司 | Method for training separable convolutional network, road side equipment and cloud control platform |
-
2020
- 2020-05-09 CN CN202010387381.9A patent/CN111598219A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113344200A (en) * | 2021-06-17 | 2021-09-03 | 阿波罗智联(北京)科技有限公司 | Method for training separable convolutional network, road side equipment and cloud control platform |
CN113344200B (en) * | 2021-06-17 | 2024-05-28 | 阿波罗智联(北京)科技有限公司 | Method for training separable convolutional network, road side equipment and cloud control platform |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112200132B (en) | Data processing method, device and equipment based on privacy protection | |
CN111181569B (en) | Compression method, device and equipment of time sequence data | |
CN112199707A (en) | Data processing method, device and equipment in homomorphic encryption | |
CN111652351A (en) | Deployment method, device and medium of neural network model | |
CN115981870A (en) | Data processing method and device, storage medium and electronic equipment | |
CN111598219A (en) | Quantization method, device, equipment and medium for depth separable convolution | |
CN116107636B (en) | Hardware acceleration method and device, storage medium and electronic equipment | |
CN115221523B (en) | Data processing method, device and equipment | |
CN116363418A (en) | Method and device for training classification model, storage medium and electronic equipment | |
CN116186781A (en) | Model training method and device, storage medium and electronic equipment | |
CN115952859A (en) | Data processing method, device and equipment | |
CN109325127B (en) | Risk identification method and device | |
CN111522527B (en) | Method and device for preventing saturation overflow of data register and electronic equipment | |
CN117873789B (en) | Checkpoint writing method and device based on segmentation quantization | |
CN116243885B (en) | Full adder circuit and multi-bit full adder | |
CN114972909B (en) | Model training method, map construction method and map construction device | |
CN111651450B (en) | Block copy method, device, equipment and medium based on block chain | |
CN118428333B (en) | Method, device, storage medium and electronic equipment for enhancing text data | |
CN116521713B (en) | Data query method, device, equipment and storage medium | |
CN112115952B (en) | Image classification method, device and medium based on full convolution neural network | |
CN112434486B (en) | Automatic paging method, device, equipment and medium for device in PCB design | |
CN118568469A (en) | Feature extraction method, device, medium and equipment | |
CN107391525B (en) | Instruction processing method and device for database | |
CN117437327A (en) | Method and device for generating design material, storage medium and electronic equipment | |
CN117496529A (en) | Training method of text detection model, text detection method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200828 |