Skip to content

Commit

Permalink
Fix THHalf issues with MSVC.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchanan committed Jan 5, 2017
1 parent 319a423 commit c5bf47a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/TH/generic/THTensorCopy.c
Expand Up @@ -4,7 +4,7 @@

void THTensor_(copy)(THTensor *tensor, THTensor *src)
{
TH_TENSOR_APPLY2(real, tensor, real, src, *tensor_data = (real)(*src_data);)
TH_TENSOR_APPLY2(real, tensor, real, src, *tensor_data = *src_data;)
}

#define IMPLEMENT_THTensor_COPY(TYPENAMESRC, TYPE_SRC) \
Expand All @@ -25,6 +25,12 @@ void THTensor_(copy##TYPENAMESRC)(THTensor *tensor, TH##TYPENAMESRC##Tensor *src
TH_TENSOR_APPLY2(real, tensor, TYPE_SRC, src, *tensor_data = (real)TH_half2float(*src_data);) \
}

#define IMPLEMENT_THTensor_COPY_TO_FROM_HALF(TYPENAMESRC, TYPE_SRC) \
void THTensor_(copy##TYPENAMESRC)(THTensor *tensor, TH##TYPENAMESRC##Tensor *src) \
{ \
TH_TENSOR_APPLY2(real, tensor, TYPE_SRC, src, *tensor_data = *src_data;) \
}

#ifndef TH_REAL_IS_HALF
IMPLEMENT_THTensor_COPY(Byte, unsigned char)
IMPLEMENT_THTensor_COPY(Char, char)
Expand All @@ -36,7 +42,7 @@ IMPLEMENT_THTensor_COPY(Double, double)
IMPLEMENT_THTensor_COPY_FROM_HALF(Half, THHalf)
#else
/* only allow pass-through for Half */
IMPLEMENT_THTensor_COPY(Half, THHalf)
IMPLEMENT_THTensor_COPY_TO_FROM_HALF(Half, THHalf)
IMPLEMENT_THTensor_COPY_TO_HALF(Byte, unsigned char)
IMPLEMENT_THTensor_COPY_TO_HALF(Char, char)
IMPLEMENT_THTensor_COPY_TO_HALF(Short, short)
Expand Down

0 comments on commit c5bf47a

Please sign in to comment.