Skip to content

Commit

Permalink
add template for ReduceNoiseAnalysis
Browse files Browse the repository at this point in the history
  • Loading branch information
j2kun committed Nov 9, 2023
1 parent 00d2853 commit 8401317
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Analysis/ReduceNoiseAnalysis/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cc_library(
name = "ReduceNoiseAnalysis",
srcs = ["ReduceNoiseAnalysis.cpp"],
hdrs = ["ReduceNoiseAnalysis.h"],
deps = [
"//lib/Dialect/Noisy",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
],
)
18 changes: 18 additions & 0 deletions lib/Analysis/ReduceNoiseAnalysis/ReduceNoiseAnalysis.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "lib/Analysis/ReduceNoiseAnalysis/ReduceNoiseAnalysis.h"

#include <string>

#include "llvm/include/llvm/ADT/DenseMap.h" // from @llvm-project
#include "llvm/include/llvm/ADT/TypeSwitch.h" // from @llvm-project
#include "mlir/include/mlir/IR/Operation.h" // from @llvm-project
#include "mlir/include/mlir/IR/Value.h" // from @llvm-project

namespace mlir {
namespace tutorial {

ReduceNoiseAnalysis::ReduceNoiseAnalysis(Operation *op) {
// Implement analysis here
}

} // namespace tutorial
} // namespace mlir
29 changes: 29 additions & 0 deletions lib/Analysis/ReduceNoiseAnalysis/ReduceNoiseAnalysis.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef LIB_ANALYSIS_REDUCENOISEANALYSIS_REDUCENOISEANALYSIS_H_
#define LIB_ANALYSIS_REDUCENOISEANALYSIS_REDUCENOISEANALYSIS_H_

#include "llvm/include/llvm/ADT/DenseMap.h" // from @llvm-project
#include "mlir/include/mlir/IR/Operation.h" // from @llvm-project
#include "mlir/include/mlir/IR/Value.h" // from @llvm-project

namespace mlir {
namespace tutorial {

class ReduceNoiseAnalysis {
public:
ReduceNoiseAnalysis(Operation *op);
~ReduceNoiseAnalysis() = default;

/// Return true if a reduce_noise op should be inserted after the given
/// operation, according to the solution to the optimization problem.
bool shouldInsertReduceNoise(Operation *op) const {
return solution.lookup(op);
}

private:
llvm::DenseMap<Operation *, bool> solution;
};

} // namespace tutorial
} // namespace mlir

#endif // LIB_ANALYSIS_REDUCENOISEANALYSIS_REDUCENOISEANALYSIS_H_

0 comments on commit 8401317

Please sign in to comment.