Systems and methods for floating point to quantized grid sampling
A method and system for quantized grid sampling of a tensor on customized digital hardware. The method and system receive a floating-point input tensor having one or more of tensor dimensions and a grid point that are performed in as quantized values. The quantized values generation and processing can be performed using digital hardware performing quantized operation including digital shifts and quantized multiplication and additions. For each of the one or more of tensor dimensions adjacent to the grid point a quantized-floor-index is determined. A domain shifted floor index is determined for each quantized-floor-index. Weights are determined for each quantized-floor-index. Data values of the tensor points adjacent to the grid point are accessed and a weighted sum grid sample point is generated.
1 . A method for quantized grid sampling a tensor on customized digital hardware comprising:
receiving a floating-point input tensor having one or more of tensor dimensions;
receiving a grid point;
determining a quantized-floor-index for each of the one or more of tensor dimensions adjacent to the grid point by RequantizeRightShift (floating-point grid point, K) by a precision number K for each dimension of the grid point, thereby generating the quantized-floor-index for each of the one or more of the tensor dimensions;
determining a domain shifted floor index for each quantized-floor-index by LeftShift (the floating-point grid point, K);
determining a quantized scaled first weight for each the quantized-floor-index by a Mask (LeftShift (floating-point grid point, K)—the domain shifted floor index, K);
determining a quantized scaled second weight for each quantized-floor-index by subtracting the associated quantized scaled first weight from 2{circumflex over ( )}K;
retrieving one or more floor data values corresponding to the quantized-floor-index for each of the one or more of the tensor dimensions;
retrieving one or more floor plus one data values corresponding to the quantized-floor-index plus one for each of the one or more of the tensor dimensions; and
determining a quantized GridSample of the floating-point grid point by generating a weighted sum utilizing the retrieved one or more floor and floor plus 1 data values and the quantized scaled first weight and the quantized scaled second weight.
2 . The method of claim 1 , wherein the generating of the weighted sum is performed by a digital multiply and add circuit.
3 . The method of claim 1 , wherein K is less than eight.
4 . The method of claim 1 , wherein the quantized-floor-index for each of the one or more of the tensor dimensions adjacent to the grid point is generated by a hardware shift register.
5 . The method of claim 1 , wherein the LeftShift(floating-point grid point, K) is generated by a hardware shift register.
6 . The method of claim 1 , wherein the RequantizeRightShift( ) function is generated by a hardware shift register.
7 . The method of claim 1 , wherein the generating of the weighted sum is performed by a digital multiply and add circuit, the LeftShift (floating-point grid point, K) is generated by a hardware shift register, and the RequantizeRightShift () function is generated by a hardware shift register.
8 . A system for quantized grid sampling a tensor on customized digital hardware comprising:
a sequencer;
one or more shift registers;
one or more digital adders and multipliers;
one or more digital masks;
wherein the sequencer is configured to receive a floating-point input tensor having one or more of tensor dimensions;
wherein the sequencer is configured to receive a grid point;
wherein the sequencer and the one or more shift registers generate a quantized-floor-index for each of the one or more of the tensor dimensions adjacent to the grid point by right shifting the grid point by K bits;
wherein the sequencer and the one or more shift registers determines a domain shifted floor index for each quantized-floor-index by one or more shift registers by left shifting the grid point by K bits;
wherein the sequencer and the one or more shift registers determines a quantized scaled first weight for each quantized-floor-index, by a Mask (LeftShift(grid point, K)-domain shifted floor index, K);
wherein the sequencer and the one or more shift register determines a quantized scaled second weight for each quantized-floor-index by subtracting the associated quantized scaled first weight from 2{circumflex over ( )}K;
wherein the sequencer and the one or more shift registers retrieves one or more floor data values corresponding to the quantized-floor-index for each of the one or more of the tensor dimensions;
wherein the sequencer and the one or more shift registers retrieves one or more ceiling data values corresponding to the quantized-floor-index plus one for each of the one or more of the tensor dimensions; and
wherein the sewuencer and the one or more shift registers determines a quantized GridSample of the floating-point grid point by generating a weighted sum of the quantized scaled first weight and the quantized scaled second weight for each quantized-floor-index.
9 . The system of claim 8 , wherein the generating of the weighted sum is performed by a digital multiply and add circuit.
10 . The system of claim 8 , wherein K is less than eight.
11 . The system of claim 8 , wherein the quantized-floor-index for each of the one or more of the tensor dimensions adjacent to the grid point is generated by a hardware shift register.
12 . The system of claim 8 , wherein the LeftShift (grid point, K) is generated by a hardware shift register.
13 . The system of claim 8 , wherein a RequantizeRightShift( ) function is generated by a hardware shift register.
14 . The system of claim 8 , wherein the generating weighted sum is performed by a digital multiply and add circuit, the LeftShift(grid point, K) is generated by a hardware shift register, and a RequantizeRightShift( ) function is generated by a hardware shift register.