Skip to content

Commit 6496004

Browse files
[Bug fix]: fix memset on default stream (PaddlePaddle#71696)
1 parent 0982e39 commit 6496004

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

paddle/phi/kernels/gpu/put_along_axis_grad_kernel.cu

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "paddle/phi/core/tensor_utils.h"
2121
#include "paddle/phi/core/utils/data_type.h"
2222
#include "paddle/phi/kernels/funcs/gather_scatter_functor.h"
23+
#include "paddle/phi/kernels/funcs/math_function.h"
2324

2425
namespace phi {
2526

@@ -91,12 +92,13 @@ void PutAlongAxisGradKernel(const Context& dev_ctx,
9192
if (value_grad) {
9293
value_grad->Resize(index.dims());
9394
dev_ctx.template Alloc<T>(value_grad);
95+
#ifdef PADDLE_WITH_HIP
9496
auto* grad_data = value_grad->data<T>();
9597
int64_t grad_size = value_grad->numel();
96-
#ifdef PADDLE_WITH_HIP
9798
hipMemset(grad_data, 0, sizeof(T) * grad_size);
9899
#else
99-
cudaMemset(grad_data, 0, sizeof(T) * grad_size);
100+
// cudaMemset(grad_data, 0, sizeof(T) * grad_size);
101+
phi::funcs::set_constant(dev_ctx, value_grad, 0);
100102
#endif
101103
if (reduce == "assign") {
102104
if (index_type == DataType::INT32) {

0 commit comments

Comments
 (0)