mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-11 19:29:02 +08:00
Roll back changes to core. Move include of TensorFunctors.h up to satisfy dependence in TensorCostModel.h.
This commit is contained in:
parent
5005b27fc8
commit
0dbd68145f
@ -591,47 +591,6 @@ template<typename Scalar>
|
|||||||
struct functor_traits<scalar_inverse_mult_op<Scalar> >
|
struct functor_traits<scalar_inverse_mult_op<Scalar> >
|
||||||
{ enum { PacketAccess = packet_traits<Scalar>::HasDiv, Cost = NumTraits<Scalar>::template Div<PacketAccess>::Cost }; };
|
{ enum { PacketAccess = packet_traits<Scalar>::HasDiv, Cost = NumTraits<Scalar>::template Div<PacketAccess>::Cost }; };
|
||||||
|
|
||||||
/** \internal
|
|
||||||
* \brief Template functor to compute the modulo between an array and a fixed scalar.
|
|
||||||
*/
|
|
||||||
template <typename Scalar>
|
|
||||||
struct scalar_mod_op {
|
|
||||||
EIGEN_DEVICE_FUNC scalar_mod_op(const Scalar& divisor) : m_divisor(divisor) {}
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a) const { return a % m_divisor; }
|
|
||||||
const Scalar m_divisor;
|
|
||||||
};
|
|
||||||
template <typename Scalar>
|
|
||||||
struct functor_traits<scalar_mod_op<Scalar> >
|
|
||||||
{ enum { Cost = NumTraits<Scalar>::template Div<false>::Cost, PacketAccess = false }; };
|
|
||||||
|
|
||||||
/** \internal
|
|
||||||
* \brief Template functor to compute the modulo between two arrays.
|
|
||||||
*/
|
|
||||||
template <typename Scalar>
|
|
||||||
struct scalar_mod2_op {
|
|
||||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_mod2_op);
|
|
||||||
EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a, const Scalar& b) const { return a % b; }
|
|
||||||
};
|
|
||||||
template <typename Scalar>
|
|
||||||
struct functor_traits<scalar_mod2_op<Scalar> >
|
|
||||||
{ enum { Cost = NumTraits<Scalar>::template Div<false>::Cost, PacketAccess = false }; };
|
|
||||||
|
|
||||||
/** \internal
|
|
||||||
* \brief Template functor to compute the float modulo between two arrays.
|
|
||||||
*/
|
|
||||||
template <typename Scalar>
|
|
||||||
struct scalar_fmod_op {
|
|
||||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_fmod_op);
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar
|
|
||||||
operator()(const Scalar& a, const Scalar& b) const {
|
|
||||||
return numext::fmod(a, b);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <typename Scalar>
|
|
||||||
struct functor_traits<scalar_fmod_op<Scalar> > {
|
|
||||||
enum { Cost = 13, // Reciprocal throughput of FPREM on Haswell.
|
|
||||||
PacketAccess = false };
|
|
||||||
};
|
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
|
@ -587,33 +587,6 @@ struct functor_traits<scalar_erfc_op<Scalar> >
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \internal
|
|
||||||
* \brief Template functor to compute the sigmoid of a scalar
|
|
||||||
* \sa class CwiseUnaryOp, ArrayBase::sigmoid()
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
struct scalar_sigmoid_op {
|
|
||||||
EIGEN_EMPTY_STRUCT_CTOR(scalar_sigmoid_op)
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T operator()(const T& x) const {
|
|
||||||
const T one = T(1);
|
|
||||||
return one / (one + numext::exp(-x));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
|
||||||
Packet packetOp(const Packet& x) const {
|
|
||||||
const Packet one = pset1<Packet>(T(1));
|
|
||||||
return pdiv(one, padd(one, pexp(pnegate(x))));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct functor_traits<scalar_sigmoid_op<T> > {
|
|
||||||
enum {
|
|
||||||
Cost = NumTraits<T>::AddCost * 2 + NumTraits<T>::MulCost * 6,
|
|
||||||
PacketAccess = packet_traits<T>::HasAdd && packet_traits<T>::HasDiv &&
|
|
||||||
packet_traits<T>::HasNegate && packet_traits<T>::HasExp
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
* \brief Template functor to compute the atan of a scalar
|
* \brief Template functor to compute the atan of a scalar
|
||||||
|
@ -65,10 +65,10 @@ typedef unsigned __int64 uint64_t;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "src/Tensor/TensorMacros.h"
|
#include "src/Tensor/TensorMacros.h"
|
||||||
#include "src/Tensor/TensorForwardDeclarations.h"
|
#include "src/Tensor/TensorForwardDeclarations.h"
|
||||||
#include "src/Tensor/TensorMeta.h"
|
#include "src/Tensor/TensorMeta.h"
|
||||||
|
#include "src/Tensor/TensorFunctors.h"
|
||||||
#include "src/Tensor/TensorCostModel.h"
|
#include "src/Tensor/TensorCostModel.h"
|
||||||
#include "src/Tensor/TensorDeviceDefault.h"
|
#include "src/Tensor/TensorDeviceDefault.h"
|
||||||
#include "src/Tensor/TensorDeviceThreadPool.h"
|
#include "src/Tensor/TensorDeviceThreadPool.h"
|
||||||
@ -78,7 +78,6 @@ typedef unsigned __int64 uint64_t;
|
|||||||
#include "src/Tensor/TensorDimensions.h"
|
#include "src/Tensor/TensorDimensions.h"
|
||||||
#include "src/Tensor/TensorInitializer.h"
|
#include "src/Tensor/TensorInitializer.h"
|
||||||
#include "src/Tensor/TensorTraits.h"
|
#include "src/Tensor/TensorTraits.h"
|
||||||
#include "src/Tensor/TensorFunctors.h"
|
|
||||||
#include "src/Tensor/TensorUInt128.h"
|
#include "src/Tensor/TensorUInt128.h"
|
||||||
#include "src/Tensor/TensorIntDiv.h"
|
#include "src/Tensor/TensorIntDiv.h"
|
||||||
|
|
||||||
|
@ -13,6 +13,77 @@
|
|||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
|
||||||
|
/** \internal
|
||||||
|
* \brief Template functor to compute the modulo between an array and a scalar.
|
||||||
|
*/
|
||||||
|
template <typename Scalar>
|
||||||
|
struct scalar_mod_op {
|
||||||
|
EIGEN_DEVICE_FUNC scalar_mod_op(const Scalar& divisor) : m_divisor(divisor) {}
|
||||||
|
EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a) const { return a % m_divisor; }
|
||||||
|
const Scalar m_divisor;
|
||||||
|
};
|
||||||
|
template <typename Scalar>
|
||||||
|
struct functor_traits<scalar_mod_op<Scalar> >
|
||||||
|
{ enum { Cost = NumTraits<Scalar>::template Div<false>::Cost, PacketAccess = false }; };
|
||||||
|
|
||||||
|
|
||||||
|
/** \internal
|
||||||
|
* \brief Template functor to compute the modulo between 2 arrays.
|
||||||
|
*/
|
||||||
|
template <typename Scalar>
|
||||||
|
struct scalar_mod2_op {
|
||||||
|
EIGEN_EMPTY_STRUCT_CTOR(scalar_mod2_op);
|
||||||
|
EIGEN_DEVICE_FUNC inline Scalar operator() (const Scalar& a, const Scalar& b) const { return a % b; }
|
||||||
|
};
|
||||||
|
template <typename Scalar>
|
||||||
|
struct functor_traits<scalar_mod2_op<Scalar> >
|
||||||
|
{ enum { Cost = NumTraits<Scalar>::template Div<false>::Cost, PacketAccess = false }; };
|
||||||
|
|
||||||
|
template <typename Scalar>
|
||||||
|
struct scalar_fmod_op {
|
||||||
|
EIGEN_EMPTY_STRUCT_CTOR(scalar_fmod_op);
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar
|
||||||
|
operator()(const Scalar& a, const Scalar& b) const {
|
||||||
|
return numext::fmod(a, b);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template <typename Scalar>
|
||||||
|
struct functor_traits<scalar_fmod_op<Scalar> > {
|
||||||
|
enum { Cost = 13, // Reciprocal throughput of FPREM on Haswell.
|
||||||
|
PacketAccess = false };
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** \internal
|
||||||
|
* \brief Template functor to compute the sigmoid of a scalar
|
||||||
|
* \sa class CwiseUnaryOp, ArrayBase::sigmoid()
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
struct scalar_sigmoid_op {
|
||||||
|
EIGEN_EMPTY_STRUCT_CTOR(scalar_sigmoid_op)
|
||||||
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T operator()(const T& x) const {
|
||||||
|
const T one = T(1);
|
||||||
|
return one / (one + numext::exp(-x));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
|
Packet packetOp(const Packet& x) const {
|
||||||
|
const Packet one = pset1<Packet>(T(1));
|
||||||
|
return pdiv(one, padd(one, pexp(pnegate(x))));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct functor_traits<scalar_sigmoid_op<T> > {
|
||||||
|
enum {
|
||||||
|
Cost = NumTraits<T>::AddCost * 2 + NumTraits<T>::MulCost * 6,
|
||||||
|
PacketAccess = packet_traits<T>::HasAdd && packet_traits<T>::HasDiv &&
|
||||||
|
packet_traits<T>::HasNegate && packet_traits<T>::HasExp
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Standard reduction functors
|
// Standard reduction functors
|
||||||
template <typename T> struct SumReducer
|
template <typename T> struct SumReducer
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user