adding fp16 direct that reads pre-vectorized data

[ROCm/composable_kernel commit: 4f0fc72e91]
This commit is contained in:
Chao Liu
2019-03-18 15:03:17 -05:00
parent 2bab275922
commit 5ba0f64087
8 changed files with 369 additions and 175 deletions

View File

@@ -28,44 +28,44 @@ struct vector_type
template <>
struct vector_type<float, 1>
{
using type = float;
using VectorType = float;
};
template <>
struct vector_type<float, 2>
{
using type = float2;
using VectorType = float2;
};
template <>
struct vector_type<float, 4>
{
using type = float4;
using VectorType = float4;
};
#if 0
template <>
struct vector_type<half_float::half, 1>
{
using type = half_float::half;
using VectorType = half_float::half;
};
template <>
struct vector_type<half_float::half, 2>
{
using type = float;
using VectorType = float;
};
template <>
struct vector_type<half_float::half, 4>
{
using type = float2;
using VectorType = float2;
};
template <>
struct vector_type<half_float::half, 8>
{
using type = float4;
using VectorType = float4;
};
#endif
@@ -73,25 +73,41 @@ struct vector_type<half_float::half, 8>
template <>
struct vector_type<half, 1>
{
using type = half;
using VectorType = half;
__host__ __device__ static VectorType pack(half s) { return s; }
};
template <>
struct vector_type<half, 2>
{
using type = half2;
using VectorType = half2;
union Data
{
VectorType vector;
half scalar[2];
};
__host__ __device__ static VectorType pack(half s0, half s1)
{
Data data;
data.scalar[0] = s0;
data.scalar[1] = s1;
return data.vector;
}
};
template <>
struct vector_type<half, 4>
{
using type = float2;
using VectorType = float2;
};
template <>
struct vector_type<half, 8>
{
using type = float4;
using VectorType = float4;
};
#endif