14 #include "Float16.cuh"
16 namespace faiss {
namespace gpu {
28 static inline __device__
float to(
float v) {
return v; }
29 #ifdef FAISS_USE_FLOAT16
30 static inline __device__
float to(half v) {
return __half2float(v); }
36 static inline __device__ float2 to(float2 v) {
return v; }
37 #ifdef FAISS_USE_FLOAT16
38 static inline __device__ float2 to(half2 v) {
return __half22float2(v); }
44 static inline __device__ float4 to(float4 v) {
return v; }
45 #ifdef FAISS_USE_FLOAT16
46 static inline __device__ float4 to(Half4 v) {
return half4ToFloat4(v); }
50 #ifdef FAISS_USE_FLOAT16
53 static inline __device__ half to(
float v) {
return __float2half(v); }
54 static inline __device__ half to(half v) {
return v; }
58 struct ConvertTo<half2> {
59 static inline __device__ half2 to(float2 v) {
return __float22half2_rn(v); }
60 static inline __device__ half2 to(half2 v) {
return v; }
64 struct ConvertTo<Half4> {
65 static inline __device__ Half4 to(float4 v) {
return float4ToHalf4(v); }
66 static inline __device__ Half4 to(Half4 v) {
return v; }