"examples/sampling/vscode:/vscode.git/clone" did not exist on "4b6faecb1e855c0733995db54592202b4aaf22b3"
randomwalk_cpu.cc 1.33 KB
Newer Older
1
2
3
4
5
6
7
8
9
/*!
 *  Copyright (c) 2018 by Contributors
 * \file graph/sampling/randomwalk_cpu.cc
 * \brief DGL sampler - CPU implementation of metapath-based random walk with OpenMP
 */

#include <dgl/array.h>
#include <dgl/base_heterograph.h>
#include <vector>
Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
10
#include <utility>
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "randomwalks_impl.h"
#include "randomwalks_cpu.h"
#include "metapath_randomwalk.h"

namespace dgl {

using namespace dgl::runtime;
using namespace dgl::aten;

namespace sampling {

namespace impl {

template<DLDeviceType XPU, typename IdxType>
Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
25
std::pair<IdArray, IdArray> RandomWalk(
26
27
28
29
30
31
32
33
34
35
36
37
38
    const HeteroGraphPtr hg,
    const IdArray seeds,
    const TypeArray metapath,
    const std::vector<FloatArray> &prob) {
  TerminatePredicate<IdxType> terminate =
    [] (IdxType *data, dgl_id_t curr, int64_t len) {
      return false;
    };

  return MetapathBasedRandomWalk<XPU, IdxType>(hg, seeds, metapath, prob, terminate);
}

template
Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
39
std::pair<IdArray, IdArray> RandomWalk<kDLCPU, int32_t>(
40
41
42
43
44
    const HeteroGraphPtr hg,
    const IdArray seeds,
    const TypeArray metapath,
    const std::vector<FloatArray> &prob);
template
Quan (Andy) Gan's avatar
Quan (Andy) Gan committed
45
std::pair<IdArray, IdArray> RandomWalk<kDLCPU, int64_t>(
46
47
48
49
50
51
52
53
54
55
    const HeteroGraphPtr hg,
    const IdArray seeds,
    const TypeArray metapath,
    const std::vector<FloatArray> &prob);

};  // namespace impl

};  // namespace sampling

};  // namespace dgl