Let me try to follow your discussion compared with our internal implementation, 
for round (of requantize), when we get the `input_scale` / `kernel_scale` / 
`output_scale`, we want to get the `shift` / `multiplier` (See: 
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/kernels/internal/quantization_util.cc#L52
 ) and pass to real `requantize` (i.e. corresponding to 
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/kernels/internal/common.h#L148)
 . 
     If we decide to do it in Python frontend like our internal implementation 
(we use Python to handle it and pass the `shift` / `multiplier` to previous 
real requantize, we should notice Python3's round is `rounds to the nearest 
"even" number`, not `round away from zero` like C++ std::round. We could 
implement it very easily:
```python
def _round_away_from_zero(value):
    abs_value = abs(value)
    result = math.floor(abs_value) + math.floor(2 * (abs_value % 1))
    return result if value >= 0 else -result
```
Maybe your discuss of round is here, right? 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/dmlc/tvm/issues/2351#issuecomment-509075561

Reply via email to