Skip to content

Commit

Permalink
add tensor save/load in numpy format (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostplant authored Aug 3, 2022
1 parent f9ea8b3 commit bffee7c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tutel/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,14 @@ def record_time(is_cuda=None):
import torch
torch.cuda.synchronize()
return time.time()

def save(t, path):
import numpy as np
npv = t.detach().cpu().numpy()
np.save(path, npv)

def load(path, device=None):
import numpy as np
import torch
npv = np.load(path)
return torch.tensor(npv, device=device)

0 comments on commit bffee7c

Please sign in to comment.