mirror of https://github.com/llvm/torch-mlir
[TorchToLinalg] Simplify QuantizePerTensor lowering (#3576)
Uses arith::MaximumFOp and arith::MinimumFOp instead of comparison and select ops to improve readability of IR.pull/3608/head
parent
f7b5c13870
commit
79ae0afc2f
|
@ -1461,12 +1461,8 @@ static Value createLinalgPayloadCalculationForElementwiseOp(
|
||||||
b.create<arith::ConstantOp>(loc, b.getFloatAttr(valueTy, minI));
|
b.create<arith::ConstantOp>(loc, b.getFloatAttr(valueTy, minI));
|
||||||
Value maxVal =
|
Value maxVal =
|
||||||
b.create<arith::ConstantOp>(loc, b.getFloatAttr(valueTy, maxI));
|
b.create<arith::ConstantOp>(loc, b.getFloatAttr(valueTy, maxI));
|
||||||
Value minCmp =
|
value = b.create<arith::MaximumFOp>(loc, value, minVal);
|
||||||
b.create<arith::CmpFOp>(loc, arith::CmpFPredicate::ULT, value, minVal);
|
value = b.create<arith::MinimumFOp>(loc, value, maxVal);
|
||||||
Value maxCmp =
|
|
||||||
b.create<arith::CmpFOp>(loc, arith::CmpFPredicate::UGT, value, maxVal);
|
|
||||||
value = b.create<arith::SelectOp>(loc, minCmp, minVal, value);
|
|
||||||
value = b.create<arith::SelectOp>(loc, maxCmp, maxVal, value);
|
|
||||||
|
|
||||||
if (isUnsigned) {
|
if (isUnsigned) {
|
||||||
value = b.create<arith::FPToUIOp>(loc, destTy, value);
|
value = b.create<arith::FPToUIOp>(loc, destTy, value);
|
||||||
|
|
Loading…
Reference in New Issue