FreeTensor
Loading...
Searching...
No Matches
make_reduction.h
Go to the documentation of this file.
1#ifndef FREE_TENSOR_MAKE_REDUCTION_H
2#define FREE_TENSOR_MAKE_REDUCTION_H
3
4#include <optional>
5#include <unordered_set>
6
7#include <func.h>
8#include <mutator.h>
9
10namespace freetensor {
11
12class MakeReduction : public Mutator {
13 const std::unordered_set<ReduceOp> &types_;
14 bool canonicalOnly_;
15
16 public:
17 MakeReduction(const std::unordered_set<ReduceOp> &types, bool canonicalOnly)
18 : types_(types), canonicalOnly_(canonicalOnly) {}
19
20 private:
21 bool isSameElem(const Store &s, const Load &l);
22
23 Stmt doMake(Store op, ASTNodeType binOp, ReduceOp reduceOp,
24 std::optional<ASTNodeType> invBinOp = std::nullopt);
25
26 protected:
27 Stmt visit(const Store &op) override;
28};
29
38inline Stmt makeReduction(const Stmt &op,
39 const std::unordered_set<ReduceOp> &types,
40 bool canonicalOnly = false) {
41 return MakeReduction(types, canonicalOnly)(op);
42}
43
44inline Stmt makeReduction(const Stmt &op) {
47}
48
50
51} // namespace freetensor
52
53#endif // FREE_TENSOR_MAKE_REDUCTION_H
Definition: make_reduction.h:12
MakeReduction(const std::unordered_set< ReduceOp > &types, bool canonicalOnly)
Definition: make_reduction.h:17
Stmt visit(const Store &op) override
Definition: make_reduction.cc:97
Definition: mutator.h:11
#define DEFINE_PASS_FOR_FUNC(pass)
Definition: func.h:88
Definition: allocator.h:9
ReduceOp
Definition: reduce_op.h:30
Stmt makeReduction(const Stmt &op, const std::unordered_set< ReduceOp > &types, bool canonicalOnly=false)
Definition: make_reduction.h:38
ASTNodeType
Definition: ast.h:20