Skip to content

Commit 22dfa5f

Browse files
committed
fix GPU compiling
1 parent 979d2e0 commit 22dfa5f

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

paddle/math/float16.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ struct PADDLE_ALIGN(2) float16 {
118118
PADDLE_HOSTDEVICE inline float16(const Eigen::half& h) : x(h.x) {}
119119
#endif // USE_EIGEN
120120

121-
#if (PADDLE_GNUC_VER >= 61 || PADDLE_CLANG_VER >= 34) && \
122-
defined(PADDLE_NEON) && defined(PADDLE_ARM_FP16)
121+
#if defined(PADDLE_NEON) && defined(PADDLE_ARM_FP16) && \
122+
(PADDLE_GNUC_VER >= 61 || PADDLE_CLANG_VER >= 34)
123123
// __fp16 is a native half precision data type for arm cpu,
124124
// float16_t is an alias for __fp16 in arm_fp16.h,
125125
// which is included in arm_neon.h.
@@ -207,8 +207,8 @@ struct PADDLE_ALIGN(2) float16 {
207207
}
208208
#endif // USE_EIGEN
209209

210-
#if (PADDLE_GNUC_VER >= 61 || PADDLE_CLANG_VER >= 34) && \
211-
defined(PADDLE_NEON) && defined(PADDLE_ARM_FP16)
210+
#if defined(PADDLE_NEON) && defined(PADDLE_ARM_FP16) && \
211+
(PADDLE_GNUC_VER >= 61 || PADDLE_CLANG_VER >= 34)
212212
PADDLE_HOSTDEVICE inline float16& operator=(const float16_t* rhs) {
213213
x = *reinterpret_cast<uint16_t*>(rhs);
214214
return *this;
@@ -302,8 +302,8 @@ struct PADDLE_ALIGN(2) float16 {
302302
}
303303
#endif // USE_EIGEN
304304

305-
#if (PADDLE_GNUC_VER >= 61 || PADDLE_CLANG_VER >= 34) && \
306-
defined(PADDLE_NEON) && defined(PADDLE_ARM_FP16)
305+
#if defined(PADDLE_NEON) && defined(PADDLE_ARM_FP16) && \
306+
(PADDLE_GNUC_VER >= 61 || PADDLE_CLANG_VER >= 34)
307307
// check whether it works or not
308308
PADDLE_HOSTDEVICE inline operator float16_t() const {
309309
float16 h = *this;

paddle/math/tests/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@ if(WITH_GPU)
2222
link_paddle_test(test_Tensor)
2323
CUDA_ADD_EXECUTABLE(test_lazyAssign test_lazyAssign.cu)
2424
link_paddle_test(test_lazyAssign)
25+
CUDA_ADD_EXECUTABLE(test_float16 test_float16.cu)
26+
link_paddle_test(test_float16)
2527
else()
2628
compile_cu_as_cpp(test_Tensor.cu)
2729
add_unittest(test_Tensor test_Tensor.cu)
2830
compile_cu_as_cpp(test_lazyAssign.cu)
2931
add_unittest(test_lazyAssign test_lazyAssign.cu)
32+
compile_cu_as_cpp(test_float16.cu)
33+
add_unittest(test_float16 test_float16.cu)
3034
endif(WITH_GPU)
3135

3236
add_simple_unittest(test_FPException)
3337
add_simple_unittest(test_GpuProfiler)
3438
add_simple_unittest(test_BaseMatrix)
3539
add_simple_unittest(test_Matrix)
36-
add_simple_unittest(test_float16)

paddle/math/tests/test_float16.cpp renamed to paddle/math/tests/test_float16.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ limitations under the License. */
1515
namespace paddle {
1616

1717
#ifdef PADDLE_CUDA_FP16
18-
TEST(float16, gpu) {
18+
TEST(float16, conversion_gpu) {
1919
// Conversion to and from cuda half
2020
float16 v1 = half(float16(1.0f));
2121
EXPECT_EQ(v1.x, 0x3c00);

0 commit comments

Comments
 (0)