Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CustomOp] Fix ext_tensor.cast failed bug #34884

Merged

Conversation

chenwhql
Copy link
Contributor

PR types

Bug fixes

PR changes

Others

Describe

The code in macro __NVCC__ need to put into .cu file and compiled by nvcc.

#if defined(__NVCC__) || defined(__HIPCC__)
    } else if (platform::is_gpu_place(in_.place())) {
      platform::Transform<platform::CUDADeviceContext> trans;
      auto *context = static_cast<const platform::CUDADeviceContext *>(ctx_);
      trans(*context, in_begin, in_end, out_begin,
            CastDataTypeFunctor<InType, OutType>());
      context->Wait();
#endif

Before this PR, if we call tensor.cast(x) and x.place is kGPU, it will throw error.

e72962a35b5a5e853a5ddc84e251c33d

2e39c354ef9e4a5c6eb151b7a7efe45e

Copy link
Contributor

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -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.

@chenwhql chenwhql merged commit 4d88cdb into PaddlePaddle:develop Aug 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants