79196327

Date: 2024-11-17 00:45:18
Score: 2
Natty:
Report link

Tensors have a "put_" method taking 2 arguments:

  1. A Long tensor of indices
  2. A tensor of values

i.e.

t.put_(torch.tensor(list(mapping.keys()),dtype=torch.long),torch.tensor(list(mapping.values())))

speedup of about 10-15x over manual indexing. Graph of speedup

Reasons:
  • Low length (0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: steinshark