Mesh sampling quantization method, system and terminal for optical flow network end side deployment

By eliminating floating-point operations through integer scaling and pixel mapping operations in the optical flow network and introducing locality constraint verification, the floating-point dependency and accuracy loss problems of the grid sampling quantization scheme are solved, and efficient and low-power optical flow estimation is achieved.

CN122675641BActive Publication Date: 2026-11-24SHANGHAI GUANGYU XINCHEN TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202611186154.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-08-06
Publication Date
2026-11-24
Estimated Expiration
2046-08-06

AI Technical Summary

Technical Problem

Existing grid sampling quantization schemes suffer from problems such as heavy floating-point dependence, significant loss of quantization accuracy, and difficulty in detecting abnormal sampling when deployed on the optical flow network edge. This leads to decreased optical flow estimation accuracy, high kernel overhead of edge devices, high computational resource consumption, limited hardware execution efficiency, and high power consumption.

Method used

By performing integer scaling and pixel mapping operations on the normalized floating-point grid coordinates of the optical flow network, floating-point operations are eliminated. A locality constraint verification mechanism is introduced to remove abnormal sampling points. High-resolution fixed-point coordinates and adaptive compression weights are used for bilinear interpolation to ensure interpolation accuracy.

Benefits of technology

Performing bilinear interpolation in the integer field reduces hardware floating-point unit dependency, lowers power consumption, improves hardware execution efficiency and speed, and enhances robustness and monitorability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122675641B_ABST
    Figure CN122675641B_ABST
Patent Text Reader

Abstract

This application provides a grid sampling quantization method, system, and terminal for edge deployment of optical flow networks. By performing integer scaling and pixel mapping operations on the normalized floating-point grid coordinates of the feature map to be sampled, the entire bilinear interpolation operation is completed entirely in the integer domain, eliminating floating-point operations within the grid sampling operator, greatly reducing the dependence on hardware floating-point units, and reducing the power consumption of the edge device. At the same time, a locality constraint verification mechanism is introduced to improve the robustness and monitorability of the quantization inference process of the network sampling operator. By performing bilinear interpolation operations with high-resolution fixed-point coordinates and adaptive compression weights, the network sampling operator maintains interpolation accuracy under extremely low bit-width operation conditions, improving the hardware execution efficiency and running speed of the edge device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of deep learning technology, and in particular to a grid sampling quantization method, system, and terminal for edge deployment of optical flow networks. Background Technology

[0002] When deploying deep learning models on edge devices, integer quantization of the deep learning model is often used to accelerate inference and reduce memory usage. Optical flow networks are deep neural network models that perform dense optical flow estimation. They can be used for AI frame interpolation in edge games. By estimating pixel motion between adjacent rendering frames through optical flow, intermediate frames are generated, thereby enhancing the smoothness and continuity of the visuals, reducing game stuttering, and simultaneously reducing the GPU rendering load, lowering the power consumption of edge devices, and reducing the heat generated by edge devices.

[0003] Mesh sampling is a key operator in optical flow networks. Its core is to perform bilinear interpolation on the input feature map based on normalized mesh coordinates, sampling the pixel value of each mesh coordinate.

[0004] Existing grid sampling primarily employs integer quantization and mixed-precision quantization schemes. Integer quantization converts floating-point coordinates and weights into low-bit integers to replace the precise calculation of sub-pixel offsets in bilinear interpolation. This quantization scheme is simple and saves memory bandwidth and hardware computing resources, but it loses sub-pixel precision, leading to severe interpolation errors and image distortion (such as a noticeable checkerboard effect), significantly impacting optical flow estimation tasks. Mixed-precision quantization uses low-bit integers for network inference in both front-end and back-end layers, switching back to floating-point numbers (such as FP16 and FP32) within the grid sampling operator for coordinate calculation and bilinear interpolation, before quantizing back to low-bit integers. This quantization scheme results in frequent data format conversions, increasing additional kernel overhead and data transfer costs, affecting end-to-end acceleration efficiency, and consequently increasing power consumption on edge devices. Furthermore, grid sampling can currently also use lookup table quantization schemes, using pre-computed interpolation weight lookup tables to avoid or mitigate the checkerboard error caused by low-bit integer quantization of sampling coordinates; however, this quantization scheme is not hardware-friendly and impacts hardware execution efficiency.

[0005] Therefore, existing grid sampling quantization schemes suffer from heavy floating-point dependence and significant loss of quantization accuracy. Furthermore, they lack a mechanism to detect abnormal sampling points that may occur during quantization, resulting in difficulty in detecting such abnormal sampling. This can easily lead to decreased optical flow estimation accuracy, high kernel overhead, high computational resource consumption, limited hardware execution efficiency and speed, and high power consumption when the optical flow network model is deployed on edge devices. Summary of the Invention

[0006] In view of the shortcomings of the prior art described above, the purpose of this application is to provide a grid sampling quantization method, system and terminal for edge deployment of optical flow networks, to solve the technical problems of existing grid sampling quantization schemes when optical flow network models are deployed on edge devices, such as heavy floating-point dependence, large loss of quantization accuracy, difficulty in detecting abnormal sampling leading to decreased optical flow estimation accuracy, large kernel overhead of edge devices, high computational resource consumption, limited hardware execution efficiency, limited running speed and high power consumption.

[0007] To achieve the above and other related objectives, a first aspect of this application provides a grid sampling quantization method for edge deployment of optical flow networks. This method is applied to a grid sampling operator of an optical flow network model deployed on an edge device, comprising: acquiring a feature map to be sampled in the optical flow network and its normalized floating-point grid coordinates; performing integer scaling and pixel mapping operations on the normalized floating-point grid coordinates to obtain pixel coordinates of multiple sampling points in the feature map; calculating the four-neighbor boundary coordinates and quantization reference coordinates of each sampling point based on their pixel coordinates; performing locality constraint verification on each sampling point to remove one or more abnormal sampling points; reading the four-neighbor pixel tensors of the remaining multiple reliable sampling points; calculating the four-neighbor pixel weight tensors of each reliable sampling point based on their sub-pixel residuals; performing bilinear interpolation to obtain the target pixel values ​​of each reliable sampling point; and outputting a target sampled feature map for optical flow estimation.

