Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rely on Dask's ability to serialize collections #307

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions dask_cuda/device_host_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,14 @@ def __sizeof__(self):

@dask_serialize.register(DeviceSerialized)
def device_serialize(obj):
headers = []
all_frames = []
for part in obj.parts:
header, frames = serialize(part)
header["frame-start-stop"] = [len(all_frames), len(all_frames) + len(frames)]
headers.append(header)
all_frames.extend(frames)

headers, frames = serialize(obj.parts)
header = {"sub-headers": headers, "main-header": obj.header}

return header, all_frames
return header, frames


@dask_deserialize.register(DeviceSerialized)
def device_deserialize(header, frames):
parts = []
for sub_header in header["sub-headers"]:
start, stop = sub_header.pop("frame-start-stop")
part = deserialize(sub_header, frames[start:stop])
parts.append(part)

parts = deserialize(header["sub-headers"], frames)
return DeviceSerialized(header["main-header"], parts)


Expand Down