Add fake_quantize_op.#11359
Conversation
There was a problem hiding this comment.
Please remove the commented lines.
There was a problem hiding this comment.
the comment is for test of python , the commented lines is used for train
There was a problem hiding this comment.
Please add the error message.
There was a problem hiding this comment.
Please add the error message.
There was a problem hiding this comment.
Please add more comments for why this argument is optional. When need it and when don't need it. The same is the following.
There was a problem hiding this comment.
find_abs_max_kernel -> FindAbsMaxKernel
Please follow Google C++ code style: https://google.github.io/styleguide/cppguide.html#Function_Names
Please modify other code with the same problem.
There was a problem hiding this comment.
NUM_THREADS -> kNumTheads Please follow Goolge code style.
There was a problem hiding this comment.
Maybe can use thrust::reduce + thrust::max_element to find the maximum value for more simply.
There was a problem hiding this comment.
this will be slow
There was a problem hiding this comment.
Here can use Eigen's method:
There was a problem hiding this comment.
this cwiseMax is an elemwise max operation, i need a reduce max op .
There was a problem hiding this comment.
or
There was a problem hiding this comment.
Also can refer https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/fluid/operators/clip_op.h#L70 for more simply.
There was a problem hiding this comment.
Need comments for how to calculate scale.
There was a problem hiding this comment.
quantize_type -> scale_type for more accurate ?
There was a problem hiding this comment.
if the quantization method is non-uniform, scale is not need, so i think this should not be scale_type
There was a problem hiding this comment.
我理解quantize_type一般指: Abs-Max,或者Min-Max等不同的量化方式。
而这里,这个attr是想来标示,计算scale的方式吧?
There was a problem hiding this comment.
如果是非均匀量化, 那浮点输入和定点输出可能是个函数,或者离散数值映射,就没有scale操作了
CI没有通过,需要更新至最新develop代码。 |
The unit testing did not pass. |
qingqing01
left a comment
There was a problem hiding this comment.
Approved. @dangqingqing will refine and add more unit testing.
* Add a fake_quantize_op, which quantize an input tensor to a tensor with lower bits.
add quant code for test