If you don’t want to convert your image tensor to a PIL.Image first, you could also use this code:
f = torch.tensor([0.299, 0.587, 0.114])
x = torch.randn(64, 3, 224, 224)

result1 = 0.299 * x[:, 0] + 0.587 * x[:, 1] + 0.114 * x[:, 2]
result2 = (x * f[None, :, None, None]).sum(1)
print((result1 == result2).all())

However, I think you won’t notice a huge difference in performance:
%timeit 0.299 * x[:, 0] + 0.587 * x[:, 1] + 0.114 * x[:, 2]
7.66 ms ± 100 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

%timeit (x * f[None, :, None, None]).sum(1)
7.3 ms ± 154 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)