@@ -109,13 +109,12 @@ void SerializeLodTensor(framework::Variable* var,
109109 iobuf->append (reinterpret_cast <const char *>(tensor->data ()), data_len);
110110 } else {
111111#ifdef PADDLE_WITH_CUDA
112- char * temp_ptr =
113- new char [tensor-> numel () * framework::SizeOfType (tensor->type ())];
112+ char * temp_ptr = new char [tensor-> numel () *
113+ framework::SizeOfType (tensor->type ())]; // NOLINT
114114 auto stream =
115115 reinterpret_cast <const platform::CUDADeviceContext&>(ctx).stream ();
116116 memory::Copy (
117- platform::CPUPlace (), temp_ptr,
118- BOOST_GET_CONST (platform::CUDAPlace, tensor->place ()), tensor->data (),
117+ platform::CPUPlace (), temp_ptr, tensor->place (), tensor->data (),
119118 tensor->numel () * framework::SizeOfType (tensor->type ()), stream);
120119 auto data_len = tensor->numel () * framework::SizeOfType (tensor->type ());
121120 iobuf->append (reinterpret_cast <const char *>(&data_len), 8 );
@@ -151,13 +150,12 @@ void SerializeSelectedRows(framework::Variable* var,
151150 iobuf->append (reinterpret_cast <const char *>(tensor->data ()), data_len);
152151 } else {
153152#ifdef PADDLE_WITH_CUDA
154- char * temp_ptr =
155- new char [tensor-> numel () * framework::SizeOfType (tensor->type ())];
153+ char * temp_ptr = new char [tensor-> numel () *
154+ framework::SizeOfType (tensor->type ())]; // NOLINT
156155 auto stream =
157156 reinterpret_cast <const platform::CUDADeviceContext&>(ctx).stream ();
158157 memory::Copy (
159- platform::CPUPlace (), temp_ptr,
160- BOOST_GET_CONST (platform::CUDAPlace, tensor->place ()), tensor->data (),
158+ platform::CPUPlace (), temp_ptr, tensor->place (), tensor->data (),
161159 tensor->numel () * framework::SizeOfType (tensor->type ()), stream);
162160 auto data_len = tensor->numel () * framework::SizeOfType (tensor->type ());
163161 iobuf->append (reinterpret_cast <const char *>(&data_len), 8 );
@@ -207,7 +205,7 @@ void DeserializeFromMultiVarMsgAndIOBuf(const MultiVarMsg& multi_msg,
207205}
208206
209207void DeserializeLodTensor (framework::Variable* var, const VarMsg& msg,
210- butil::IOBufBytesIterator& io_buffer_itr,
208+ butil::IOBufBytesIterator& io_buffer_itr, // NOLINT
211209 const platform::DeviceContext& ctx) {
212210 const auto place = ctx.GetPlace ();
213211 framework::LoDTensor* tensor = var->GetMutable <framework::LoDTensor>();
@@ -232,30 +230,30 @@ void DeserializeLodTensor(framework::Variable* var, const VarMsg& msg,
232230
233231 // IO Buffer
234232 if (platform::is_cpu_place (place)) {
235- unsigned long data_len;
236- io_buffer_itr.copy_and_forward ((void *)(&data_len), 8 );
233+ unsigned long data_len; // NOLINT
234+ io_buffer_itr.copy_and_forward ((void *)(&data_len), 8 ); // NOLINT
237235 io_buffer_itr.copy_and_forward (tensor_data, data_len);
238236 } else if (platform::is_gpu_place (place)) {
239237#ifdef PADDLE_WITH_CUDA
240- unsigned long data_len;
241- char * temp_ptr =
242- new char [tensor-> numel () * framework::SizeOfType (tensor->type ())];
243- io_buffer_itr.copy_and_forward ((void *)(&data_len), 8 );
244- io_buffer_itr.copy_and_forward ((void *)temp_ptr, data_len);
238+ unsigned long data_len; // NOLINT
239+ char * temp_ptr = new char [tensor-> numel () *
240+ framework::SizeOfType (tensor->type ())]; // NOLINT
241+ io_buffer_itr.copy_and_forward ((void *)(&data_len), 8 ); // NOLINT
242+ io_buffer_itr.copy_and_forward ((void *)temp_ptr, data_len); // NOLINT
245243 auto stream =
246244 reinterpret_cast <const platform::CUDADeviceContext&>(ctx).stream ();
247- memory::Copy (BOOST_GET_CONST (platform::CUDAPlace, place), tensor_data,
248- platform::CPUPlace (), (void *)temp_ptr,
249- tensor->numel () * framework::SizeOfType (tensor->type ()),
250- stream);
245+ memory::Copy (
246+ place, tensor_data, platform::CPUPlace (), (void *)temp_ptr, // NOLINT
247+ tensor->numel () * framework::SizeOfType (tensor->type ()), stream);
251248 delete[] temp_ptr;
252249#endif
253250 }
254251}
255252
256- void DeserializeSelectedRows (framework::Variable* var, const VarMsg& msg,
257- butil::IOBufBytesIterator& io_buffer_itr,
258- const platform::DeviceContext& ctx) {
253+ void DeserializeSelectedRows (
254+ framework::Variable* var, const VarMsg& msg,
255+ butil::IOBufBytesIterator& io_buffer_itr, // NOLINT
256+ const platform::DeviceContext& ctx) {
259257 const auto place = ctx.GetPlace ();
260258 auto * slr = var->GetMutable <framework::SelectedRows>();
261259 framework::Tensor* tensor = slr->mutable_value ();
@@ -272,20 +270,19 @@ void DeserializeSelectedRows(framework::Variable* var, const VarMsg& msg,
272270 tensor->mutable_data (place, VarMessageToVarType (msg.data_type ()));
273271 // IO Buffer
274272 if (platform::is_cpu_place (place)) {
275- unsigned long data_len;
276- io_buffer_itr.copy_and_forward ((void *)(&data_len), 8 );
273+ unsigned long data_len; // NOLINT
274+ io_buffer_itr.copy_and_forward ((void *)(&data_len), 8 ); // NOLINT
277275 io_buffer_itr.copy_and_forward (tensor_data, data_len);
278276 } else if (platform::is_gpu_place (place)) {
279277#ifdef PADDLE_WITH_CUDA
280- char * temp_ptr =
281- new char [tensor-> numel () * framework::SizeOfType (tensor->type ())];
282- unsigned long data_len;
283- io_buffer_itr.copy_and_forward ((void *)(&data_len), 8 );
278+ char * temp_ptr = new char [tensor-> numel () *
279+ framework::SizeOfType (tensor->type ())]; // NOLINT
280+ unsigned long data_len; // NOLINT
281+ io_buffer_itr.copy_and_forward ((void *)(&data_len), 8 ); // NOLINT
284282 io_buffer_itr.copy_and_forward (temp_ptr, data_len);
285283 auto stream =
286284 reinterpret_cast <const platform::CUDADeviceContext&>(ctx).stream ();
287- memory::Copy (BOOST_GET_CONST (platform::CUDAPlace, place), tensor_data,
288- platform::CPUPlace (), temp_ptr,
285+ memory::Copy (place, tensor_data, platform::CPUPlace (), temp_ptr,
289286 tensor->numel () * framework::SizeOfType (tensor->type ()),
290287 stream);
291288 delete[] temp_ptr;
0 commit comments