[Mlir-commits] [mlir] [mlir][tosa] Remove Quantization Attribute (PR #125479)
Georgios Pinitas
llvmlistbot at llvm.org
Mon Feb 3 03:23:26 PST 2025
================
@@ -141,63 +141,67 @@ static Value createLinalgBodyCalculationForElementwiseOp(
}
// tosa::NegateOp
- if (isa<tosa::NegateOp>(op) && isa<FloatType>(elementTy))
- return rewriter.create<arith::NegFOp>(loc, resultTypes, args);
+ if (isa<tosa::NegateOp>(op)) {
+ if (isa<FloatType>(elementTy))
+ return rewriter.create<arith::NegFOp>(loc, resultTypes, args);
- if (isa<tosa::NegateOp>(op) && isa<IntegerType>(elementTy)) {
- int64_t inZp = 0, outZp = 0;
+ auto inputZpAttr = cast<tosa::NegateOp>(op).getInput1ZpAttr();
+ auto outputZpAttr = cast<tosa::NegateOp>(op).getOutputZpAttr();
+ int32_t inputZpVal = inputZpAttr ? inputZpAttr.getInt() : 0;
+ int32_t outputZpVal = outputZpAttr ? outputZpAttr.getInt() : 0;
- if (cast<tosa::NegateOp>(op).getQuantizationInfo()) {
- auto quantizationInfo = cast<tosa::NegateOp>(op).getQuantizationInfo();
- inZp = quantizationInfo.value().getInputZp();
- outZp = quantizationInfo.value().getOutputZp();
- }
-
- int32_t inputBitWidth = elementTy.getIntOrFloatBitWidth();
- if (!inZp && !outZp) {
+ if (isa<IntegerType>(elementTy) && inputZpVal == 0 && outputZpVal == 0) {
----------------
GeorgeARM wrote:
Above you extract zeropoint and here you check for integer type. Why not pull the extraction inside the check?
https://github.com/llvm/llvm-project/pull/125479
More information about the Mlir-commits
mailing list