Merge pull request #2978 from QiJune/fix_bug_EigenVector

fix bug in EigenVector::Flatten method
cblas_new
QI JUN 8 years ago committed by GitHub
commit 155f727c21

@ -65,14 +65,15 @@ template <typename T, int MajorType = Eigen::RowMajor,
typename IndexType = Eigen::DenseIndex> typename IndexType = Eigen::DenseIndex>
struct EigenVector : public EigenTensor<T, 1, MajorType, IndexType> { struct EigenVector : public EigenTensor<T, 1, MajorType, IndexType> {
// Flatten is to reshape a Tensor into a one dimension EigenVector // Flatten is to reshape a Tensor into a one dimension EigenVector
static typename EigenTensor<T, 1>::Type Flatten(Tensor& tensor) { using Parent = EigenTensor<T, 1, MajorType, IndexType>;
return EigenTensor<T, 1>::From( static typename Parent::Type Flatten(Tensor& tensor) {
tensor, make_ddim({static_cast<int>(product(tensor.dims_))})); return Parent::From(tensor,
make_ddim({static_cast<int>(product(tensor.dims_))}));
} }
static typename EigenTensor<T, 1>::ConstType Flatten(const Tensor& tensor) { static typename Parent::ConstType Flatten(const Tensor& tensor) {
return EigenTensor<T, 1>::From( return Parent::From(tensor,
tensor, make_ddim({static_cast<int>(product(tensor.dims_))})); make_ddim({static_cast<int>(product(tensor.dims_))}));
} }
}; };

Loading…
Cancel
Save