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
zjgarvey 2024-07-29 12:24:46 -07:00 committed by GitHub
parent 30c4d2f2b8
commit 50d6ce225f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -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();