| 946 | arrayfire::common::half val) noexcept; |
| 947 | |
| 948 | class alignas(2) half { |
| 949 | native_half_t data_ = native_half_t(); |
| 950 | |
| 951 | #if !defined(__NVCC__) && !defined(__CUDACC_RTC__) |
| 952 | // NVCC on OSX performs a weird transformation where it removes the std:: |
| 953 | // namespace and complains that the std:: namespace is not there |
| 954 | friend class std::numeric_limits<half>; |
| 955 | friend struct std::hash<half>; |
| 956 | #endif |
| 957 | |
| 958 | public: |
| 959 | AF_CONSTEXPR |
| 960 | half() = default; |
| 961 | |
| 962 | /// Constructor. |
| 963 | /// \param bits binary representation to set half to |
| 964 | AF_CONSTEXPR __DH__ half(internal::binary_t, uint16_t bits) noexcept |
| 965 | : |
| 966 | #if defined(__CUDA_ARCH__) |
| 967 | data_(__ushort_as_half(bits)) |
| 968 | #else |
| 969 | data_(bits) |
| 970 | #endif |
| 971 | { |
| 972 | #ifndef __CUDACC_RTC__ |
| 973 | static_assert(std::is_standard_layout<half>::value, |
| 974 | "half must be a standard layout type"); |
| 975 | static_assert(std::is_nothrow_move_assignable<half>::value, |
| 976 | "half is not move assignable"); |
| 977 | static_assert(std::is_nothrow_move_constructible<half>::value, |
| 978 | "half is not move constructible"); |
| 979 | #endif |
| 980 | } |
| 981 | |
| 982 | __DH__ explicit half(double value) noexcept |
| 983 | : data_(float2half<double>(value)) {} |
| 984 | |
| 985 | #if defined(__CUDA_ARCH__) |
| 986 | AF_CONSTEXPR |