Indeed it’s one-hot encoding. In pytorch both torch.nn.NLLLoss() and torch.nn.NLLLoss2d() do the mapping of the labels to one-hot encoding implicitly.
For instance, for an output of size (N, C, H, W) your label should be of size (N,H,W)