elem.h 2.19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*!
 * \file tl/op/elem.h
 * \brief Define elment-wise operators.
 *
 */

#ifndef TVM_TL_OP_ELEM_H_
#define TVM_TL_OP_ELEM_H_

#include "op.h"
#include "parallel.h"

namespace tvm {
namespace tl {

using namespace tir;

class Copy : public Operator {
19
public:
20
  Copy(Array<PrimExpr> args, BufferMap vmap);
21
22
  Stmt Lower(const LowerArgs &T, arith::Analyzer *analyzer) const final;
  LayoutMap InferLayout(const LayoutInferArgs &T, InferLevel level) final;
23

24
  static const Op &Get();
25

26
27
28
29
30
31
32
33
34
35
36
37
38
  Copy(const Copy &other)
      : args_(other.args_), src(other.src), dst(other.dst),
        src_range(other.src_range), dst_range(other.dst_range),
        coalesced_width(other.coalesced_width), disable_tma(other.disable_tma) {
    // No clone nullptr
    if (other.par_op_)
      par_op_ = std::unique_ptr<ParallelOp>(
          static_cast<ParallelOp *>(other.par_op_->Clone().release()));
  }
  std::unique_ptr<Operator> Clone() const final {
    return std::make_unique<Copy>(*this);
  }

39
40
41
protected:
  Stmt LowerBulkCopy(const LowerArgs &T, arith::Analyzer *analyzer) const;
  Stmt LowerLDSMCopy(const LowerArgs &T, arith::Analyzer *analyzer) const;
42

43
  For MakeSIMTLoop(arith::Analyzer *analyzer) const;
44
45
46
47
  Array<IterVar> MakeIterVars() const;

  // ivs: itervars returned by MakeIterVars()
  // src_dst: 0 for src_indices, 1 for dst_indices
48
  Array<PrimExpr> MakeIndices(const Array<IterVar> &ivs, int src_dst) const;
49

50
  PrimExpr MakePredicate(arith::Analyzer *analyzer, const Array<IterVar> &ivs,
51
52
53
54
55
56
57
                         Array<PrimExpr> extents, int src_dst) const;

  Array<PrimExpr> args_;

  Buffer src, dst;
  Array<Range> src_range, dst_range;
  IntImm coalesced_width;
58
  Bool disable_tma = Bool(false);
59
60

  std::unique_ptr<ParallelOp> par_op_;
61
62

  int eviction_policy;
63
64
65
};

class Fill : public Operator {
66
public:
67
  Fill(Array<PrimExpr> args, BufferMap vmap);
68
69
  Stmt Lower(const LowerArgs &T, arith::Analyzer *analyzer) const final;
  static const Op &Get();
70

71
72
73
74
  std::unique_ptr<Operator> Clone() const final {
    return std::make_unique<Fill>(*this);
  }

75
76
private:
  For MakeSIMTLoop(arith::Analyzer *analyzer) const;
77
78
  tir::Buffer dst;
  PrimExpr value;
79
  Array<Range> region;
80
81
};

82
83
} // namespace tl
} // namespace tvm
84

85
#endif //  TVM_TL_OP_ELEM_H_