John2J/SFVS / mmaudio /utils /tensor_utils.py
John2J's picture
download
raw
510 Bytes
import torch
def distribute_into_histogram(loss: torch.Tensor,
t: torch.Tensor,
num_bins: int = 25) -> tuple[torch.Tensor, torch.Tensor]:
loss = loss.detach().flatten()
t = t.detach().flatten()
t = (t * num_bins).long()
hist = torch.zeros(num_bins, device=loss.device)
count = torch.zeros(num_bins, device=loss.device)
hist.scatter_add_(0, t, loss)
count.scatter_add_(0, t, torch.ones_like(loss))
return hist, count

Xet Storage Details

Size:
510 Bytes
·
Xet hash:
bbd1d6d41e7e3a613fd83fc2c547eb350d1f4187ffb4bb8f699c957f66906203

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.