@@ -82,7 +82,7 @@ void SerializeToByteBuffer(const std::string& name, framework::Variable* var,
82
82
platform::CPUPlace cpu;
83
83
auto & gpu_dev_ctx =
84
84
static_cast <const platform::CUDADeviceContext&>(ctx);
85
- auto copy_size = tensor.memory_size ( );
85
+ auto copy_size = tensor.numel () * framework::SizeOfType (tensor. type () );
86
86
payload = memory::Alloc (cpu, copy_size);
87
87
88
88
memory::Copy (cpu, payload,
@@ -99,7 +99,7 @@ void SerializeToByteBuffer(const std::string& name, framework::Variable* var,
99
99
} else {
100
100
payload = tensor.data <void >();
101
101
}
102
- payload_size = tensor.memory_size ( );
102
+ payload_size = tensor.numel () * framework::SizeOfType (tensor. type () );
103
103
e.WriteVarlengthBeginning (VarMsg::kSerializedFieldNumber , payload_size);
104
104
} break ;
105
105
case framework::proto::VarType_Type_SELECTED_ROWS: {
@@ -118,7 +118,8 @@ void SerializeToByteBuffer(const std::string& name, framework::Variable* var,
118
118
platform::CPUPlace cpu;
119
119
auto & gpu_dev_ctx =
120
120
static_cast <const platform::CUDADeviceContext&>(ctx);
121
- auto copy_size = tensor->memory_size ();
121
+ auto copy_size =
122
+ tensor->numel () * framework::SizeOfType (tensor->type ());
122
123
payload = memory::Alloc (cpu, copy_size);
123
124
memory::Copy (cpu, payload,
124
125
boost::get<platform::CUDAPlace>(tensor->place ()),
@@ -133,7 +134,7 @@ void SerializeToByteBuffer(const std::string& name, framework::Variable* var,
133
134
} else {
134
135
payload = slr->mutable_value ()->data <void >();
135
136
}
136
- payload_size = tensor->memory_size ( );
137
+ payload_size = tensor->numel () * framework::SizeOfType (tensor-> type () );
137
138
e.WriteVarlengthBeginning (VarMsg::kSerializedFieldNumber , payload_size);
138
139
} break ;
139
140
default :
0 commit comments