"vscode:/vscode.git/clone" did not exist on "695e7adcd22c25b859a6d4b3af99617aaf425708"
Unverified Commit a7be4d00 authored by Swapnil Parekh's avatar Swapnil Parekh Committed by GitHub
Browse files

[CORE] Improvement in ranks code (#4718)

parent a709e87a
...@@ -681,7 +681,9 @@ def _get_ranks(x: torch.Tensor, indices: torch.Tensor) -> torch.Tensor: ...@@ -681,7 +681,9 @@ def _get_ranks(x: torch.Tensor, indices: torch.Tensor) -> torch.Tensor:
""" """
vals = x[torch.arange(0, len(x), device=x.device, dtype=indices.dtype), vals = x[torch.arange(0, len(x), device=x.device, dtype=indices.dtype),
indices] indices]
return (x > vals[:, None]).long().sum(1).add_(1) result = (x > vals[:, None])
del vals
return result.sum(1).add_(1)
def _get_logprobs( def _get_logprobs(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment