mirror of https://github.com/llvm/torch-mlir
Align Quantization Rounding Scheme with ONNX/Pytorch (#3569)
Pytorch and ONNX apparently round to nearest, ties go to nearest even, but we were using `math::round` for the torch-to-linalg conversion of `quantize_per_tensor`, which rounds away from zero on ties.pull/3572/head
parent
30c4d2f2b8
commit
50d6ce225f
|
@ -1442,7 +1442,7 @@ static Value createLinalgPayloadCalculationForElementwiseOp(
|
|||
scale = b.create<arith::TruncFOp>(loc, valueTy, scale);
|
||||
|
||||
value = b.create<arith::DivFOp>(loc, value, scale);
|
||||
value = b.create<math::RoundOp>(loc, value);
|
||||
value = b.create<math::RoundEvenOp>(loc, value);
|
||||
value = b.create<arith::AddFOp>(loc, value, zp);
|
||||
|
||||
auto destTy = payloadArgs[1].getType();
|
||||
|
|
Loading…
Reference in New Issue