[mlir][tosa] Add apply scale flags to TosaToArith creation API
authorDiego Caballero <diegocaballero@google.com>
Thu, 8 Sep 2022 20:11:37 +0000 (20:11 +0000)
committerDiego Caballero <diegocaballero@google.com>
Thu, 8 Sep 2022 20:11:47 +0000 (20:11 +0000)
TosaToArith has two flags to enable/disable 'tosa.apply_scale' ops and
to use a 64-bit/32-bit implementation for it. This patch makes the flags
available from the pass creation API.

Reviewed By: rsuderman

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

mlir/include/mlir/Conversion/TosaToArith/TosaToArith.h
mlir/lib/Conversion/TosaToArith/TosaToArithPass.cpp

index 95b815a..e7158ee 100644 (file)
@@ -22,7 +22,8 @@ namespace mlir {
 
 namespace tosa {
 
-std::unique_ptr<Pass> createTosaToArith();
+std::unique_ptr<Pass> createTosaToArith(bool includeApplyRescale = false,
+                                        bool use32BitApplyRescale = false);
 
 void populateTosaToArithConversionPatterns(RewritePatternSet *patterns);
 
index 788e284..85f7c8d 100644 (file)
@@ -31,6 +31,8 @@ using namespace tosa;
 namespace {
 struct TosaToArith : public impl::TosaToArithBase<TosaToArith> {
 public:
+  TosaToArith(TosaToArithOptions &options) : TosaToArithBase(options) {}
+
   void runOnOperation() override {
     RewritePatternSet patterns(&getContext());
     ConversionTarget target(getContext());
@@ -52,6 +54,8 @@ public:
 };
 } // namespace
 
-std::unique_ptr<Pass> mlir::tosa::createTosaToArith() {
-  return std::make_unique<TosaToArith>();
+std::unique_ptr<Pass> mlir::tosa::createTosaToArith(bool includeApplyRescale,
+                                                    bool use32BitApplyRescale) {
+  TosaToArithOptions options = {includeApplyRescale, use32BitApplyRescale};
+  return std::make_unique<TosaToArith>(options);
 }