einsum seems like it should be the answer, but I’m finding that it’s a lot slower (~25X!) than the basic multiply and sum.
This is the code I’m using for that.
(a, b) = torch.broadcast_tensors(a, b)
return torch.einsum("...ijk, ...ijk -> ...", a, b)

I’ve filed a bug for that at https://github.com/pytorch/pytorch/issues/32591 22