From dcb9497d7291f9d6db5308f32e86c1524695030c Mon Sep 17 00:00:00 2001 From: James Yang Date: Mon, 21 Oct 2024 15:58:56 -0700 Subject: [PATCH] Add stupid MSVC fix --- .../adelie_core/matrix/matrix_naive_convex_relu.ipp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/adelie/src/include/adelie_core/matrix/matrix_naive_convex_relu.ipp b/adelie/src/include/adelie_core/matrix/matrix_naive_convex_relu.ipp index dee4df19..7afab72e 100644 --- a/adelie/src/include/adelie_core/matrix/matrix_naive_convex_relu.ipp +++ b/adelie/src/include/adelie_core/matrix/matrix_naive_convex_relu.ipp @@ -573,16 +573,18 @@ ADELIE_CORE_MATRIX_NAIVE_CONVEX_RELU_SPARSE::sq_mul( const auto d = _mat.cols(); const auto m = _mask.cols(); Eigen::SparseMatrix mat_sq = _mat.cwiseProduct(_mat); - const auto routine = [&](int k) { + // NOTE: MSVC does not like it when we try to capture mat_sq. + // This is a bug in MSVC (god I hate microsoft so much...). + const auto routine = [&](int k, const auto& mat_sq) { out.segment(k * d, d).matrix() = ( (weights * _mask.col(k).transpose().array().template cast()).matrix() ) * mat_sq; }; if (_n_threads <= 1) { - for (int k = 0; k < m; ++k) routine(k); + for (int k = 0; k < m; ++k) routine(k, mat_sq); } else { #pragma omp parallel for schedule(static) num_threads(_n_threads) - for (int k = 0; k < m; ++k) routine(k); + for (int k = 0; k < m; ++k) routine(k, mat_sq); } out.tail(m * d) = out.head(m * d); }