serialize.h 1.84 KB
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
53
/*!
 *  Copyright (c) 2019 by Contributors
 * \file serialize.h
 * \brief Serialization for DGL distributed training.
 */
#ifndef DGL_GRAPH_NETWORK_SERIALIZE_H_
#define DGL_GRAPH_NETWORK_SERIALIZE_H_

#include <dgl/sampler.h>
#include <dgl/immutable_graph.h>

namespace dgl {
namespace network {

/*!
 * \brief Serialize sampled subgraph to binary data
 * \param data pointer of data buffer
 * \param csr subgraph csr
 * \param node_mapping node mapping in NodeFlowIndex
 * \param edge_mapping edge mapping in NodeFlowIndex
 * \param layer_offsets layer offsets in NodeFlowIndex
 * \param flow_offsets flow offsets in NodeFlowIndex
 * \return the total size of the serialized binary data
 */
int64_t SerializeSampledSubgraph(char* data,
                                 const ImmutableGraph::CSR::Ptr csr,
                                 const IdArray& node_mapping,
                                 const IdArray& edge_mapping,
                                 const IdArray& layer_offsets,
                                 const IdArray& flow_offsets);

/*!
 * \brief Deserialize sampled subgraph from binary data
 * \param data pointer of data buffer
 * \param csr subgraph csr
 * \param node_mapping node mapping in NodeFlowIndex
 * \param edge_mapping edge mapping in NodeFlowIndex
 * \param layer_offsets layer offsets in NodeFlowIndex
 * \param flow_offsets flow offsets in NodeFlowIndex
 */
void DeserializeSampledSubgraph(char* data,
                                ImmutableGraph::CSR::Ptr* csr,
                                IdArray* node_mapping,
                                IdArray* edge_mapping,
                                IdArray* layer_offsets,
                                IdArray* flow_offsets);

// TODO(chao): we can add compression and decompression method here

}  // namespace network
}  // namespace dgl

#endif  // DGL_GRAPH_NETWORK_SERIALIZE_H_