15 #include "Float16.cuh"
17 namespace faiss {
namespace gpu {
29 static inline __device__
float to(
float v) {
return v; }
30 #ifdef FAISS_USE_FLOAT16
31 static inline __device__
float to(half v) {
return __half2float(v); }
37 static inline __device__ float2 to(float2 v) {
return v; }
38 #ifdef FAISS_USE_FLOAT16
39 static inline __device__ float2 to(half2 v) {
return __half22float2(v); }
45 static inline __device__ float4 to(float4 v) {
return v; }
46 #ifdef FAISS_USE_FLOAT16
47 static inline __device__ float4 to(Half4 v) {
return half4ToFloat4(v); }
51 #ifdef FAISS_USE_FLOAT16
54 static inline __device__ half to(
float v) {
return __float2half(v); }
55 static inline __device__ half to(half v) {
return v; }
59 struct ConvertTo<half2> {
60 static inline __device__ half2 to(float2 v) {
return __float22half2_rn(v); }
61 static inline __device__ half2 to(half2 v) {
return v; }
65 struct ConvertTo<Half4> {
66 static inline __device__ Half4 to(float4 v) {
return float4ToHalf4(v); }
67 static inline __device__ Half4 to(Half4 v) {
return v; }