Skip to content

Commit

Permalink
[CustomOp] Fix ext_tensor.cast failed bug (#34884)
Browse files Browse the repository at this point in the history
* fix ext_tensor.cast failed bug

* remove useless deps

* fix windows cmake failed

* try to fix windows make failed

* fix make error on windwos
  • Loading branch information
chenwhql authored Aug 18, 2021
1 parent dd533dd commit 4d88cdb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
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)
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

0 comments on commit 4d88cdb

Please sign in to comment.