Skip to content

Instantly share code, notes, and snippets.

@shink
Last active May 20, 2024 10:06
Show Gist options
  • Save shink/932e5c81a72823892bea7448ea8201fa to your computer and use it in GitHub Desktop.
Save shink/932e5c81a72823892bea7448ea8201fa to your computer and use it in GitHub Desktop.
if __name__ == '__main__':
import torch
torch.set_default_device('cuda')
t1 = torch.tensor([1, 2, 3, 3, 4, 5, 6, 7, 8], dtype=torch.float)
res1 = torch.histc(t1, 5, 7, 7)
print(res1)
t2 = torch.tensor([7], dtype=torch.float)
res2 = torch.histc(t2, 5, 7, 7)
print(res2)
t3 = torch.tensor([1, 2, 3, 3, 4, 5, 6, 7, 8], dtype=torch.float)
res3 = torch.histc(t3, 5, 0, 0)
print(res3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment