Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions paddle/fluid/extension/src/ext_tensor.cu
14 changes: 11 additions & 3 deletions paddle/fluid/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function(windows_symbolic TARGET)
add_custom_command(OUTPUT ${final_path}/.${src}.cu
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${final_path}/${src}.cc" "${final_path}/.${src}.cu"
COMMENT "create hidden file of ${src}.cu")
add_custom_target(${TARGET} ALL DEPENDS .${src}.cu)
add_custom_target(${TARGET} ALL DEPENDS ${final_path}/.${src}.cu)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoL, so we have a file named "ext_tensor.cu" for Linux Symlink, and a hidden ".ext_tensor.cu"(actually .ext_tensor.cu.cu) for Windows Symlink. What if there were a third/fourth... platform?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src is ext_tensor here. If system is based on Unix, these is no problem generally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove these symlink cases later, include data_type_transform, tensor_utils, etc.

endforeach()
endfunction()

Expand Down Expand Up @@ -413,8 +413,16 @@ include_directories(${PADDLE_SOURCE_DIR}/paddle/fluid/platform)
include_directories(${PADDLE_SOURCE_DIR}/paddle/fluid/extension/include)
include_directories(${PADDLE_SOURCE_DIR}/paddle/utils)

if(WITH_ROCM)
hip_library(custom_tensor SRCS ../extension/src/ext_tensor.cc DEPS lod_tensor memory enforce)
if (WITH_GPU)
if (WIN32)
windows_symbolic(ext_tensor_cu SRCS ext_tensor.cu PATH ../extension/src)
nv_library(custom_tensor SRCS ../extension/src/.ext_tensor.cu DEPS lod_tensor memory enforce)
add_dependencies(custom_tensor ext_tensor_cu)
else()
nv_library(custom_tensor SRCS ../extension/src/ext_tensor.cu DEPS lod_tensor memory enforce)
endif(WIN32)
elseif (WITH_ROCM)
hip_library(custom_tensor SRCS ../extension/src/ext_tensor.cu DEPS lod_tensor memory enforce)
else()
cc_library(custom_tensor SRCS ../extension/src/ext_tensor.cc DEPS lod_tensor memory enforce)
endif()
Expand Down
7 changes: 7 additions & 0 deletions paddle/fluid/framework/custom_tensor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ void TestCast(paddle::DataType data_type) {
t1.template mutable_data<T>();
auto t2 = t1.cast(data_type);
CHECK(t2.type() == data_type);
#ifdef PADDLE_WITH_CUDA
auto tg1 = paddle::Tensor(paddle::PlaceType::kGPU);
tg1.reshape(tensor_shape);
tg1.template mutable_data<T>();
auto tg2 = tg1.cast(data_type);
CHECK(tg2.type() == data_type);
#endif
}

void GroupTestCopy() {
Expand Down