From pytorch’s project in github, I can find MSELossImpl::forward() in torch/csrc/api/src/nn/modules/loss.cpp.
This function calls F::detail::mse_loss(input, target, options.reduction());, it’s in torch/csrc/api/include/torch/nn/functional/loss.h.
Again F::detail::mse_loss magically calls:
return torch::mse_loss(
expanded_input,
expanded_target,
enumtype::reduction_get_enum(reduction));
However I can’t find defination of torch::mse_loss().
torch/csrc/api/include/torch/nn/functional/loss.h includes 3 files:
#include <ATen/ExpandUtils.h>
#include <torch/nn/functional/activation.h>
#include <torch/nn/options/loss.h>