Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#40 from mthreads/format_build_musa
Browse files Browse the repository at this point in the history
[MTAI-484] feat(build): fix a bug in softmax.cu for MUSA
  • Loading branch information
caizhi-mt authored and mt-robot committed Aug 14, 2023
2 parents 269609e + d485fb5 commit 7bb11aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 2 additions & 0 deletions paddle/phi/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ if(WITH_MUSA)
"gpu/rnn_grad_kernel.cu.cc"
"gpu/rnn_kernel.cu.cc"
"gpu/slogdeterminant_grad_kernel.cu"
"gpu/softmax_grad_kernel.cu"
"gpu/softmax_kernel.cu"
"gpu/solve_grad_kernel.cu"
"gpu/solve_kernel.cu"
"gpu/spectral_norm_grad_kernel.cu"
Expand Down
3 changes: 2 additions & 1 deletion paddle/phi/kernels/funcs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ endif()
if(WITH_MUSA)
list(REMOVE_ITEM func_cu_srcs
"cross_entropy.cu"
"gru_compute.cu")
"gru_compute.cu"
"softmax.cu")
endif()

collect_srcs(kernels_srcs SRCS ${func_cc_srcs} ${func_cu_srcs})
14 changes: 4 additions & 10 deletions paddle/phi/kernels/funcs/softmax.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ limitations under the License. */

namespace phi {
namespace funcs {
// TODO(@caizhi): enable it
#if 0
using ScopedTensorDescriptor = phi::backends::gpu::ScopedTensorDescriptor;
using DataLayout = phi::backends::gpu::DataLayout;
template <typename T>
Expand Down Expand Up @@ -61,8 +59,6 @@ void SoftmaxCUDNNFunctor<T, DeviceContext>::operator()(
context.template Alloc<T>(Y),
MIOPEN_SOFTMAX_ACCURATE,
MIOPEN_SOFTMAX_MODE_INSTANCE));
#elif defined(PADDLE_WITH_MUSA)
// TODO
#else
cudnnTensorDescriptor_t cudnn_x_desc =
xDesc.descriptor<T>(layout, cudnn_tensor_dims);
Expand Down Expand Up @@ -148,18 +144,16 @@ template class SoftmaxCUDNNFunctor<float, phi::GPUContext>;
template class SoftmaxCUDNNFunctor<phi::dtype::float16, phi::GPUContext>;
template class SoftmaxGradCUDNNFunctor<float, phi::GPUContext>;
template class SoftmaxGradCUDNNFunctor<phi::dtype::float16, phi::GPUContext>;
// TODO(@caizhi): enable it
//#if CUDNN_VERSION_MIN(8, 1, 0)
//template class SoftmaxCUDNNFunctor<phi::dtype::bfloat16, phi::GPUContext>;
//template class SoftmaxGradCUDNNFunctor<phi::dtype::bfloat16, phi::GPUContext>;
//#endif
#if CUDNN_VERSION_MIN(8, 1, 0)
template class SoftmaxCUDNNFunctor<phi::dtype::bfloat16, phi::GPUContext>;
template class SoftmaxGradCUDNNFunctor<phi::dtype::bfloat16, phi::GPUContext>;
#endif

// MIOPEN do not support double
#ifndef PADDLE_WITH_HIP
template class SoftmaxCUDNNFunctor<double, phi::GPUContext>;
template class SoftmaxGradCUDNNFunctor<double, phi::GPUContext>;
#endif
#endif
template class SoftmaxFunctor<phi::GPUContext, phi::dtype::float16>;
template class SoftmaxFunctor<phi::GPUContext, phi::dtype::bfloat16>;
template class SoftmaxFunctor<phi::GPUContext, float>;
Expand Down

0 comments on commit 7bb11aa

Please sign in to comment.