[Mlir-commits] [mlir] [MLIR][TOSA-Linalg] Fix rescale lowering for unsigned input zp (PR #138313)

Georgios Pinitas llvmlistbot at llvm.org
Tue May 6 02:44:31 PDT 2025


================
@@ -1467,20 +1470,17 @@ class RescaleConverter : public OpRewritePattern<tosa::RescaleOp> {
           Value value = blockArgs[0];
           Type valueTy = value.getType();
 
-          // For now we do all of our math in 64-bit. This is not optimal but
-          // should be correct for now, consider computing correct bit depth
-          // later.
-          int32_t inBitwidth = valueTy.getIntOrFloatBitWidth() > 32 ? 48 : 32;
-
           FailureOr<int64_t> maybeIZp = op.getInputZeroPoint();
           if (failed(maybeIZp)) {
             (void)rewriter.notifyMatchFailure(
                 op, "input zero point cannot be statically determined");
             return;
           }
 
-          auto inputZp = createConstOpFromZpVal<int32_t>(
-              op, *maybeIZp, nestedBuilder.getIntegerType(inBitwidth),
+          const int32_t inBitwidth = valueTy.getIntOrFloatBitWidth();
+          const int32_t attrBitwidth = inBitwidth > 32 ? 48 : 32;
----------------
GeorgeARM wrote:

nit: Can we rename `attrBitwidth` to `inAttrBitwidth`.

https://github.com/llvm/llvm-project/pull/138313


More information about the Mlir-commits mailing list