[0008] In some embodiments of the first aspect of this application, the method of performing integer scaling and pixel mapping operations on the normalized floating-point grid coordinates includes: determining the target quantization bit width and scaling factor of the normalized floating-point grid coordinates, and performing an integer scaling operation on the normalized floating-point grid coordinates to linearly map the normalized floating-point grid coordinates to fixed-point integer grid coordinates of the target quantization bit width; performing a pixel mapping operation on the fixed-point integer grid coordinates to map the fixed-point integer grid coordinates to the pixel space of the feature map to be sampled, thereby obtaining the pixel fixed-point coordinates of multiple sampling points in the feature map to be sampled.

[0009] In some embodiments of the first aspect of this application, the linear mapping formula for linearly mapping the normalized floating-point grid coordinates to the fixed-point integer grid coordinates of the target quantization bit width is as follows: ;in, The fixed-point integer grid coordinates; The normalized floating-point grid coordinates; Quantize the bit width for the target.

[0010] In some embodiments of the first aspect of this application, a pixel mapping operation is performed on the fixed-point integer grid coordinates according to the pixel edge alignment mode. Specifically, if the pixel edge alignment mode is True, the fixed-point integer grid coordinates are mapped to the pixel center of the feature map to be sampled. The calculation formula for pixel space mapping is as follows: ; If the pixel edge alignment mode is False, then the fixed-point integer grid coordinates are mapped to the pixel edges of the feature map to be sampled. The calculation formula for pixel space mapping is: ; ;in, The pixel coordinates of the sampling point; The integer fixed coordinates of the sampling points; Quantize the bit width of the target; The height of the feature map to be sampled. The width of the feature map to be sampled.

[0011] In some embodiments of the first aspect of this application, the method for performing local constraint verification on the sampling points includes: constructing a theoretical reference coordinate grid. Wherein, the theoretical reference coordinate grid The size is consistent with the feature map to be sampled; calculate the quantization reference coordinates of the sampling points. With the theoretical reference coordinates drift difference The calculation formula is: ;in, Use the quantization reference coordinates of the sampling points; determine the drift difference of the sampling points. Does it exceed the preset allowable drift threshold? ;like If the sampling point fails to detect an abnormal quantization jump, it will be removed as an abnormal sampling point, and a circuit breaker operation will be performed to generate an alarm log; otherwise, the sampling point will be treated as a reliable sampling point.

[0012] In some embodiments of the first aspect of this application, the method of reading the four-neighbor pixel tensor of the trusted sampling point includes: performing a rounding operation based on the fixed point coordinates of the four-neighbor boundary of the trusted sampling point to obtain the four-neighbor pixel index of the trusted sampling point; expanding the four-neighbor pixel index of the trusted sampling point into a four-dimensional tensor and aligning the four-dimensional tensor with the dimension of the feature map to be sampled; and performing an index value operation on the feature map to be sampled based on the four-neighbor pixel index of the trusted sampling point to obtain the four-neighbor pixel tensor of the trusted sampling point.

[0013] In some embodiments of the first aspect of this application, the calculation method for the four-neighbor pixel weight tensor of the reliable sampling point based on the sub-pixel residual of the reliable sampling point includes: ; ; ; ;in, For the weight tensor of the four neighboring pixels of the reliable sampling point, The top-left pixel weight component. The weight component for the bottom left pixel. The top right pixel weight component. The weight component of the bottom right pixel; For the sub-pixel residuals of reliable sampling points, , , The pixel coordinates of the reliable sampling point; The coordinates of the upper left boundary of the reliable sampling point; For displacement, , Quantize the bit width for the target; Quantize the target bit width for weights.

[0014] In some embodiments of the first aspect of this application, the method of performing bilinear interpolation to obtain the target pixel value of the reliable sampling point includes: converting the four neighboring pixel weight tensor of the reliable sampling point into a single value. Aligned with the dimension of the feature map to be sampled; weight tensor of the four neighboring pixels of the reliable sampling point. and the four neighboring pixel tensor Perform an integer-weighted summation operation to obtain the interpolated pixel values ​​of the reliable sampling points; the formula for the integer-weighted summation operation is as follows: Perform a global right-shift normalization operation on the interpolated pixel values ​​of the reliable sampling points to obtain the target pixel values ​​of the reliable sampling points; the calculation formula is: ;in, The target pixel value of the reliable sampling point; Interpolated pixel values ​​for reliable sampling points; For the weight tensor of the four neighboring pixels of the reliable sampling point, The top-left pixel weight component. The weight component for the bottom left pixel. The top right pixel weight component. The weight component of the bottom right pixel; For the four neighboring pixels of the reliable sampling point, The top left pixel component, The lower left pixel component. The top right pixel component. The bottom right pixel component; This is the normalized displacement.

[0015] To achieve the above and other related objectives, a second aspect of this application provides a grid sampling quantization system for edge deployment in an optical flow network. The grid sampling quantization system includes: a grid coordinate mapping module, used to acquire a feature map to be sampled in the optical flow network and its normalized floating-point grid coordinates, and to perform integer scaling and pixel mapping operations on the normalized floating-point grid coordinates to obtain the pixel coordinates of multiple sampling points in the feature map to be sampled; a locality constraint verification module, connected to the grid coordinate mapping module, used to calculate the four-neighbor boundary coordinates and quantization reference coordinates of each sampling point based on the pixel coordinates of each sampling point, and to perform locality constraint verification on each sampling point to remove one or more abnormal sampling points; and a bilinear interpolation module, connected to the locality constraint verification module, used to read the four-neighbor pixel tensors of the remaining multiple reliable sampling points, and to calculate the four-neighbor pixel weight tensors of each reliable sampling point based on the sub-pixel residuals of each reliable sampling point, to perform bilinear interpolation operations to obtain the target pixel values ​​of each reliable sampling point, thereby outputting a target sampled feature map for optical flow estimation.

