Skip to content

Commit

Permalink
Replace torch._utils._accumulate with numpy.cumsum. (#3364)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenZickel authored May 3, 2024
1 parent 5ba6232 commit ca36025
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions examples/contrib/mue/FactorMuE.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ def main(args):
indices = torch.randperm(sum(data_lengths), device=device).tolist()
dataset_train, dataset_test = [
torch.utils.data.Subset(dataset, indices[(offset - length) : offset])
for offset, length in zip(
torch._utils._accumulate(data_lengths), data_lengths
)
for offset, length in zip(np.cumsum(data_lengths), data_lengths)
]
else:
dataset_train = dataset
Expand Down
4 changes: 1 addition & 3 deletions examples/contrib/mue/ProfileHMM.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ def main(args):
indices = torch.randperm(sum(data_lengths), device=device).tolist()
dataset_train, dataset_test = [
torch.utils.data.Subset(dataset, indices[(offset - length) : offset])
for offset, length in zip(
torch._utils._accumulate(data_lengths), data_lengths
)
for offset, length in zip(np.cumsum(data_lengths), data_lengths)
]
else:
dataset_train = dataset
Expand Down

0 comments on commit ca36025

Please sign in to comment.