…and x (but not y) should be logprobs, say the doc. My apologies for missing that at first.
Best regards
Thomas
Edit: so back at the (pytorch 0.4) computer
import torch
a2 = torch.FloatTensor([0.3, 0.6, 0.1])
a1 = torch.FloatTensor([0.4, 0.5, 0.1])
c1 = torch.nn.KLDivLoss(size_average=False)(a1.log(),a2)
print(c1)

gives 2.3088, the same as explicitly computing
(a2*(a2.log()-a1.log())).sum()

Note that PyTorch erroneously averages 232 the terms by default rather than summing them.