-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSerialize.hpp
53 lines (30 loc) · 981 Bytes
/
Serialize.hpp
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
#include "tensor.h"
#include "proto/kurff.pb.h"
#include <string>
#include <google/protobuf/repeated_field.h>
namespace kurff{
class Serialize{
typedef google::protobuf::RepeatedField<float> Field;
public:
Serialize(){
}
~Serialize(){
}
template<typename T, class SrcContext, class DstContext>
void serialize(T* t, Field* field, std::string name){
int size = t->size();
field->Reserve(size);
for(int i = 0; i < size; ++ i){
field->Add(0);
}
//CHECK_EQ(t->meta().name(),"f");
//LOG(INFO)<<t->meta().name();
const float* src = t->template data<float>();
float* dst = field->mutable_data();
SrcContext context;
context.template Copy<float,SrcContext,DstContext>(size, src, dst);
//LOG(INFO)<<field->SerializeAsString();
}
protected:
};
}