arith.h 883 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*!
 *  Copyright (c) 2019 by Contributors
 * \file array/arith.h
 * \brief Arithmetic functors
 */
#ifndef DGL_ARRAY_ARITH_H_
#define DGL_ARRAY_ARITH_H_

namespace dgl {
namespace aten {
namespace arith {

struct Add {
  template <typename T>
  inline static T Call(const T& t1, const T& t2) {
    return t1 + t2;
  }
};

struct Sub {
  template <typename T>
  inline static T Call(const T& t1, const T& t2) {
    return t1 - t2;
  }
};

struct Mul {
  template <typename T>
  inline static T Call(const T& t1, const T& t2) {
    return t1 * t2;
  }
};

struct Div {
  template <typename T>
  inline static T Call(const T& t1, const T& t2) {
    return t1 / t2;
  }
};

struct LT {
  template <typename T>
  inline static bool Call(const T& t1, const T& t2) {
    return t1 < t2;
  }
};

}  // namespace arith
}  // namespace aten
}  // namespace dgl

#endif  // DGL_ARRAY_ARITH_H_