graclus_kernel.cu 2.13 KB
Newer Older
rusty1s's avatar
rusty1s committed
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <ATen/ATen.h>

at::Tensor graclus_cuda(at::Tensor row, at::Tensor col, int64_t num_nodes) {
  auto cluster = at::full(num_nodes, -1, row.options());
  return cluster;
}

at::Tensor weighted_graclus_cuda(at::Tensor row, at::Tensor col,
                                 at::Tensor weight, int64_t num_nodes) {
  auto cluster = at::full(num_nodes, -1, row.options());
  return cluster;
}

// #include "color.cuh"
// #include "common.cuh"

// at::Tensor graclus(at::Tensor row, at::Tensor col, int num_nodes) {
//   // Remove self-loops.
//   auto mask = row != col;
//   row = row.masked_select(mask);
//   col.masked_select(mask);

//   // Sort by row index.
//   at::Tensor perm;
//   std::tie(row, perm) = row.sort();
//   col = col.index_select(0, perm);

//   // Generate helper vectors.
//   auto cluster = at::full(row.type(), {num_nodes}, -1);
//   auto prop = at::full(row.type(), {num_nodes}, -1);
//   auto deg = degree(row, num_nodes);
//   auto cum_deg = deg.cumsum(0);

//   color(cluster);

//   /* while (!color(cluster)) { */
//   /*   propose(cluster, prop, row, col, weight, deg, cum_deg); */
//   /*   response(cluster, prop, row, col, weight, deg, cum_deg); */
//   /* } */

//   return cluster;
// }

// at::Tensor weighted_graclus(at::Tensor row, at::Tensor col, at::Tensor
// weight,
//                             int num_nodes) {
//   // Remove self-loops.
//   auto mask = row != col;
//   row = row.masked_select(mask);
//   col = col.masked_select(mask);
//   weight = weight.masked_select(mask);

//   // Sort by row index.
//   at::Tensor perm;
//   std::tie(row, perm) = row.sort();
//   col = col.index_select(0, perm);
//   weight = weight.index_select(0, perm);

//   // Generate helper vectors.
//   auto cluster = at::full(row.type(), {num_nodes}, -1);
//   auto prop = at::full(row.type(), {num_nodes}, -1);
//   auto deg = degree(row, num_nodes);
//   auto cum_deg = deg.cumsum(0);

//   color(cluster);

//   /* while (!color(cluster)) { */
//   /*   weighted_propose(cluster, prop, row, col, weight, deg, cum_deg); */
//   /*   weighted_response(cluster, prop, row, col, weight, deg, cum_deg); */
//   /* } */

//   return cluster;
// }