add more logging messages to dimension checks of FCGradient (#9203)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/9203

Closes https://github.com/pytorch/pytorch/pull/9203

Added extra logging for FCGradient input dimension checks

Reviewed By: yinghai

Differential Revision: D8738549

fbshipit-source-id: d4f26572d86f3d44f40c9dca62d4f241ba15aead
This commit is contained in:
Hector Yuen 2018-07-09 16:41:45 -07:00 committed by Facebook Github Bot
parent c67ade26a7
commit 2b8aea3ada

View file

@ -184,8 +184,28 @@ class FullyConnectedGradientOp : public Operator<Context> {
const auto canonical_axis_w = W.canonical_axis_index(axis_w_);
const int N = TransposeWeight ? W.size_to_dim(canonical_axis_w)
: W.size_from_dim(canonical_axis_w);
CAFFE_ENFORCE(M * K == X.size());
CAFFE_ENFORCE(K * N == W.size());
auto dimErrorString = [&]() {
return MakeString(
"Dimension mismatch: ",
"X: ",
X.dims(),
", W: ",
W.dims(),
", dY: ",
dY.dims(),
", axis: ",
axis_,
", M: ",
M,
", N: ",
N,
", K: ",
K);
};
CAFFE_ENFORCE(M * K == X.size(), dimErrorString());
CAFFE_ENFORCE(K * N == W.size(), dimErrorString());
auto* dW = Output(0);
auto* db = Output(1);