| A templated class that implements
| SparseLengths[Sum,WeightedSum,Mean].
|
| typename T, // output type
| class InputTypes, // supported input types, such as TensorTypes
| bool USE_WEIGHT = false, // Whether it is SparseLengthsWeightedSum
| bool USE_MEAN = false, // Whether this is SparseLengthsMean
| bool USE_POSITIONAL_WEIGHT = false
| // USE_WEIGHT = true and USE_POSITIONAL_WEIGHT = true
| // -> SparseLengthsPositionalWeightedSum
| This operator applies 8Bit row-wise
| quantization to input tensor and returns
| quantized tensor.
|
| Row wise quantization of input tensor
| is the following process.
|
| We take tensor of size
|
| (m_1, m_2,…,m_n), n >= 2, reshape
| it into matrix of size
|
| (m_1, m_2 x… x m_n) and apply row-wise
| quantization.
|
| After this, we compute scale_i= (min_i
| - max_i) / 255 and bias_i = min_i for i-th
| row r_i of reshaped matrix, where min_i
| and max_i – minimum and maximum elements
| of i-th row, and quantize each element
| r_{ij} as 0 <= round(r_ij - bias_i) /
| scale_i) < 256.
|
| Instead of input tensor we obtain uint8
| tensor and auxiliary information as
| scale and bias to restore input tensor
| (with losses).
|
| Given uint8 tensor, quantized using
| 8bit row-wise quantization, and auxiliary
| scales and biases, this operator restores
| float tensor in the following way.
|
| We take input 8bits tensor of size
|
| (m_1, m_2, …, m_n), n >= 2, reshape
| it into matrix of size
|
| (m_1, m_2 x… x m_n).
|
| We compute element r_{ij} of output
| matrix as
|
| r_{ij} * s_i + b_i
|
| and after this we reshape this output
| matrix into output tensor of size
|
| (m_1, m_2, …, m_n).
|