python_binding.cc 1.65 KB
Newer Older
1
2
3
4
5
6
7
/**
 *  Copyright (c) 2023 by Contributors
 * @file python_binding.cc
 * @brief Graph bolt library Python binding.
 */

#include <graphbolt/csc_sampling_graph.h>
8
#include <graphbolt/serialize.h>
9
10
11
12
13

namespace graphbolt {
namespace sampling {

TORCH_LIBRARY(graphbolt, m) {
14
15
16
17
18
19
20
21
22
23
  m.class_<SampledSubgraph>("SampledSubgraph")
      .def(torch::init<>())
      .def_readwrite("indptr", &SampledSubgraph::indptr)
      .def_readwrite("indices", &SampledSubgraph::indices)
      .def_readwrite(
          "reverse_row_node_ids", &SampledSubgraph::reverse_row_node_ids)
      .def_readwrite(
          "reverse_column_node_ids", &SampledSubgraph::reverse_column_node_ids)
      .def_readwrite("reverse_edge_ids", &SampledSubgraph::reverse_edge_ids)
      .def_readwrite("type_per_edge", &SampledSubgraph::type_per_edge);
24
25
26
27
28
29
  m.class_<CSCSamplingGraph>("CSCSamplingGraph")
      .def("num_nodes", &CSCSamplingGraph::NumNodes)
      .def("num_edges", &CSCSamplingGraph::NumEdges)
      .def("csc_indptr", &CSCSamplingGraph::CSCIndptr)
      .def("indices", &CSCSamplingGraph::Indices)
      .def("node_type_offset", &CSCSamplingGraph::NodeTypeOffset)
30
      .def("type_per_edge", &CSCSamplingGraph::TypePerEdge)
31
      .def("in_subgraph", &CSCSamplingGraph::InSubgraph)
32
      .def("sample_neighbors", &CSCSamplingGraph::SampleNeighbors)
33
      .def("copy_to_shared_memory", &CSCSamplingGraph::CopyToSharedMemory);
34
  m.def("from_csc", &CSCSamplingGraph::FromCSC);
35
36
  m.def("load_csc_sampling_graph", &LoadCSCSamplingGraph);
  m.def("save_csc_sampling_graph", &SaveCSCSamplingGraph);
37
  m.def("load_from_shared_memory", &CSCSamplingGraph::LoadFromSharedMemory);
38
39
40
41
}

}  // namespace sampling
}  // namespace graphbolt