Support static dimensions (aka IndexList) in Tensor::resize(...)

This commit is contained in:
Eugene Zhulenev 2018-09-18 14:25:21 -07:00
parent 218a7b9840
commit c4627039ac

View File

@ -477,6 +477,18 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
// Nothing to do: rank 0 tensors have fixed size
}
#ifdef EIGEN_HAS_INDEX_LIST
template <typename FirstType, typename... OtherTypes>
EIGEN_DEVICE_FUNC
void resize(const Eigen::IndexList<FirstType, OtherTypes...>& dimensions) {
array<Index, NumIndices> dims;
for (int i = 0; i < NumIndices; ++i) {
dims[i] = static_cast<Index>(dimensions[i]);
}
resize(dims);
}
#endif
/** Custom Dimension */
#ifdef EIGEN_HAS_SFINAE
template<typename CustomDimension,