12 #include "../../Index.h"
13 #include "Float16.cuh"
15 namespace faiss {
namespace gpu {
33 static inline __device__
float to(
float v) {
return v; }
34 #ifdef FAISS_USE_FLOAT16
35 static inline __device__
float to(half v) {
return __half2float(v); }
41 static inline __device__ float2 to(float2 v) {
return v; }
42 #ifdef FAISS_USE_FLOAT16
43 static inline __device__ float2 to(half2 v) {
return __half22float2(v); }
49 static inline __device__ float4 to(float4 v) {
return v; }
50 #ifdef FAISS_USE_FLOAT16
51 static inline __device__ float4 to(Half4 v) {
return half4ToFloat4(v); }
55 #ifdef FAISS_USE_FLOAT16
58 static inline __device__ half to(
float v) {
return __float2half(v); }
59 static inline __device__ half to(half v) {
return v; }
63 struct ConvertTo<half2> {
64 static inline __device__ half2 to(float2 v) {
return __float22half2_rn(v); }
65 static inline __device__ half2 to(half2 v) {
return v; }
69 struct ConvertTo<Half4> {
70 static inline __device__ Half4 to(float4 v) {
return float4ToHalf4(v); }
71 static inline __device__ Half4 to(Half4 v) {
return v; }
long idx_t
all indices are this type