mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-10 23:21:47 +08:00
Restore __device__
This commit is contained in:
parent
243249718b
commit
95ec3232c6
@ -147,55 +147,55 @@ namespace half_impl {
|
|||||||
// versions to get the ALU speed increased), but you do save the
|
// versions to get the ALU speed increased), but you do save the
|
||||||
// conversion steps back and forth.
|
// conversion steps back and forth.
|
||||||
|
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator + (const half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ half operator + (const half& a, const half& b) {
|
||||||
return __hadd(a, b);
|
return __hadd(a, b);
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator * (const half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ half operator * (const half& a, const half& b) {
|
||||||
return __hmul(a, b);
|
return __hmul(a, b);
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator - (const half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ half operator - (const half& a, const half& b) {
|
||||||
return __hsub(a, b);
|
return __hsub(a, b);
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator / (const half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ half operator / (const half& a, const half& b) {
|
||||||
float num = __half2float(a);
|
float num = __half2float(a);
|
||||||
float denom = __half2float(b);
|
float denom = __half2float(b);
|
||||||
return __float2half(num / denom);
|
return __float2half(num / denom);
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half operator - (const half& a) {
|
EIGEN_STRONG_INLINE __device__ half operator - (const half& a) {
|
||||||
return __hneg(a);
|
return __hneg(a);
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator += (half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ half& operator += (half& a, const half& b) {
|
||||||
a = a + b;
|
a = a + b;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator *= (half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ half& operator *= (half& a, const half& b) {
|
||||||
a = a * b;
|
a = a * b;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator -= (half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ half& operator -= (half& a, const half& b) {
|
||||||
a = a - b;
|
a = a - b;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half& operator /= (half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ half& operator /= (half& a, const half& b) {
|
||||||
a = a / b;
|
a = a / b;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator == (const half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ bool operator == (const half& a, const half& b) {
|
||||||
return __heq(a, b);
|
return __heq(a, b);
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator != (const half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ bool operator != (const half& a, const half& b) {
|
||||||
return __hne(a, b);
|
return __hne(a, b);
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator < (const half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ bool operator < (const half& a, const half& b) {
|
||||||
return __hlt(a, b);
|
return __hlt(a, b);
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator <= (const half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ bool operator <= (const half& a, const half& b) {
|
||||||
return __hle(a, b);
|
return __hle(a, b);
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator > (const half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ bool operator > (const half& a, const half& b) {
|
||||||
return __hgt(a, b);
|
return __hgt(a, b);
|
||||||
}
|
}
|
||||||
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool operator >= (const half& a, const half& b) {
|
EIGEN_STRONG_INLINE __device__ bool operator >= (const half& a, const half& b) {
|
||||||
return __hge(a, b);
|
return __hge(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,7 +608,7 @@ struct hash<Eigen::half> {
|
|||||||
|
|
||||||
// Add the missing shfl_xor intrinsic
|
// Add the missing shfl_xor intrinsic
|
||||||
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 300
|
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 300
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::half __shfl_xor(Eigen::half var, int laneMask, int width=warpSize) {
|
__device__ EIGEN_STRONG_INLINE Eigen::half __shfl_xor(Eigen::half var, int laneMask, int width=warpSize) {
|
||||||
return static_cast<Eigen::half>(__shfl_xor(static_cast<float>(var), laneMask, width));
|
return static_cast<Eigen::half>(__shfl_xor(static_cast<float>(var), laneMask, width));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user