[0016] To achieve the above and other related objectives, a third aspect of this application provides a grid sampling quantization terminal for deployment on the end side of an optical flow network. The grid sampling quantization terminal for deployment on the end side of an optical flow network includes: a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program stored in the memory, so that the terminal performs the grid sampling quantization method for deployment on the end side of an optical flow network as described in any of the above embodiments.

[0017] As described above, this application has the following beneficial effects: This application provides a grid sampling quantization method, system, and terminal for edge deployment of optical flow networks. By performing integer scaling and pixel mapping operations on the normalized floating-point grid coordinates of the feature map to be sampled, the entire bilinear interpolation operation is completed entirely in the integer domain, eliminating the floating-point operations inside the grid sampling operator, greatly reducing the dependence on hardware floating-point units, and reducing the power consumption of the edge device. At the same time, a locality constraint verification mechanism is introduced to improve the robustness and monitorability of the quantization inference process of the network sampling operator. By performing bilinear interpolation operations with high-resolution fixed-point coordinates and adaptive compression weights, the network sampling operator maintains interpolation accuracy under extremely low bit-width operation conditions, improving the hardware execution efficiency and running speed of the edge device. Attached Figure Description

[0018] Figure 1 The diagram shows a flowchart of a grid sampling quantization method for deployment on the end side of an optical flow network according to an embodiment of this application.

[0019] Figure 2 The diagram shown is a structural schematic of a grid sampling quantization system deployed on the optical flow network end side according to an embodiment of this application.

[0020] Figure 3 The diagram shown is a structural schematic of a grid sampling and quantization terminal deployed on the optical flow network end side in one embodiment of this application. Detailed Implementation

[0021] The following specific examples illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. This application can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of this application. It should be noted that, unless otherwise specified, the following embodiments and features in the embodiments can be combined with each other.

[0022] In the embodiments of this application, the terms "first" and "second" are used to distinguish identical or similar items with essentially the same function and effect, without limiting their order. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that the terms "first" and "second" do not necessarily imply that they are different.

[0023] To address the problems mentioned above, this application provides a grid sampling quantization method, system, and terminal for edge deployment of optical flow networks. It aims to solve the technical problems of existing grid sampling quantization schemes when optical flow network models are deployed on edge devices, such as heavy floating-point dependence, significant loss of quantization accuracy, difficulty in detecting abnormal sampling leading to decreased optical flow estimation accuracy, and high kernel overhead, high computational resource consumption, limited hardware execution efficiency, limited running speed, and high power consumption on edge devices. This allows for the implementation of a low-bit-width adaptive grid sampling operator, enabling the optical flow network to execute efficiently, with low power consumption, and low error on edge devices while ensuring optical flow estimation accuracy.

[0024] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions in the embodiments of this application are further described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only for explaining this application and are not intended to limit this application.

[0025] like Figure 1 The diagram illustrates a flowchart of a mesh sampling quantization method for edge deployment in an optical flow network, as shown in this embodiment of the invention. The mesh sampling quantization method for edge deployment in an optical flow network, as described in this embodiment, includes the following steps.

[0026] Step S1: Obtain the feature map to be sampled in the optical flow network and the normalized floating-point grid coordinates of the feature map to be sampled, and perform integer scaling and pixel mapping operations on the normalized floating-point grid coordinates to obtain the pixel coordinates of multiple sampling points in the feature map to be sampled.

[0027] Optical flow networks (ORFs) are deep neural network models for dense optical flow estimation. They can be used for AI frame interpolation in mobile games, estimating pixel motion between adjacent rendered frames using optical flow to generate intermediate frames. The input to an ORF is typically two consecutive adjacent frames, and the output is the added intermediate frame image. When performing optical flow estimation, ORFs often employ a grid sampling operator based on normalized floating-point grid coordinates to perform differentiable resampling and bilinear interpolation on the input feature map to be sampled, outputting a target sampled feature map to support the optical flow estimation task.

[0028] It should be understood that the feature map to be sampled by the input grid sampling operator is a multidimensional tensor, the shape of which can be represented as follows: .in, The number of samples processed in a batch is the number of samples to be processed in one batch. In this embodiment, the number of samples processed in a batch does not affect the differentiable resampling and bilinear interpolation operations of the grid sampling operator. For simplicity, the number of samples processed in a batch of the feature map to be sampled can be expressed as the number of samples to be processed in one batch. Set to 1; The channel number represents the feature dimension of each pixel position in the feature map to be sampled. The size of the feature map to be sampled. The height of the feature map to be sampled. The width of the feature map to be sampled.

[0029] Therefore, the normalized floating-point grid coordinates of the feature map to be sampled The shape is Where 2 represents a two-dimensional coordinate, and each sampling point in the feature map to be sampled corresponds to a two-dimensional floating-point coordinate. Two-dimensional floating-point coordinates of each sampling point The range of values ​​is .

[0030] In this embodiment, to avoid rounding errors caused by division operations in bilinear interpolation of floating-point grid coordinates, step S1 involves adjusting the normalized floating-point grid coordinates. Perform integer scaling and pixel mapping operations to discretize the continuous floating-point space into a high-precision integer grid, allowing bilinear interpolation operations to be performed entirely in the integer domain.

[0031] In one embodiment, the normalized floating-point grid coordinates are... The following steps are involved in performing integer scaling and pixel mapping operations.

