From: Diego Caballero Date: Thu, 8 Sep 2022 20:11:37 +0000 (+0000) Subject: [mlir][tosa] Add apply scale flags to TosaToArith creation API X-Git-Tag: upstream/17.0.6~34025 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9cfb6f7e082b57d8a1c5fc577dd357da60238db;p=platform%2Fupstream%2Fllvm.git [mlir][tosa] Add apply scale flags to TosaToArith creation API 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 --- diff --git a/mlir/include/mlir/Conversion/TosaToArith/TosaToArith.h b/mlir/include/mlir/Conversion/TosaToArith/TosaToArith.h index 95b815a..e7158ee 100644 --- a/mlir/include/mlir/Conversion/TosaToArith/TosaToArith.h +++ b/mlir/include/mlir/Conversion/TosaToArith/TosaToArith.h @@ -22,7 +22,8 @@ namespace mlir { namespace tosa { -std::unique_ptr createTosaToArith(); +std::unique_ptr createTosaToArith(bool includeApplyRescale = false, + bool use32BitApplyRescale = false); void populateTosaToArithConversionPatterns(RewritePatternSet *patterns); diff --git a/mlir/lib/Conversion/TosaToArith/TosaToArithPass.cpp b/mlir/lib/Conversion/TosaToArith/TosaToArithPass.cpp index 788e284..85f7c8d 100644 --- a/mlir/lib/Conversion/TosaToArith/TosaToArithPass.cpp +++ b/mlir/lib/Conversion/TosaToArith/TosaToArithPass.cpp @@ -31,6 +31,8 @@ using namespace tosa; namespace { struct TosaToArith : public impl::TosaToArithBase { public: + TosaToArith(TosaToArithOptions &options) : TosaToArithBase(options) {} + void runOnOperation() override { RewritePatternSet patterns(&getContext()); ConversionTarget target(getContext()); @@ -52,6 +54,8 @@ public: }; } // namespace -std::unique_ptr mlir::tosa::createTosaToArith() { - return std::make_unique(); +std::unique_ptr mlir::tosa::createTosaToArith(bool includeApplyRescale, + bool use32BitApplyRescale) { + TosaToArithOptions options = {includeApplyRescale, use32BitApplyRescale}; + return std::make_unique(options); }