mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-29 15:24:51 +08:00
Marked the tensor constructors as EIGEN_DEVICE_FUNC: This makes it possible to call them from a CUDA kernel.
This commit is contained in:
parent
140f3a02a8
commit
75e19fc7ca
@ -340,34 +340,34 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
|||||||
|
|
||||||
#ifdef EIGEN_HAS_VARIADIC_TEMPLATES
|
#ifdef EIGEN_HAS_VARIADIC_TEMPLATES
|
||||||
template<typename... IndexTypes>
|
template<typename... IndexTypes>
|
||||||
inline Tensor(Index firstDimension, IndexTypes... otherDimensions)
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor(Index firstDimension, IndexTypes... otherDimensions)
|
||||||
: m_storage(internal::array_prod(array<Index, NumIndices>{{firstDimension, otherDimensions...}}), array<Index, NumIndices>{{firstDimension, otherDimensions...}})
|
: m_storage(internal::array_prod(array<Index, NumIndices>{{firstDimension, otherDimensions...}}), array<Index, NumIndices>{{firstDimension, otherDimensions...}})
|
||||||
{
|
{
|
||||||
// The number of dimensions used to construct a tensor must be equal to the rank of the tensor.
|
// The number of dimensions used to construct a tensor must be equal to the rank of the tensor.
|
||||||
EIGEN_STATIC_ASSERT(sizeof...(otherDimensions) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
EIGEN_STATIC_ASSERT(sizeof...(otherDimensions) + 1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
inline explicit Tensor(Index dim1)
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Tensor(Index dim1)
|
||||||
: m_storage(dim1, array<Index, 1>(dim1))
|
: m_storage(dim1, array<Index, 1>(dim1))
|
||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT(1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
EIGEN_STATIC_ASSERT(1 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||||
}
|
}
|
||||||
inline explicit Tensor(Index dim1, Index dim2)
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Tensor(Index dim1, Index dim2)
|
||||||
: m_storage(dim1*dim2, array<Index, 2>(dim1, dim2))
|
: m_storage(dim1*dim2, array<Index, 2>(dim1, dim2))
|
||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT(2 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
EIGEN_STATIC_ASSERT(2 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||||
}
|
}
|
||||||
inline explicit Tensor(Index dim1, Index dim2, Index dim3)
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Tensor(Index dim1, Index dim2, Index dim3)
|
||||||
: m_storage(dim1*dim2*dim3, array<Index, 3>(dim1, dim2, dim3))
|
: m_storage(dim1*dim2*dim3, array<Index, 3>(dim1, dim2, dim3))
|
||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT(3 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
EIGEN_STATIC_ASSERT(3 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||||
}
|
}
|
||||||
inline explicit Tensor(Index dim1, Index dim2, Index dim3, Index dim4)
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Tensor(Index dim1, Index dim2, Index dim3, Index dim4)
|
||||||
: m_storage(dim1*dim2*dim3*dim4, array<Index, 4>(dim1, dim2, dim3, dim4))
|
: m_storage(dim1*dim2*dim3*dim4, array<Index, 4>(dim1, dim2, dim3, dim4))
|
||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT(4 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
EIGEN_STATIC_ASSERT(4 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||||
}
|
}
|
||||||
inline explicit Tensor(Index dim1, Index dim2, Index dim3, Index dim4, Index dim5)
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Tensor(Index dim1, Index dim2, Index dim3, Index dim4, Index dim5)
|
||||||
: m_storage(dim1*dim2*dim3*dim4*dim5, array<Index, 5>(dim1, dim2, dim3, dim4, dim5))
|
: m_storage(dim1*dim2*dim3*dim4*dim5, array<Index, 5>(dim1, dim2, dim3, dim4, dim5))
|
||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT(5 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
EIGEN_STATIC_ASSERT(5 == NumIndices, YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||||
@ -375,7 +375,7 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Normal Dimension */
|
/** Normal Dimension */
|
||||||
inline explicit Tensor(const array<Index, NumIndices>& dimensions)
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE explicit Tensor(const array<Index, NumIndices>& dimensions)
|
||||||
: m_storage(internal::array_prod(dimensions), dimensions)
|
: m_storage(internal::array_prod(dimensions), dimensions)
|
||||||
{
|
{
|
||||||
EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
|
EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user