"...text-generation-inference.git" did not exist on "b49dbf2d88c340c3686e4318985d8b64581364b7"
selector.h 1.24 KB
Newer Older
sangwzh's avatar
sangwzh committed
1
// !!! This is a file automatically generated by hipify!!!
2
/**
3
 *  Copyright (c) 2020 by Contributors
4
5
 * @file array/selector.h
 * @brief Selector functions to select among src/edge/dst attributes.
6
7
8
9
10
11
12
13
14
15
 */
#ifndef DGL_ARRAY_SELECTOR_H_
#define DGL_ARRAY_SELECTOR_H_

#include <dmlc/logging.h>

namespace dgl {

namespace {

sangwzh's avatar
sangwzh committed
16
17
#ifdef __HIPCC__
#define DGLDEVICE __device__ __host__
18
19
20
21
#define DGLINLINE __forceinline__
#else
#define DGLDEVICE
#define DGLINLINE inline
sangwzh's avatar
sangwzh committed
22
#endif  // __HIPCC__
23
24
25

}  // namespace

26
/**
27
28
 * @brief Select among src/edge/dst feature/idx.
 * @note the integer argument target specifies which target
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 *       to choose, 0: src, 1: edge, 2: dst.
 */
template <int target>
struct Selector {
  template <typename T>
  static DGLDEVICE DGLINLINE T Call(T src, T edge, T dst) {
    LOG(INFO) << "Target " << target << " not recognized.";
    return src;
  }
};

template <>
template <typename T>
DGLDEVICE DGLINLINE T Selector<0>::Call(T src, T edge, T dst) {
  return src;
}

template <>
template <typename T>
DGLDEVICE DGLINLINE T Selector<1>::Call(T src, T edge, T dst) {
  return edge;
}

template <>
template <typename T>
DGLDEVICE DGLINLINE T Selector<2>::Call(T src, T edge, T dst) {
  return dst;
}

}  // namespace dgl

#endif  // DGL_ARRAY_SELECTOR_H_