6 #include "c10/util/Registry.h" 7 #include "caffe2/core/common.h" 8 #include "caffe2/proto/caffe2_pb.h" 14 constexpr
int kDefaultChunkSize = -1;
15 constexpr
int kNoChunking = 0;
30 using SerializationAcceptor =
31 std::function<void(const std::string& blobName, const std::string& data)>;
49 const std::string& name,
50 SerializationAcceptor acceptor) = 0;
52 virtual void SerializeWithChunkSize(
55 const std::string& name,
56 SerializationAcceptor acceptor,
59 Serialize(pointer, typeMeta, name, acceptor);
64 C10_DECLARE_TYPED_REGISTRY(
65 BlobSerializerRegistry,
69 #define REGISTER_BLOB_SERIALIZER(id, ...) \ 70 C10_REGISTER_TYPED_CLASS(BlobSerializerRegistry, id, __VA_ARGS__) 72 inline unique_ptr<BlobSerializerBase> CreateSerializer(
TypeIdentifier id) {
73 return BlobSerializerRegistry()->Create(
id);
86 virtual void Deserialize(
const BlobProto& proto,
Blob* blob) = 0;
90 #define REGISTER_BLOB_DESERIALIZER(name, ...) \ 91 C10_REGISTER_CLASS(BlobDeserializerRegistry, name, __VA_ARGS__) 93 inline unique_ptr<BlobDeserializerBase> CreateDeserializer(
const string& type) {
94 return BlobDeserializerRegistry()->Create(type);
Blob is a general container that hosts a typed pointer.
BlobDeserializerBase is an abstract class that deserializes a blob from a BlobProto or a TensorProto...
A type id is a unique id for a given C++ type.
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
BlobSerializerBase is an abstract class that serializes a blob to a string.
virtual void Serialize(const void *pointer, TypeMeta typeMeta, const std::string &name, SerializationAcceptor acceptor)=0
The virtual function that returns a serialized string for the input blob.