[0032] ① Determine the target quantization bit width and scaling factor of the normalized floating-point grid coordinates, and perform an integer scaling operation on the normalized floating-point grid coordinates to linearly map the normalized floating-point grid coordinates to fixed-point integer grid coordinates of the target quantization bit width.

[0033] Specifically, for the normalized floating-point grid coordinates When the normalized floating-point grid coordinates The target quantization bit width is At that time, the normalized floating-point grid coordinates scaling factor The normalized floating-point grid coordinates Linear mapping to Fixed-point integer grid coordinates of bits The linear mapping formula is:

[0034] ;

[0035] It should be understood that In deep learning and quantization deployment, computation refers to rounding a floating-point number to the nearest integer, thereby "flattening" consecutive floating-point values ​​onto discrete integer grid points. The operation is a numerical truncation operation used to truncate fixed-point integer grid coordinates. Limit to a given minimum value and maximum value This prevents overflow and extreme values ​​from corrupting the scaling factor. estimate.

[0036] In a preferred embodiment, the target quantization bit width At this point, the scaling factor .

[0037] It should be noted that the target quantization bit width can also be set to 8 or 10. The smaller the target quantization bit width N, the lower the quantization accuracy of the network sampling operator, but the faster the execution speed. Users can adjust it according to their needs, and this application does not specifically limit it.

[0038] ② Perform a pixel mapping operation on the fixed-point integer grid coordinates to map the fixed-point integer grid coordinates to the pixel space of the feature map to be sampled, thereby obtaining the pixel fixed-point coordinates of multiple sampling points in the feature map to be sampled.

[0039] Specifically, the two-dimensional floating-point coordinates of the sampling points in the feature map to be sampled are: The normalized floating-point grid coordinates Linear mapping to Fixed-point integer grid coordinates of bits After that, its integer fixed-point coordinates are .

[0040] In one embodiment, integer multiplication and addition operations can be used to convert the fixed-point integer grid coordinates. Mapping to pixel space, the integer fixed-point coordinates of the sampling points are... Convert to pixel coordinates .in, and It is a high-resolution fixed-point number, whose low bits can represent sub-pixel offset and the remaining high bits can represent pixel index.

[0041] Specifically, depending on the pixel edge alignment mode (align_corners), different integer arithmetic formulas are used to perform pixel mapping operations on the fixed-point integer grid coordinates.

[0042] If the pixel edge alignment mode is True (i.e., align_corners=True), then the fixed-point integer grid coordinates will be... Mapped to the pixel center of the feature map to be sampled, the calculation formula for pixel space mapping is as follows:

[0043] ;

[0044] ;

[0045] If the pixel edge alignment mode is False (align_corners=False), then the fixed-point integer grid coordinates will be... The pixel space mapping is mapped to the pixel edges of the feature map to be sampled. The calculation formula for this pixel space mapping is as follows:

[0046] ;

[0047] ;

[0048] in, The pixel coordinates of the sampling point; The integer fixed coordinates of the sampling points; Quantize the bit width of the target; The height of the feature map to be sampled. The width of the feature map to be sampled.

[0049] Step S2: Based on the pixel coordinates of each sampling point, calculate the four neighbor boundary coordinates and quantization reference coordinates of each sampling point, and perform locality constraint verification on each sampling point to remove one or more abnormal sampling points.

[0050] In the grid sampling operator, for each sampling point, bilinear interpolation is performed on the pixel values ​​of its four neighboring areas (above, below, left, and right) centered on its pixel coordinates. Before performing bilinear interpolation, it is necessary to ensure that the pixel values ​​of the four neighboring areas are bit-aligned and can be efficiently read. In this embodiment, the boundary coordinates of the four neighboring areas and the quantization reference coordinates of each sampling point can be calculated, and locality constraint checks can be performed on each sampling point accordingly to eliminate one or more abnormal sampling points, thereby establishing an abnormal sampling point detection mechanism and ensuring that the pixel values ​​of the four neighboring areas are bit-aligned.

[0051] Specifically, the coordinates of the four neighboring boundary points of the sampling point include: the coordinates of the upper left boundary point. Coordinates of the lower left boundary point Coordinates of the top right boundary point and the coordinates of the fixed point on the lower right boundary .

[0052] in, ; Soon , Move right Move left after positioning This removes low-level bits. The base coordinate address is a multiple of the integer number of decimal places. ; .

[0053] In one embodiment, the method further includes: performing a saturation clamping operation on each boundary coordinate, i.e., performing... Operations are performed to prevent out-of-bounds access.

[0054] Subsequently, based on the coordinates of the four neighboring boundary points of the sampling point, the quantization reference coordinates of the sampling point are calculated. .in, ; .

[0055] In one embodiment, the method for performing locality constraint verification on sampling points includes the following steps.

[0056] ① Construct a theoretical reference coordinate grid .

[0057] Wherein, the theoretical reference coordinate grid The size is consistent with that of the feature map to be sampled. Its index is a standard integer index. as well as .

[0058] ② Calculate the quantization reference coordinates of the sampling points With the theoretical reference coordinates drift difference The calculation formula is:

[0059] .

[0060] ③ Determine the drift difference of the sampling points Does it exceed the preset allowable drift threshold? .

[0061] In a preferred embodiment, the allowable drift threshold However, it should be noted that the allowable drift threshold... This is used to represent the maximum number of pixels that can be deviated from the theoretical index. The specific value can be determined and adjusted according to the requirements, and this application does not specifically limit it.

[0062] ④If If the sampling point is found to have experienced an abnormal quantization jump, it will be removed as an abnormal sampling point, and a circuit breaker operation will be performed to generate an alarm log.

[0063] Under normal circumstances, index deviation caused by quantization error is generally within ±1 pixel. If the drift difference... If the value exceeds 64, it indicates a severe mismatch in quantization error or an anomaly in the input feature map to be sampled. Immediate intervention is required to stop model training or inference tasks and generate an alarm log.

