[Mlir-commits] [mlir] a91fb43 - [mlir][tosa] Cleanup of tosa.rescale lowering to linalg

Rob Suderman llvmlistbot at llvm.org
Mon May 17 17:32:21 PDT 2021


Author: Rob Suderman
Date: 2021-05-17T17:31:20-07:00
New Revision: a91fb4328f255298dcc17dcb982db6831a53f81a

URL: https://github.com/llvm/llvm-project/commit/a91fb4328f255298dcc17dcb982db6831a53f81a
DIFF: https://github.com/llvm/llvm-project/commit/a91fb4328f255298dcc17dcb982db6831a53f81a.diff

LOG: [mlir][tosa] Cleanup of tosa.rescale lowering to linalg

Comment was poorly written. Changed to bail on contradictory information in
the double round.

Reviewed By: NatashaKnk

Differential Revision: https://reviews.llvm.org/D102651

Added: 
    

Modified: 
    mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
    mlir/lib/Conversion/TosaToStandard/TosaToStandard.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
index a68c8bca8a74a..efcf714d0a6c9 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -1259,6 +1259,11 @@ class RescaleConverter : public OpRewritePattern<tosa::RescaleOp> {
     auto outputTy = op.output().getType().cast<ShapedType>();
     unsigned rank = inputTy.getRank();
 
+    // This is an illegal configuration. terminate and log an error
+    if (op.double_round() && !op.scale32())
+      return rewriter.notifyMatchFailure(
+          op, "tosa.rescale requires scale32 for double_round to be true");
+
     if (!outputTy.hasStaticShape())
       return rewriter.notifyMatchFailure(
           op, "tosa to linalg conversion expects statically shaped tensors");

diff  --git a/mlir/lib/Conversion/TosaToStandard/TosaToStandard.cpp b/mlir/lib/Conversion/TosaToStandard/TosaToStandard.cpp
index 668548d3dec39..579e35ab1b2fb 100644
--- a/mlir/lib/Conversion/TosaToStandard/TosaToStandard.cpp
+++ b/mlir/lib/Conversion/TosaToStandard/TosaToStandard.cpp
@@ -103,7 +103,8 @@ class ApplyScaleOpConverter : public OpRewritePattern<tosa::ApplyScaleOp> {
       Value shiftThirty64 = rewriter.create<mlir::SignExtendIOp>(
           loc, rewriter.getI64Type(), shiftThirty32);
 
-      // Round value needs to with be added or sbustracted depending on
+      // Round value needs to with be added or subtracted depending on the sign
+      // of the input value.
       Value roundAdd64 =
           rewriter.create<mlir::AddIOp>(loc, round64, shiftThirty64);
       Value roundSub64 =


        


More information about the Mlir-commits mailing list