serialize picklable python object to tensor
(pyobj, device="cuda")
| 39 | |
| 40 | |
| 41 | def pyobj2tensor(pyobj, device="cuda"): |
| 42 | """serialize picklable python object to tensor""" |
| 43 | storage = torch.ByteStorage.from_buffer(pickle.dumps(pyobj)) |
| 44 | return torch.ByteTensor(storage).to(device=device) |
| 45 | |
| 46 | |
| 47 | def tensor2pyobj(tensor): |