Skip to content

Commit f82fa64

Browse files
authored
Move float16 into fluid folder (#8394)
* move float16 into fluid * fix include * move to platform folder
1 parent 432d2b5 commit f82fa64

File tree

5 files changed

+17
-25
lines changed

5 files changed

+17
-25
lines changed

paddle/fluid/platform/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ELSE()
2727
set(MKLDNN_CTX_DEPS)
2828
ENDIF()
2929

30-
# memcpy deoends on device_context, here add deps individually for
30+
# memcpy depends on device_context, here add deps individually for
3131
# avoiding cycle dependencies
3232
cc_library(device_context SRCS device_context.cc DEPS memory buddy_allocator
3333
system_allocator memory_block meta_data meta_cache place eigen3 ${GPU_CTX_DEPS} ${MKLDNN_CTX_DEPS})
@@ -39,3 +39,6 @@ nv_test(nccl_test SRCS nccl_test.cu DEPS dynload_cuda gpu_info device_context)
3939

4040
cc_library(profiler SRCS profiler.cc DEPS device_context)
4141
cc_test(profiler_test SRCS profiler_test.cc DEPS profiler)
42+
43+
nv_test(float16_gpu_test SRCS float16_test.cu)
44+
cc_test(float16_test SRCS float16_test.cc)

paddle/math/float16.h renamed to paddle/fluid/platform/float16.h

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace paddle {
6868
// memory access of float16 struct and also makes float16 compatible
6969
// with CUDA half, ARM float16_t, and Eigen::half data types.
7070
struct PADDLE_ALIGN(2) float16 {
71-
public:
71+
public:
7272
uint16_t x;
7373

7474
// Constructors
@@ -319,7 +319,7 @@ struct PADDLE_ALIGN(2) float16 {
319319
return static_cast<double>(float(*this));
320320
}
321321

322-
private:
322+
private:
323323
union Bits {
324324
float f;
325325
int32_t si;
@@ -485,8 +485,7 @@ HOST inline float16 operator+(const float16& a, const float16& b) {
485485
"st1 {v0.h}[0], [%[res_ptr]]\n"
486486
: // outputs
487487
: // inputs
488-
[a_ptr] "r"(&(a.x)),
489-
[b_ptr] "r"(&(b.x)),
488+
[a_ptr] "r"(&(a.x)), [b_ptr] "r"(&(b.x)),
490489
[res_ptr] "r"(&(res.x))
491490
: // clobbers
492491
"memory", "v0", "v1");
@@ -502,8 +501,7 @@ HOST inline float16 operator-(const float16& a, const float16& b) {
502501
"st1 {v0.h}[0], [%[res_ptr]]\n"
503502
: // outputs
504503
: // inputs
505-
[a_ptr] "r"(&(a.x)),
506-
[b_ptr] "r"(&(b.x)),
504+
[a_ptr] "r"(&(a.x)), [b_ptr] "r"(&(b.x)),
507505
[res_ptr] "r"(&(res.x))
508506
: // clobbers
509507
"memory", "v0", "v1");
@@ -519,8 +517,7 @@ HOST inline float16 operator*(const float16& a, const float16& b) {
519517
"st1 {v0.h}[0], [%[res_ptr]]\n"
520518
: // outputs
521519
: // inputs
522-
[a_ptr] "r"(&(a.x)),
523-
[b_ptr] "r"(&(b.x)),
520+
[a_ptr] "r"(&(a.x)), [b_ptr] "r"(&(b.x)),
524521
[res_ptr] "r"(&(res.x))
525522
: // clobbers
526523
"memory", "v0", "v1");
@@ -536,8 +533,7 @@ HOST inline float16 operator/(const float16& a, const float16& b) {
536533
"st1 {v0.h}[0], [%[res_ptr]]\n"
537534
: // outputs
538535
: // inputs
539-
[a_ptr] "r"(&(a.x)),
540-
[b_ptr] "r"(&(b.x)),
536+
[a_ptr] "r"(&(a.x)), [b_ptr] "r"(&(b.x)),
541537
[res_ptr] "r"(&(res.x))
542538
: // clobbers
543539
"memory", "v0", "v1");
@@ -588,8 +584,7 @@ HOST inline bool operator==(const float16& a, const float16& b) {
588584
"st1 {v0.h}[0], [%[res_ptr]]\n"
589585
: // outputs
590586
: // inputs
591-
[a_ptr] "r"(&(a.x)),
592-
[b_ptr] "r"(&(b.x)),
587+
[a_ptr] "r"(&(a.x)), [b_ptr] "r"(&(b.x)),
593588
[res_ptr] "r"(&res)
594589
: // clobbers
595590
"memory", "v0", "v1");
@@ -609,8 +604,7 @@ HOST inline bool operator<(const float16& a, const float16& b) {
609604
"st1 {v0.h}[0], [%[res_ptr]]\n"
610605
: // outputs
611606
: // inputs
612-
[a_ptr] "r"(&(a.x)),
613-
[b_ptr] "r"(&(b.x)),
607+
[a_ptr] "r"(&(a.x)), [b_ptr] "r"(&(b.x)),
614608
[res_ptr] "r"(&res)
615609
: // clobbers
616610
"memory", "v0", "v1");
@@ -626,8 +620,7 @@ HOST inline bool operator<=(const float16& a, const float16& b) {
626620
"st1 {v0.h}[0], [%[res_ptr]]\n"
627621
: // outputs
628622
: // inputs
629-
[a_ptr] "r"(&(a.x)),
630-
[b_ptr] "r"(&(b.x)),
623+
[a_ptr] "r"(&(a.x)), [b_ptr] "r"(&(b.x)),
631624
[res_ptr] "r"(&res)
632625
: // clobbers
633626
"memory", "v0", "v1");
@@ -643,8 +636,7 @@ HOST inline bool operator>(const float16& a, const float16& b) {
643636
"st1 {v0.h}[0], [%[res_ptr]]\n"
644637
: // outputs
645638
: // inputs
646-
[a_ptr] "r"(&(a.x)),
647-
[b_ptr] "r"(&(b.x)),
639+
[a_ptr] "r"(&(a.x)), [b_ptr] "r"(&(b.x)),
648640
[res_ptr] "r"(&res)
649641
: // clobbers
650642
"memory", "v0", "v1");
@@ -660,8 +652,7 @@ HOST inline bool operator>=(const float16& a, const float16& b) {
660652
"st1 {v0.h}[0], [%[res_ptr]]\n"
661653
: // outputs
662654
: // inputs
663-
[a_ptr] "r"(&(a.x)),
664-
[b_ptr] "r"(&(b.x)),
655+
[a_ptr] "r"(&(a.x)), [b_ptr] "r"(&(b.x)),
665656
[res_ptr] "r"(&res)
666657
: // clobbers
667658
"memory", "v0", "v1");

paddle/math/tests/test_float16.cpp renamed to paddle/fluid/platform/float16_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
99
See the License for the specific language governing permissions and
1010
limitations under the License. */
1111

12-
#include "paddle/math/float16.h"
12+
#include "paddle/fluid/platform/float16.h"
1313

1414
#include <gtest/gtest.h>
1515

paddle/math/tests/test_float16.cu renamed to paddle/fluid/platform/float16_test.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
99
See the License for the specific language governing permissions and
1010
limitations under the License. */
1111

12-
#include "paddle/math/float16.h"
12+
#include "paddle/fluid/platform/float16.h"
1313

1414
#include <gtest/gtest.h>
1515

paddle/math/tests/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ 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-
nv_test(test_float16_gpu SRCS test_float16.cu)
2625
else()
2726
compile_cu_as_cpp(test_Tensor.cu)
2827
add_unittest(test_Tensor test_Tensor.cu)
@@ -34,4 +33,3 @@ add_simple_unittest(test_FPException)
3433
add_simple_unittest(test_GpuProfiler)
3534
add_simple_unittest(test_BaseMatrix)
3635
add_simple_unittest(test_Matrix)
37-
add_simple_unittest(test_float16)

0 commit comments

Comments
 (0)