| 1145 | |
| 1146 | template <typename TL, typename TR> |
| 1147 | inline std::unique_ptr<BlockingCounter> |
| 1148 | SparseMatMul<TL, TR>::CreateSparseSlices( |
| 1149 | const typename SparseMatMul<TL, TR>::ConstMatrixMapL& mat, bool transpose, |
| 1150 | int slice_num_rows, int slice_block_size, int slice_num_cols, |
| 1151 | std::vector<std::vector<SparseSlice<TL>*>>* mat_slices, |
| 1152 | const DeviceBase::CpuWorkerThreads* thread_pool) { |
| 1153 | const int mat_num_rows = transpose ? mat.dimension(1) : mat.dimension(0); |
| 1154 | const int mat_num_cols = transpose ? mat.dimension(0) : mat.dimension(1); |
| 1155 | const int num_slices_dim0 = |
| 1156 | std::max(1, (mat_num_rows + slice_num_rows - 1) / slice_num_rows); |
| 1157 | const int num_slices_dim1 = |
| 1158 | std::max(1, (mat_num_cols + slice_num_cols - 1) / slice_num_cols); |
| 1159 | mat_slices->resize(num_slices_dim0); |
| 1160 | BlockingCounter* counter = |
| 1161 | new BlockingCounter(num_slices_dim0 * num_slices_dim1); |
| 1162 | auto work = [counter, transpose](SparseSlice<TL>* sparse_slice, |
| 1163 | SparseMatMul<TL, TR>::ConstMatrixMapL* slice, |
| 1164 | int col_offset) { |
| 1165 | if (transpose) { |
| 1166 | sparse_slice->template Initialize<true>(*slice, col_offset); |
| 1167 | } else { |
| 1168 | sparse_slice->template Initialize<false>(*slice, col_offset); |
| 1169 | } |
| 1170 | delete slice; |
| 1171 | counter->DecrementCount(); |
| 1172 | }; |
| 1173 | for (int i = 0; i < num_slices_dim0; ++i) { |
| 1174 | (*mat_slices)[i].resize(num_slices_dim1); |
| 1175 | int num_rows = |
| 1176 | std::min<int>(slice_num_rows, mat_num_rows - i * slice_num_rows); |
| 1177 | for (int j = 0; j < num_slices_dim1; ++j) { |
| 1178 | int num_cols = |
| 1179 | std::min<int>(slice_num_cols, mat_num_cols - j * slice_num_cols); |
| 1180 | SparseMatMul<TL, TR>::ConstMatrixMapL* slice = nullptr; |
| 1181 | if (transpose) { |
| 1182 | slice = new SparseMatMul<TL, TR>::ConstMatrixMapL( |
| 1183 | &mat(0, i * slice_num_rows), mat.dimensions()); |
| 1184 | } else { |
| 1185 | DSizes d(num_rows, mat_num_cols); |
| 1186 | slice = new SparseMatMul<TL, TR>::ConstMatrixMapL( |
| 1187 | &mat(i * slice_num_rows, 0), d); |
| 1188 | } |
| 1189 | auto* sparse_slice = |
| 1190 | new SparseSlice<TL>(num_rows, num_cols, slice_block_size); |
| 1191 | (*mat_slices)[i][j] = sparse_slice; |
| 1192 | thread_pool->workers->Schedule( |
| 1193 | [=]() { work(sparse_slice, slice, slice_num_cols * j); }); |
| 1194 | } |
| 1195 | } |
| 1196 | return std::unique_ptr<BlockingCounter>(counter); |
| 1197 | } |
| 1198 | #define LOAD(x) Eigen::internal::ploadu<Packet>((x)); |
| 1199 | #define INTERLEAVE(x) Eigen::internal::pinterleave4x64<Packet>(x); |
| 1200 | #define STORE(x, y) Eigen::internal::pstoreu<float>(x, y); |
nothing calls this directly
no test coverage detected