[0064] In this embodiment, this application establishes a unique locality constraint verification mechanism. By performing locality constraint verification, the "tearing" or incorrect sampling of the feature map to be sampled due to extreme quantization errors can be effectively prevented. This enables the quantization inference process of the grid sampling operator to have "self-diagnosis" capability, which can promptly detect and report abnormal grid deformations, thereby improving the reliability of optical flow networks in edge games and even high-risk scenarios such as autonomous driving and medical imaging.

[0065] ⑤ Otherwise, the sampling point is taken as a reliable sampling point.

[0066] Step S3: Read the four-neighbor pixel tensors of the remaining multiple trusted sampling points, and calculate the four-neighbor pixel weight tensors of each trusted sampling point based on the sub-pixel residuals of each trusted sampling point, so as to perform bilinear interpolation operation to obtain the target pixel value of each trusted sampling point, thereby outputting the target sampling feature map for optical flow estimation.

[0067] In one embodiment, reading the four-neighbor pixel tensor of the trusted sampling point includes the following steps.

[0068] ① Based on the coordinates of the four neighboring boundary points of the reliable sampling point, perform a rounding operation to obtain the pixel index of the four neighboring points of the reliable sampling point.

[0069] Specifically, the coordinates of the upper left boundary of the reliable sampling points are determined respectively. Coordinates of the lower left boundary point Coordinates of the top right boundary point and the coordinates of the fixed point on the lower right boundary Move right The four neighboring pixel indices of the reliable sampling point are obtained by performing a floor operation. These four neighboring pixel indices include: the top-left boundary pixel index. Pixel index of the lower left boundary Top right boundary pixel index and the bottom right boundary pixel index .in, ; ; ; .

[0070] Since saturation clamping operations were performed on each boundary coordinate in the previous steps, the extracted boundary pixel indices at this time can ensure that... and Within the legal scope.

[0071] ② Expand the four-neighbor pixel index of the reliable sampling point into a four-dimensional tensor, and align the four-dimensional tensor with the dimension of the feature map to be sampled.

[0072] At this point, the shape of the four-dimensional tensor is consistent with the shape of the feature map to be sampled, which is... To support batch and channel parallel processing.

[0073] ③ Based on the four-neighbor pixel index of the reliable sampling point, perform an index retrieval operation (i.e., a Gather operation) on the feature map to be sampled to obtain the four-neighbor pixel tensor of the reliable sampling point. .

[0074] At this time, the four neighboring pixel tensor Shape .

[0075] In one embodiment, the method for calculating the four-neighbor pixel weight tensor of a reliable sampling point includes the following steps.

[0076] ① Calculate the sub-pixel residual of the reliable sampling point based on the pixel coordinates of the reliable sampling point and the coordinates of the four neighboring boundary points. The specific calculation formula is as follows:

[0077] ;

[0078] ;

[0079] in, For the sub-pixel residuals of reliable sampling points, , The residual range is ; The pixel coordinates of the reliable sampling point; The coordinates of the upper left boundary of the reliable sampling point are given.

[0080] ② Based on the sub-pixel residuals of the reliable sampling points, calculate the initial four-neighbor pixel weight tensor of the reliable sampling points, and perform bit-width compression operation to obtain the four-neighbor pixel weight tensor of the reliable sampling points.

[0081] Specifically, the four-neighbor pixel weight tensor can be represented as: .in, The top-left pixel weight component. The weight component for the bottom left pixel. The top right pixel weight component. This refers to the weight component of the bottom right pixel. The calculation formulas are as follows:

[0082] ;

[0083] ;

[0084] ;

[0085] ;

[0086] in, For displacement, . Quantize the bit width of the target; To quantize the target bit width for weights, while ensuring the required weight accuracy, It should be as low as possible. However, it should be noted that this application does not limit the target quantization bit width. The target bit width of the weight quantization and the displacement amount .

[0087] In a preferred implementation, , ,but Each pixel weight component is shifted 22 bits to the right, compressing the product result, which originally required 32 bits of storage, into a 10-bit integer. This takes into account the hardware limitations of the edge device, reduces the bit width requirement of the multiplier, significantly reduces the power consumption and latency of the edge device, improves hardware execution efficiency and speed, and at the same time maintains the relative proportional accuracy of the pixel weights and the quantization accuracy of the grid sampling operator.

[0088] The compressed low-bit four-neighbor pixel weight tensor and the read four-neighbor pixel tensor are used to perform integer fusion multiplication-addition operations, followed by normalization, to complete the bilinear interpolation operation and output a target sampling feature map for optical flow estimation. In one embodiment, the specific method includes the following steps.

[0089] ①The weight tensor of the four neighboring pixels of the reliable sampling point Align with the dimensions of the feature map to be sampled.

[0090] Specifically, firstly, the weight tensor of the four neighboring pixels is... Transform shape to Then, the weight tensor of the four neighboring pixels is... Perform channel expansion operation, i.e., execute The operation is performed to make the weight tensor of the four neighboring pixels... Shape transformation .

[0091] It should be understood that Operations are performed on the weight tensor of the four neighboring pixels. Add a dimension of size 1 to the first dimension (usually the "column dimension") to achieve shape alignment, broadcasting mechanisms, or in conjunction with other operators.

[0092] It should be noted that the four-neighbor pixel weight tensor In relation to shape The four-neighbor pixel tensor During multiplication, the weight tensor of the four neighboring pixels It will be copied along the channel dimension. Next, all channels at the same spatial location share the same set of interpolation weights, reducing the weight tensor of the four-neighbor pixel domain. The storage and computing redundancy effectively improves the hardware execution efficiency of the end-side setup.

