diff --git a/paddle/phi/kernels/cpu/index_put_grad_kernel.cc b/paddle/phi/kernels/cpu/index_put_grad_kernel.cc index 7c8ac0624e2d80dec7894e14130b3344eba2849c..9426a5def6527292a11f313b763a7e7b0b53e19f 100644 --- a/paddle/phi/kernels/cpu/index_put_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/index_put_grad_kernel.cc @@ -195,7 +195,7 @@ void IndexPutGradKernel(const Context& dev_ctx, std::vector tmp_res_indices_v; std::vector range_tensor_v; - for (int i = indices.size(); i < x.dims().size(); ++i) { + for (int i = int_indices_v.size(); i < x.dims().size(); ++i) { range_tensor_v.emplace_back(funcs::GetRangeTensor( dev_ctx, x.dims()[i], phi::DataType::INT64)); } diff --git a/paddle/phi/kernels/cpu/index_put_kernel.cc b/paddle/phi/kernels/cpu/index_put_kernel.cc index da93a74886ea8259bd76bc1b0a7c0e06bc9a71f8..3ab05fea8fa4724ff9ad8397b74bb34ee714b039 100644 --- a/paddle/phi/kernels/cpu/index_put_kernel.cc +++ b/paddle/phi/kernels/cpu/index_put_kernel.cc @@ -127,7 +127,7 @@ void IndexPutKernel(const Context& dev_ctx, std::vector range_tensor_v; const DenseTensor* ptr_value = nullptr; - for (int i = indices.size(); i < x.dims().size(); ++i) { + for (int i = int_indices_v.size(); i < x.dims().size(); ++i) { range_tensor_v.emplace_back(funcs::GetRangeTensor( dev_ctx, x.dims()[i], phi::DataType::INT64)); } diff --git a/paddle/phi/kernels/gpu/index_put_grad_kernel.cu b/paddle/phi/kernels/gpu/index_put_grad_kernel.cu index 9dca49ee7ff0fd869780067ef9732f889fd52c36..1a301323cad87365740a1d1d87f106d36a754371 100644 --- a/paddle/phi/kernels/gpu/index_put_grad_kernel.cu +++ b/paddle/phi/kernels/gpu/index_put_grad_kernel.cu @@ -227,7 +227,7 @@ void IndexPutGradKernel(const Context& dev_ctx, std::vector tmp_res_indices_v; std::vector range_tensor_v; - for (int i = indices.size(); i < x.dims().size(); ++i) { + for (int i = int_indices_v.size(); i < x.dims().size(); ++i) { range_tensor_v.emplace_back(funcs::GetRangeCudaTensor( dev_ctx, x.dims()[i], phi::DataType::INT64)); } diff --git a/paddle/phi/kernels/gpu/index_put_kernel.cu b/paddle/phi/kernels/gpu/index_put_kernel.cu index fd4476fe11d98bee67dcb73a4486749f5cfd0826..9710f5baca77de363f088d9be47560ce2755ecf2 100644 --- a/paddle/phi/kernels/gpu/index_put_kernel.cu +++ b/paddle/phi/kernels/gpu/index_put_kernel.cu @@ -128,7 +128,7 @@ void IndexPutKernel(const Context& dev_ctx, std::vector range_tensor_v; const DenseTensor* ptr_value = nullptr; - for (int i = indices.size(); i < x.dims().size(); ++i) { + for (int i = int_indices_v.size(); i < x.dims().size(); ++i) { range_tensor_v.emplace_back(funcs::GetRangeCudaTensor( dev_ctx, x.dims()[i], phi::DataType::INT64)); }