10 #ifndef EIGEN_CXX11_TENSOR_TENSOR_CONVERSION_H 11 #define EIGEN_CXX11_TENSOR_TENSOR_CONVERSION_H 23 template<
typename TargetType,
typename XprType>
30 typedef typename XprType::Nested
Nested;
37 template<
typename TargetType,
typename XprType>
43 template<
typename TargetType,
typename XprType>
52 template <
typename TensorEvaluator,
typename SrcPacket,
typename TgtPacket,
int SrcCoeffRatio,
int TgtCoeffRatio>
58 template<
int LoadMode,
typename Index>
60 return internal::pcast<SrcPacket, TgtPacket>(m_impl.template packet<LoadMode>(index));
68 template <
typename TensorEvaluator,
typename SrcPacket,
typename TgtPacket>
74 template<
int LoadMode,
typename Index>
78 SrcPacket src1 = m_impl.template packet<LoadMode>(index);
79 SrcPacket src2 = m_impl.template packet<LoadMode>(index + SrcPacketSize);
80 TgtPacket
result = internal::pcast<SrcPacket, TgtPacket>(src1, src2);
88 template <
typename TensorEvaluator,
typename SrcPacket,
typename TgtPacket>
94 template<
int LoadMode,
typename Index>
98 SrcPacket src1 = m_impl.template packet<LoadMode>(index);
99 SrcPacket src2 = m_impl.template packet<LoadMode>(index + SrcPacketSize);
100 SrcPacket src3 = m_impl.template packet<LoadMode>(index + 2 * SrcPacketSize);
101 SrcPacket src4 = m_impl.template packet<LoadMode>(index + 3 * SrcPacketSize);
102 TgtPacket
result = internal::pcast<SrcPacket, TgtPacket>(src1, src2, src3, src4);
110 template <
typename TensorEvaluator,
typename SrcPacket,
typename TgtPacket>
114 : m_impl(impl), m_maxIndex(impl.
dimensions().TotalSize()) {}
116 template<
int LoadMode,
typename Index>
122 if (m_impl.data() && (index + SrcPacketSize < m_maxIndex)) {
124 return internal::pcast<SrcPacket, TgtPacket>(m_impl.template packet<Unaligned>(index));
131 for (
int i = 0;
i < TgtPacketSize; ++
i) {
132 values[
i] = converter(m_impl.coeff(index+
i));
134 TgtPacket rslt = internal::pload<TgtPacket>(
values);
144 template<
typename TargetType,
typename XprType>
168 impl.evalSubExprsIfNeeded(
NULL);
175 return impl.evalSubExprsIfNeeded(data);
181 template<
typename TargetType,
typename ArgType,
typename Device>
202 : m_impl(op.expression(), device)
221 return converter(m_impl.coeff(index));
224 template<
int LoadMode>
234 const double cast_cost = TensorOpCost::CastCost<SrcType, TargetType>();
236 const double SrcCoeffRatio =
238 const double TgtCoeffRatio =
240 return m_impl.costPerCoeff(vectorized) * (SrcCoeffRatio / PacketSize) +
241 TensorOpCost(0, 0, TgtCoeffRatio * (cast_cost / PacketSize));
243 return m_impl.costPerCoeff(vectorized) +
TensorOpCost(0, 0, cast_cost);
247 EIGEN_DEVICE_FUNC Scalar*
data()
const {
return NULL; }
250 template <
int LoadMode,
bool ActuallyVectorize>
255 for (
int i = 0;
i < PacketSize; ++
i) {
256 values[
i] = converter(impl.
coeff(index+
i));
258 PacketReturnType rslt = internal::pload<PacketReturnType>(
values);
263 template <
int LoadMode>
264 struct PacketConv<LoadMode, true> {
269 SrcCoeffRatio, TgtCoeffRatio> converter(impl);
270 return converter.template packet<LoadMode>(index);
279 #endif // EIGEN_CXX11_TENSOR_TENSOR_CONVERSION_H
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
const TensorEvaluator & m_impl
#define EIGEN_STRONG_INLINE
PacketType< SrcType, Device >::type PacketSourceType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketConverter(const TensorEvaluator &impl)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorConversionOp(const XprType &xpr)
const TensorEvaluator & m_impl
TargetType CoeffReturnType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TgtPacket packet(Index index) const
const TensorConversionOp< TargetType, XprType > & type
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool evalSubExprsIfNeeded(Scalar *data)
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType run(const TensorEvaluator< ArgType, Device > &impl, Index index)
Namespace containing all symbols from the Eigen library.
A cost model used to limit the number of threads used for evaluating tensor expression.
traits< XprType >::StorageKind StorageKind
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketConverter(const TensorEvaluator &impl)
vector< size_t > dimensions(L.begin(), L.end())
internal::nested< TensorConversionOp >::type Nested
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool run(Eval &impl, Scalar *data)
traits< XprType >::Index Index
TensorConversionOp< TargetType, XprType > type
internal::remove_all< typename internal::traits< ArgType >::Scalar >::type SrcType
PacketType< CoeffReturnType, Device >::type PacketReturnType
EIGEN_DEVICE_FUNC const internal::remove_all< typename XprType::Nested >::type & expression() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions & dimensions() const
TensorConversionOp< TargetType, ArgType > XprType
NumTraits< Scalar >::Real RealScalar
internal::traits< TensorConversionOp >::StorageKind StorageKind
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketConverter(const TensorEvaluator &impl)
TensorEvaluator< ArgType, Device >::Dimensions Dimensions
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const TensorEvaluator & m_impl
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType run(const TensorEvaluator< ArgType, Device > &impl, Index index)
Tensor conversion class. This class makes it possible to vectorize type casting operations when the n...
internal::traits< TensorConversionOp >::Scalar Scalar
TensorEvaluator< ArgType, Device > m_impl
internal::traits< TensorConversionOp >::Index Index
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TgtPacket packet(Index index) const
remove_reference< Nested >::type _Nested
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TgtPacket packet(Index index) const
EIGEN_DEVICE_FUNC Scalar * data() const
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool run(Eval &impl, Scalar *)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorOpCost costPerCoeff(bool vectorized) const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void cleanup()
const TensorEvaluator::Index m_maxIndex
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TgtPacket packet(Index index) const
void run(Expr &expr, Dev &dev)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(const XprType &op, const Device &device)
const TensorEvaluator & m_impl
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketConverter(const TensorEvaluator &impl)