[0093] ② Weight tensor of the four neighboring pixels of the reliable sampling point and the four neighboring pixel tensor Perform an integer weighted summation operation to obtain the interpolated pixel values ​​of the reliable sampling points.

[0094] Specifically, the integer weighted summation operation avoids any intermediate floating-point conversions, and the calculation formula is as follows:

[0095] ;

[0096] in, These are the interpolated pixel values ​​for reliable sampling points.

[0097] In a preferred embodiment, the four-neighbor pixel tensor Each pixel component , , , 8-bit, four-neighbor pixel weight tensor Each pixel weight component , , , It is then compressed to 10 bits. At this point, the product of each single term is 8 bits + 10 bits = 18 bits. After considering the carry-over from the sum of the four terms, it becomes... The maximum is approximately 18 bits + 2 bits = 20 bits.

[0098] ③ Perform a global right-shift normalization operation on the interpolated pixel values ​​of the reliable sampling points to obtain the target pixel values ​​of the reliable sampling points.

[0099] The specific calculation formula is as follows:

[0100] ;

[0101] in, The target pixel value of the reliable sampling point; The normalized displacement is a comprehensive compensation for the interpolated pixel values, used to offset the gain amplification caused by weight compression and to balance the scaling factor of the input feature map to be sampled. This is equivalent to an approximate division operation on the scaling factor, thereby achieving efficient fixed-point restoration of the target pixel values. In one embodiment, , Quantize the bit width to the target. This represents the displacement during weight compression. Quantize the target bit width for weights; preferably, , , ,but .

[0102] It should be noted that the target pixel value The value should be an integer. If the downstream network layer requires floating-point input, the target pixel value can be used instead. Convert to floating-point output, such as converting to Float32 output; otherwise, retain the target pixel value. The integer format is passed to the downstream network layer.

[0103] Repeat the calculation of the target pixel value at each reliable sampling point. This allows for the bilinear interpolation operation of the grid sampling operator to obtain the target sampling feature map.

[0104] This application performs integer scaling and pixel mapping operations on the normalized floating-point grid coordinates of the feature map to be sampled, ensuring that the entire bilinear interpolation operation is completed entirely in the integer domain. This completely eliminates floating-point operations within the grid sampling operator, significantly reducing the dependence on hardware floating-point units and lowering the power consumption of the edge device, allowing the optical flow network to be deployed on low-power edge devices. Simultaneously, this application maintains interpolation accuracy under extremely low bit-width operation conditions through high-resolution fixed-point coordinates and adaptive compressed weights. This application also introduces a locality constraint verification mechanism to improve the robustness and monitorability of the quantization inference process of the network sampling operator. In summary, the grid sampling quantization method provided in this application, which uses integer operations and bit shifting operations throughout, achieves the technical effects of improving the hardware execution efficiency and reducing the power consumption of the edge device when the optical flow network model is deployed on the edge device.

[0105] like Figure 2 The diagram illustrates the structure of a grid sampling and quantization system 200 deployed on the end side of an optical flow network according to an embodiment of this application. The grid sampling and quantization system 200 deployed on the end side of an optical flow network in this embodiment mainly includes: a grid coordinate mapping module 201, a locality constraint verification module 202, and a bilinear interpolation module 203 connected in sequence.

[0106] Specifically, the grid coordinate mapping module 201 is used to obtain the feature map to be sampled in the optical flow network and the normalized floating-point grid coordinates of the feature map to be sampled, and to perform integer scaling and pixel mapping operations on the normalized floating-point grid coordinates to obtain the pixel fixed coordinates of multiple sampling points in the feature map to be sampled.

[0107] The locality constraint verification module 202 is used to calculate the four neighbor boundary coordinates and quantization reference coordinates of each sampling point based on the pixel fixed point coordinates of each sampling point, and to perform locality constraint verification on each sampling point to remove one or more abnormal sampling points.

[0108] The bilinear interpolation module 203 is used to read the four-neighbor pixel tensors of the remaining multiple reliable sampling points, and calculate the four-neighbor pixel weight tensors of each reliable sampling point based on the sub-pixel residuals of each reliable sampling point, so as to perform bilinear interpolation operation, obtain the target pixel value of each reliable sampling point, and thus output the target sampling feature map for optical flow estimation.

[0109] It should be understood that the grid sampling quantization system deployed on the optical flow network end side and the grid sampling quantization method deployed on the optical flow network end side belong to the same inventive concept. The implementation methods of each module have been described in detail in the above method embodiments, and will not be repeated here for the sake of brevity.

[0110] It should also be understood that the module division in the embodiments of this application is illustrative and only represents a logical functional division; in actual implementation, there may be other division methods. Furthermore, the functional modules in the various embodiments of this application can be integrated into a single processor or functional module, or they can exist as separate physical entities, or they can be divided into more functional modules. The integrated modules or units described above can be implemented in hardware or as software functional modules.

[0111] The grid sampling quantization method for deployment on the optical flow network edge provided in this embodiment of the invention can be implemented on the terminal side or the server side. For the hardware structure of the grid sampling quantization terminal for deployment on the optical flow network edge, please refer to [link to relevant documentation]. Figure 3 This is a schematic diagram of an optional hardware structure of a grid sampling and quantization terminal 300 deployed on the optical flow network side according to an embodiment of the present invention. The grid sampling and quantization terminal 300 can be a mobile phone, computer device, tablet device, personal digital processing device, factory back-end processing device, etc. The grid sampling and quantization terminal 300 includes: at least one processor 301, a memory 302, at least one network interface 304, and a user interface 306. The various components in the device are coupled together through a bus system 305. It is understood that the bus system 305 is used to realize the connection and communication between these components. In addition to a data bus, the bus system 305 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 3 The general will label all buses as bus systems.

[0112] The user interface 306 may include a monitor, keyboard, mouse, trackball, clicker, button, touchpad, or touch screen.

