Caffe2 - C++ API
A deep learning, cross platform ML framework
blob_serializer_base.h
1 #pragma once
2 
3 #include <string>
4 #include <functional>
5 
6 namespace caffe2 {
7 
8 class Blob;
9 
10 constexpr int kDefaultChunkSize = -1;
11 constexpr int kNoChunking = 0;
12 
24  public:
25  virtual ~BlobSerializerBase() {}
26  using SerializationAcceptor =
27  std::function<void(const std::string& blobName, const std::string& data)>;
42  virtual void Serialize(const Blob& blob, const std::string& name,
43  SerializationAcceptor acceptor) = 0;
44 
45  virtual void SerializeWithChunkSize(
46  const Blob& blob,
47  const std::string& name,
48  SerializationAcceptor acceptor,
49  int chunk_size) {
50  // Base implementation.
51  Serialize(blob, name, acceptor);
52  }
53 };
54 
55 } // namespace caffe2
virtual void Serialize(const Blob &blob, const std::string &name, SerializationAcceptor acceptor)=0
The virtual function that returns a serialized string for the input blob.
Simple registry implementation in Caffe2 that uses static variables to register object creators durin...
Blob is a general container that hosts a typed pointer.
Definition: blob.h:25
BlobSerializerBase is an abstract class that serializes a blob to a string.