From 1a25a6f9715a3c5d167df9bb76d811b2a0d0765d Mon Sep 17 00:00:00 2001 From: Jeremy Kun Date: Fri, 10 Nov 2023 07:03:54 -0800 Subject: [PATCH] implement pass to use solver solution --- lib/Transform/Noisy/ReduceNoiseOptimizer.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Transform/Noisy/ReduceNoiseOptimizer.cpp b/lib/Transform/Noisy/ReduceNoiseOptimizer.cpp index 26fe070..3591fa5 100644 --- a/lib/Transform/Noisy/ReduceNoiseOptimizer.cpp +++ b/lib/Transform/Noisy/ReduceNoiseOptimizer.cpp @@ -17,7 +17,18 @@ struct ReduceNoiseOptimizer : impl::ReduceNoiseOptimizerBase { using ReduceNoiseOptimizerBase::ReduceNoiseOptimizerBase; - void runOnOperation() { ReduceNoiseAnalysis analysis(getOperation()); } + void runOnOperation() { + // FIXME: Should have some way to mark failure + ReduceNoiseAnalysis analysis(getOperation()); + + getOperation()->walk([&](Operation *op) { + if (analysis.shouldInsertReduceNoise(op)) { + OpBuilder builder(getOperation()); + auto reduceOp = builder.create(op->getLoc(), op->getResult(0)); + op->getResult(0).replaceAllUsesWith(reduceOp.getResult()); + } + }); + } }; } // namespace noisy