serialize.cc 801 Bytes
Newer Older
1
2
3
4
5
6
7
/**
 *  Copyright (c) 2023 by Contributors
 * @file graphbolt/src/serialize.cc
 * @brief Source file of serialize.
 */

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

namespace torch {

serialize::InputArchive& operator>>(
    serialize::InputArchive& archive,
14
    graphbolt::sampling::FusedCSCSamplingGraph& graph) {
15
16
17
18
19
20
  graph.Load(archive);
  return archive;
}

serialize::OutputArchive& operator<<(
    serialize::OutputArchive& archive,
21
    const graphbolt::sampling::FusedCSCSamplingGraph& graph) {
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  graph.Save(archive);
  return archive;
}

}  // namespace torch

namespace graphbolt {

torch::IValue read_from_archive(
    torch::serialize::InputArchive& archive, const std::string& key) {
  torch::IValue data;
  archive.read(key, data);
  return data;
}

}  // namespace graphbolt