Skip to content

Commit

Permalink
Merge commit 'e67b525388a5ae11ed243e94bbc25b4934b03a66'
Browse files Browse the repository at this point in the history
  • Loading branch information
soumith committed Jan 13, 2017
2 parents 69d8331 + e67b525 commit b8a5b1e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion torch/lib/TH/THGeneral.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void _THArgCheck(const char *file, int line, int condition, int argNumber, const
snprintf(msg + n, 2048 - n, " at %s:%d", file, line);
}

if (threadArgErrorHandlerData)
if (threadArgErrorHandler)
(*threadArgErrorHandler)(argNumber, msg, threadArgErrorHandlerData);
else
(*defaultArgErrorHandler)(argNumber, msg, defaultArgErrorHandlerData);
Expand Down
8 changes: 5 additions & 3 deletions torch/lib/TH/THHalf.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,17 @@ float TH_half2float(THHalf h)
}

int temp = ((sign << 31) | (exponent << 23) | mantissa);

return *((float*)((void*)&temp));
float x;
memcpy(&x,&temp,sizeof(float));
return x;
}

THHalf TH_float2half(float f)
{
THHalf ret;

unsigned x = *((int*)(void*)(&f));
unsigned x;
memcpy(&x,&f,sizeof(f));
unsigned u = (x & 0x7fffffff), remainder, shift, lsb, lsb_s1, lsb_m1;
unsigned sign, exponent, mantissa;

Expand Down
4 changes: 2 additions & 2 deletions torch/lib/TH/cmake/FindARM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ if(NOT NEON_FOUND)
MESSAGE(STATUS "Could not find hardware support for NEON on this machine.")
endif(NOT NEON_FOUND)
if(NOT CORTEXA8_FOUND)
MESSAGE(STATUS "No OMAP3 processor on this on this machine.")
MESSAGE(STATUS "No OMAP3 processor on this machine.")
endif(NOT CORTEXA8_FOUND)
if(NOT CORTEXA9_FOUND)
MESSAGE(STATUS "No OMAP4 processor on this on this machine.")
MESSAGE(STATUS "No OMAP4 processor on this machine.")
endif(NOT CORTEXA9_FOUND)
mark_as_advanced(NEON_FOUND)
10 changes: 8 additions & 2 deletions torch/lib/TH/generic/THTensorCopy.c
Original file line number Diff line number Diff line change
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
4 changes: 2 additions & 2 deletions torch/lib/TH/generic/simd/simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ enum SIMDExtensions
};


#if defined(__arm__)
#if defined(__arm__) || defined(__aarch64__) // incl. armel, armhf, arm64

#if defined(__NEON__)

Expand All @@ -80,7 +80,7 @@ static inline uint32_t detectHostSIMDExtensions()
return SIMDExtension_VSX;
}

#else
#else //PPC64 without VSX

static inline uint32_t detectHostSIMDExtensions()
{
Expand Down

0 comments on commit b8a5b1e

Please sign in to comment.