[0113] It is understood that memory 302 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM) or programmable read-only memory (PROM), used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM) and synchronous static random access memory (SSRAM). The memories described in the embodiments of this invention are intended to include, but are not limited to, these and any other suitable categories of memory.

[0114] In this embodiment of the invention, the memory 302 is used to store various types of data to support the operation of the grid sampling quantization terminal 300 deployed on the optical flow network end side. Examples of this data include any executable program for operation on the grid sampling quantization terminal 300 deployed on the optical flow network end side, such as operating system 3021 and application program 3022; operating system 3021 includes various system programs, such as framework layer, core library layer, driver layer, etc., for implementing various basic services and handling hardware-based tasks. Application program 3022 may include various applications, such as media player, browser, etc., for implementing various application services. The implementation of the grid sampling quantization method for optical flow network end side deployment provided in this embodiment of the invention can be included in application program 3022.

[0115] The methods disclosed in the above embodiments of the present invention can be applied to or implemented by processor 301. Processor 301 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 301 or by instructions in the form of software. The processor 301 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 301 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. General-purpose processor 301 may be a microprocessor or any conventional processor, etc. The steps of the grid sampling quantization method for deployment on the optical flow network end side provided in the embodiments of the present invention can be directly reflected as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in a memory. The processor reads the information in the memory and combines it with its hardware to complete the steps of the aforementioned method.

[0116] In an exemplary embodiment, the grid sampling quantization terminal 300 deployed on the optical flow network end side can be used by one or more application specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), or complex programmable logic devices (CPLDs) to execute the aforementioned grid sampling quantization method deployed on the optical flow network end side.

[0117] According to the method provided in the embodiments of this application, this application also provides a computer program product, which includes: computer program code, which, when run on a computer, causes the computer to execute the mesh sampling quantization method for deployment on the optical flow network end side of any of the above method embodiments.

[0118] According to the method provided in the embodiments of this application, this application also provides a computer-readable storage medium storing program code, which, when run on a computer, causes the computer to execute the mesh sampling quantization method for deployment on the optical flow network end side of any of the above embodiments.

[0119] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0120] In summary, this application provides a grid sampling quantization method, system, and terminal for edge deployment of optical flow networks. By performing integer scaling and pixel mapping operations on the normalized floating-point grid coordinates of the feature map to be sampled, the entire bilinear interpolation operation is completed entirely in the integer domain, eliminating floating-point operations within the grid sampling operator, greatly reducing the dependence on hardware floating-point units, and reducing the power consumption of the edge device. At the same time, a locality constraint verification mechanism is introduced to improve the robustness and monitorability of the quantization inference process of the network sampling operator. By performing bilinear interpolation operations with high-resolution fixed-point coordinates and adaptive compression weights, the network sampling operator maintains interpolation accuracy under extremely low bit-width operation conditions, improving the hardware execution efficiency and running speed of the edge device.

[0121] Therefore, this application effectively overcomes the various shortcomings of the prior art and has high industrial application value.

[0122] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.

Claims

1. A mesh sampling quantization method for edge deployment of optical flow networks, applied to the mesh sampling operator of an optical flow network model deployed on an edge device, characterized in that, include: Obtain the feature map to be sampled in the optical flow network and the normalized floating-point grid coordinates of the feature map to be sampled, and perform integer scaling and pixel mapping operations on the normalized floating-point grid coordinates to obtain the pixel fixed coordinates of multiple sampling points in the feature map to be sampled; Based on the pixel coordinates of each sampling point, calculate the four neighbor boundary coordinates and quantization reference coordinates of each sampling point, and perform locality constraint verification on each sampling point to remove one or more abnormal sampling points. Read the four-neighbor pixel tensors of the remaining multiple trusted sampling points, and calculate the four-neighbor pixel weight tensors of each trusted sampling point based on the sub-pixel residuals of each trusted sampling point, so as to perform bilinear interpolation operation to obtain the target pixel value of each trusted sampling point, thereby outputting the target sampling feature map for optical flow estimation. Among them, the calculation method for the four-neighbor pixel weight tensor of each reliable sampling point based on the sub-pixel residual of each reliable sampling point includes: ; ; ; ; in, For the weight tensor of the four neighboring pixels of the reliable sampling point, The top-left pixel weight component. The weight component for the bottom left pixel. The top right pixel weight component. The weight component for the bottom right pixel; For the sub-pixel residuals of reliable sampling points, , , The pixel coordinates of the reliable sampling point; The coordinates of the upper left boundary of the reliable sampling point; For displacement, , Quantize the bit width for the target; Quantize the target bit width for weights; Methods for obtaining the target pixel value at each reliable sampling point by performing bilinear interpolation include: The weight tensor of the four neighboring pixels of the reliable sampling point Align with the dimensions of the feature map to be sampled; Weight tensor of four neighboring pixels of a reliable sampling point and the four neighboring pixel tensor Perform an integer-weighted summation operation to obtain the interpolated pixel values ​​of the reliable sampling points; the formula for the integer-weighted summation operation is as follows: ; Perform a global right-shift normalization operation on the interpolated pixel values ​​of the reliable sampling points to obtain the target pixel values ​​of the reliable sampling points; the calculation formula is: ; in, The target pixel value of the reliable sampling point; Interpolated pixel values ​​for reliable sampling points; For the four neighboring pixels of the reliable sampling point, The top left pixel component. The lower left pixel component. The top right pixel component. The bottom right pixel component; This is the normalized displacement.

2. The grid sampling quantization method for deployment at the end of an optical flow network according to claim 1, characterized in that, The methods for performing integer scaling and pixel mapping operations on the normalized floating-point grid coordinates include: Determine the target quantization bit width and scaling factor of the normalized floating-point grid coordinates, and perform an integer scaling operation on the normalized floating-point grid coordinates to linearly map the normalized floating-point grid coordinates to fixed-point integer grid coordinates of the target quantization bit width. A pixel mapping operation is performed on the fixed-point integer grid coordinates to map the fixed-point integer grid coordinates to the pixel space of the feature map to be sampled, thereby obtaining the pixel fixed-point coordinates of multiple sampling points in the feature map to be sampled.

