reduce.h 895 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

/*!
 * \file tl/op/reduce.h
 * \brief Define reduce operator.
 *
 */

#ifndef TVM_TL_OP_REDUCE_H_
#define TVM_TL_OP_REDUCE_H_

#include "op.h"

namespace tvm {
namespace tl {

using namespace tir;

class ReduceOp : public Operator {
21
public:
22
  ReduceOp(Array<PrimExpr> args, BufferMap vmap);
23
24
25
  Stmt Lower(const LowerArgs &T, arith::Analyzer *analyzer) const final;
  LayoutMap InferLayout(const LayoutInferArgs &T, InferLevel level) final;
  static const Op &Get();
26

27
private:
28
29
30
31
32
33
34
35
36
37
38
  tir::Buffer src, dst;
  int dim;
  enum class ReduceType {
    kSum,
    kAbsSum,
    kMax,
    kMin,
  } type;
  bool clear;

  PrimExpr MakeInitValue() const;
39
  PrimExpr MakeReduce(const PrimExpr &a, const PrimExpr &b) const;
40
41
42
  std::string MakeCodegenReducer() const;
};

43
44
} // namespace tl
} // namespace tvm
45

46
#endif //  TVM_TL_OP_REDUCE_H_