File tree Expand file tree Collapse file tree 1 file changed +6
-17
lines changed
mooncake-integration/store Expand file tree Collapse file tree 1 file changed +6
-17
lines changed Original file line number Diff line number Diff line change @@ -227,29 +227,18 @@ class MooncakeStorePyWrapper {
227227 py::gil_scoped_acquire acquire_gil;
228228 auto torch = torch_module ();
229229
230+ int i = 0 ;
230231 for (const auto &buffer_handle : buffer_handles) {
231- if (!buffer_handle) {
232- results_list.append (py::none ());
233- continue ;
234- }
235-
236- auto total_length = buffer_handle->size ();
237- if (total_length <= sizeof (TensorMetadata)) {
238- LOG (ERROR) << " Invalid data format: insufficient data for "
239- " metadata" ;
240- results_list.append (py::none ());
241- continue ;
242- }
243-
244- char *exported_data = new char [total_length];
245- if (!exported_data) {
246- LOG (ERROR) << " Failed to allocate memory for tensor data" ;
232+ uint64_t total_length = 0 ;
233+ auto get_result = store_->get_allocated_internal (keys[i++], total_length);
234+ if (!get_result) {
247235 results_list.append (py::none ());
248236 continue ;
249237 }
250238
251- memcpy ( exported_data, buffer_handle-> ptr (), total_length) ;
239+ auto exported_data = *get_result ;
252240
241+ // Copy metadata from buffer
253242 TensorMetadata metadata;
254243 memcpy (&metadata, exported_data, sizeof (TensorMetadata));
255244
You can’t perform that action at this time.
0 commit comments