3. The grid sampling quantization method for deployment at the end of an optical flow network according to claim 2, characterized in that, The linear mapping formula for linearly mapping the normalized floating-point grid coordinates to the fixed-point integer grid coordinates of the target quantization bit width is as follows: ; in, The fixed-point integer grid coordinates; The normalized floating-point grid coordinates; Quantize the bit width for the target.

4. The grid sampling quantization method for deployment at the end of an optical flow network according to claim 2, characterized in that, Based on the pixel edge alignment mode, a pixel mapping operation is performed on the fixed-point integer grid coordinates, specifically including: If the pixel edge alignment mode is True, then the fixed-point integer grid coordinates are mapped to the pixel center of the feature map to be sampled. The calculation formula for pixel space mapping is: ; ; If the pixel edge alignment mode is False, then the fixed-point integer grid coordinates are mapped to the pixel edges of the feature map to be sampled. The calculation formula for pixel space mapping is: ; ; in, The pixel coordinates of the sampling point; The integer fixed coordinates of the sampling points; Quantize the bit width of the target; The height of the feature map to be sampled. The width of the feature map to be sampled.

5. The grid sampling quantization method for deployment at the end of an optical flow network according to claim 1, characterized in that, The methods for performing local constraint verification on each sampling point separately include: Constructing a theoretical reference coordinate grid Wherein, the theoretical reference coordinate grid The size is consistent with the size of the feature map to be sampled; Calculate the quantization reference coordinates of the sampling points With the theoretical reference coordinate grid drift difference The calculation formula is: ;in, The quantization reference coordinates of the sampling points; Determine the drift difference of the sampling points Does it exceed the preset allowable drift threshold? ; like If the sampling point is found to have experienced an abnormal quantization jump, it will be removed as an abnormal sampling point, and a circuit breaker operation will be performed to generate an alarm log. Otherwise, the sampling point is considered a reliable sampling point.

6. The grid sampling quantization method for deployment at the end of an optical flow network according to claim 1, characterized in that, Methods for reading the four-neighbor pixel tensor of the remaining multiple trusted sampling points include: Based on the coordinates of the four neighboring boundary points of the reliable sampling point, perform a rounding operation to obtain the pixel index of the four neighboring points of the reliable sampling point; Expand the four-neighbor pixel index of the reliable sampling point into a four-dimensional tensor, and align the four-dimensional tensor with the dimension of the feature map to be sampled; Based on the four neighboring pixel indexes of the trusted sampling points, an index retrieval operation is performed on the feature map to be sampled to obtain the four neighboring pixel tensors of the trusted sampling points.

7. A grid sampling quantization system for deployment at the edge of an optical flow network, characterized in that, include: The grid coordinate mapping module is used to obtain the feature map to be sampled in the optical flow network and the normalized floating-point grid coordinates of the feature map to be sampled, and to perform integer scaling and pixel mapping operations on the normalized floating-point grid coordinates to obtain the pixel fixed coordinates of multiple sampling points in the feature map to be sampled. The local constraint verification module, connected to the grid coordinate mapping module, is used to calculate the four neighbor boundary coordinates and quantization reference coordinates of each sampling point based on the pixel coordinates of each sampling point, and to perform local constraint verification on each sampling point to remove one or more abnormal sampling points. The bilinear interpolation module, connected to the locality constraint verification module, is used to read the four-neighbor pixel tensors of the remaining multiple reliable sampling points, and calculate the four-neighbor pixel weight tensors of each reliable sampling point based on the sub-pixel residuals of each reliable sampling point, so as to perform bilinear interpolation operation, obtain the target pixel value of each reliable sampling point, and thus output the target sampling feature map for optical flow estimation. Among them, the calculation method for the four-neighbor pixel weight tensor of each reliable sampling point based on the sub-pixel residual of each reliable sampling point includes: ; ; ; ; in, For the weight tensor of the four neighboring pixels of the reliable sampling point, The top-left pixel weight component. The weight component for the bottom left pixel. The top right pixel weight component. The weight component for the bottom right pixel; For the sub-pixel residuals of reliable sampling points, , , The pixel coordinates of the reliable sampling point; The coordinates of the upper left boundary of the reliable sampling point; For displacement, , Quantize the bit width for the target; Quantize the target bit width for weights; Methods for obtaining the target pixel value at each reliable sampling point by performing bilinear interpolation include: The weight tensor of the four neighboring pixels of the reliable sampling point Align with the dimensions of the feature map to be sampled; Weight tensor of four neighboring pixels of a reliable sampling point and the four neighboring pixel tensor Perform an integer-weighted summation operation to obtain the interpolated pixel values ​​of the reliable sampling points; the formula for the integer-weighted summation operation is as follows: ; Perform a global right-shift normalization operation on the interpolated pixel values ​​of the reliable sampling points to obtain the target pixel values ​​of the reliable sampling points; the calculation formula is: ; in, The target pixel value of the reliable sampling point; Interpolated pixel values ​​for reliable sampling points; For the four neighboring pixels of the reliable sampling point, The top left pixel component. The lower left pixel component. The top right pixel component. The bottom right pixel component; This is the normalized displacement.

8. A grid sampling and quantization terminal for deployment on the end side of an optical flow network, characterized in that, include: Memory and processor; The memory is used to store computer programs; The processor is used to execute the computer program stored in the memory to cause the terminal to perform the mesh sampling quantization method for optical flow network end-side deployment as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Road damage detection method based on vision assistance

    CN121746899A

  • Animation video frame rate adjusting method and system based on artificial intelligence

    CN122265482A