diff --git a/3rdparty/mshadow/mshadow/tensor_cpu-inl.h b/3rdparty/mshadow/mshadow/tensor_cpu-inl.h index ae2636ec8141..aa71c6ca425e 100755 --- a/3rdparty/mshadow/mshadow/tensor_cpu-inl.h +++ b/3rdparty/mshadow/mshadow/tensor_cpu-inl.h @@ -503,9 +503,10 @@ template inline void AddTakeGrad(Tensor dst, const Tensor& index, const Tensor &src) { - const int K = dst.shape_[0]; + const index_t K = dst.shape_[0]; + const index_t C = dst.shape_[1]; for (index_t y = 0; y < index.size(0); ++y) { - int j = index[y]; + index_t j = index[y]; if (clip) { if (j <= 0) j = 0; else if (j >= K) j = K - 1; @@ -513,7 +514,9 @@ inline void AddTakeGrad(Tensor dst, j %= K; if (j < 0) j += K; } - dst[j] += src[y]; + for (index_t i = 0; i < C; ++i) { + dst[j][i] += src[y][i]; + } } }