@@ -214,90 +214,6 @@ void BindFleetExecutor(py::module* m) {
214
214
self.Run (inputs, &outputs);
215
215
return outputs;
216
216
});
217
-
218
- py::class_<DistModelDataBuf>(*m, " DistModelDataBuf" )
219
- .def (py::init<size_t >())
220
- .def (py::init ([](std::vector<float >& data) {
221
- auto buf = DistModelDataBuf (data.size () * sizeof (float ));
222
- std::memcpy (buf.data (), static_cast <void *>(data.data ()), buf.length ());
223
- return buf;
224
- }))
225
- .def (py::init (&DistModelDataBufCreate<int32_t >))
226
- .def (py::init (&DistModelDataBufCreate<int64_t >))
227
- .def (py::init (&DistModelDataBufCreate<float >))
228
- .def (py::init (&DistModelDataBufCreate<phi::dtype::float16>))
229
- .def (" reset" ,
230
- [](DistModelDataBuf& self, std::vector<float >& data) {
231
- self.Resize (data.size () * sizeof (float ));
232
- std::memcpy (self.data (), data.data (), self.length ());
233
- })
234
- .def (" reset" , &DistModelDataBufReset<int32_t >)
235
- .def (" reset" , &DistModelDataBufReset<int64_t >)
236
- .def (" reset" , &DistModelDataBufReset<float >)
237
- .def (" reset" , &DistModelDataBufReset<phi::dtype::float16>)
238
- .def (" length" , &DistModelDataBuf::length)
239
- .def (
240
- " tolist" ,
241
- [](DistModelDataBuf& self, const std::string& dtype) -> py::list {
242
- py::list l;
243
- if (dtype == " int32" ) {
244
- auto * data = static_cast <int32_t *>(self.data ());
245
- auto size = self.length () / sizeof (int32_t );
246
- l = py::cast (std::vector<int32_t >(data, data + size));
247
- } else if (dtype == " int64" ) {
248
- auto * data = static_cast <int64_t *>(self.data ());
249
- auto size = self.length () / sizeof (int64_t );
250
- l = py::cast (std::vector<int64_t >(data, data + size));
251
- } else if (dtype == " float32" ) {
252
- auto * data = static_cast <float *>(self.data ());
253
- auto size = self.length () / sizeof (float );
254
- l = py::cast (std::vector<float >(data, data + size));
255
- } else if (dtype == " float16" ) {
256
- auto * data = static_cast <phi::dtype::float16*>(self.data ());
257
- auto size = self.length () / sizeof (phi::dtype::float16);
258
- l = py::cast (std::vector<phi::dtype::float16>(data, data + size));
259
- } else {
260
- PADDLE_THROW (common::errors::Unimplemented (
261
- " Unsupported data type. Now only supports INT32, INT64, "
262
- " FLOAT16 and FLOAT32." ));
263
- }
264
- return l;
265
- });
266
-
267
- py::class_<DistModelTensor>(*m, " DistModelTensor" )
268
- .def (py::init<>())
269
- .def (py::init (&DistModelTensorCreate<int32_t >),
270
- py::arg (" data" ),
271
- py::arg (" name" ) = " " ,
272
- py::arg (" lod" ) = std::vector<std::vector<size_t >>(),
273
- py::arg (" copy" ) = true )
274
- .def (py::init (&DistModelTensorCreate<int64_t >),
275
- py::arg (" data" ),
276
- py::arg (" name" ) = " " ,
277
- py::arg (" lod" ) = std::vector<std::vector<size_t >>(),
278
- py::arg (" copy" ) = true )
279
- .def (py::init (&DistModelTensorCreate<float >),
280
- py::arg (" data" ),
281
- py::arg (" name" ) = " " ,
282
- py::arg (" lod" ) = std::vector<std::vector<size_t >>(),
283
- py::arg (" copy" ) = true )
284
- .def (py::init (&DistModelTensorCreate<phi::dtype::float16>),
285
- py::arg (" data" ),
286
- py::arg (" name" ) = " " ,
287
- py::arg (" lod" ) = std::vector<std::vector<size_t >>(),
288
- py::arg (" copy" ) = true )
289
- .def_readwrite (" name" , &DistModelTensor::name)
290
- .def_readwrite (" shape" , &DistModelTensor::shape)
291
- .def_readwrite (" data" , &DistModelTensor::data)
292
- .def_readwrite (" dtype" , &DistModelTensor::dtype)
293
- .def_readwrite (" lod" , &DistModelTensor::lod)
294
- .def (" as_ndarray" , &DistModelTensorGetData);
295
-
296
- py::enum_<DistModelDataType>(*m, " DistModelDataType" )
297
- .value (" FLOAT32" , DistModelDataType::FLOAT32)
298
- .value (" INT64" , DistModelDataType::INT64)
299
- .value (" INT32" , DistModelDataType::INT32)
300
- .value (" FLOAT16" , DistModelDataType::FLOAT16);
301
217
}
302
218
} // namespace pybind
303
219
} // namespace paddle
0 commit comments