I’ve got a use case of the following form:
import torch
tensor = torch.tensor([False, True, False, False, True])
indices = tensor.cummax(dim=0).indices
print(indices) # tensor([0, 1, 1, 1, 4])
in which I am relying on the fact that (at least based on my tests) cummax.indices
always gives the last occurence of a maximum. The documentation leaves it unspecified what the indices are when there are multiple maximums – i.e. that last 4
could equally well be a 1
.
Just in case this changes in future versions of PyTorch I’m adding a test to my library that this behaviour remains consistent. How worried should I be about that possibility / can it be added to the specification for cummax.indices
that it keeps this behaviour?