diff --git a/paddle/phi/backends/xpu/xpu2_op_list.cc b/paddle/phi/backends/xpu/xpu2_op_list.cc index aa9714ee36eaaf296c22587584181140d4a49c68..3a7a0f2fd6b5636f10f6d72be58ddcd29e850b4c 100644 --- a/paddle/phi/backends/xpu/xpu2_op_list.cc +++ b/paddle/phi/backends/xpu/xpu2_op_list.cc @@ -603,7 +603,17 @@ XPUOpMap& get_kl2_ops() { phi::DataType::BOOL, phi::DataType::INT8, phi::DataType::UINT8, + phi::DataType::FLOAT16, phi::DataType::FLOAT32})}, + {"unsqueeze_with_xshape", + XPUKernelSet({phi::DataType::FLOAT64, + phi::DataType::INT64, + phi::DataType::INT32, + phi::DataType::BOOL, + phi::DataType::INT8, + phi::DataType::UINT8, + phi::DataType::FLOAT32, + phi::DataType::FLOAT16})}, {"warpctc_grad", XPUKernelSet({phi::DataType::FLOAT32})}, {"warpctc", XPUKernelSet({phi::DataType::FLOAT32})}, {"where_index", diff --git a/paddle/phi/kernels/xpu/cross_entropy_kernel.cc b/paddle/phi/kernels/xpu/cross_entropy_kernel.cc index f054c6c445148c47dc459761dc6ce7f6c5aef247..f1b2257427f67b1ce8bc3dc194a4d6a3975246a4 100644 --- a/paddle/phi/kernels/xpu/cross_entropy_kernel.cc +++ b/paddle/phi/kernels/xpu/cross_entropy_kernel.cc @@ -89,10 +89,15 @@ void CrossEntropyWithSoftmaxKernel(const Context& dev_ctx, static_cast(max_val)); PADDLE_ENFORCE_XDNN_SUCCESS(r, "clip_v2"); - r = xpu::softmax( - dev_ctx.x_context(), clip_logits_data, softmax_data, logits_dims, axis); - PADDLE_ENFORCE_XDNN_SUCCESS(r, "softmax"); - + if (use_softmax) { + r = xpu::softmax( + dev_ctx.x_context(), clip_logits_data, softmax_data, logits_dims, axis); + PADDLE_ENFORCE_XDNN_SUCCESS(r, "softmax"); + } else { + r = xpu::copy( + dev_ctx.x_context(), clip_logits_data, softmax_data, softmax->numel()); + PADDLE_ENFORCE_XDNN_SUCCESS(r, "copy"); + } // cross_entropy if (axis != rank - 1) { XPUType* trans_softmax = RAII_GUARD.alloc_l3_or_gm(n * d);