[XPU] Fix XPU kernel errors for paddle.diagonal_scatter#79008
Open
YqGe585 wants to merge 1 commit into
Open
Conversation
… xpu::fill_diagonal_tensor XDNN call with CPU-side diagonal fill The XDNN fill_diagonal_tensor function rejected several dtypes (float32, int64, int32, float16, bool) with XDNN_INVALID_PARAM. Replace it with a CPU round-trip approach that computes diagonal positions via CalMatDims and fills values on CPU, matching the CPU/GPU kernel algorithm. This eliminates the XPU kernel dependency on XDNN for the core fill logic. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
你的PR提交成功,感谢你对开源项目的贡献! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Category
Operator Mechanism
PR Types
Bug fixes
Description
Fix XPU kernel errors for
paddle.diagonal_scatterwhere the underlying XDNNfill_diagonal_tensorfunction rejected several data types (float32,int64,int32,float16,bool) withXDNN_INVALID_PARAM.Root Cause
The XPU kernel at
paddle/phi/kernels/xpu/fill_diagonal_tensor_kernel.ccdelegated the diagonal fill logic entirely to the XDNN library'sxpu::fill_diagonal_tensorfunction. This function does not support all the data types that Paddle registers the kernel for, causing runtime errors for those dtypes.Fix
Replaced the XDNN
fill_diagonal_tensorcall with a CPU round-trip approach:CalMatDims(same as CPU/GPU kernel)This approach:
unique_kernel.cc,generate_proposals_kernel.cc)Test Results
All 13 testable cases from
PaddleAPITest/all_config.txtpass withmax_abs_diff=0, max_rel_diff=0(bitwise identical XPU vs GPU outputs):bool,complex64,float16,float32(offset=0/1/-2, axis1=0/1 axis2=0/1),float64,int8,int16,int32,int64,uint8complex128is skipped by the test framework (known XPU platform limitation).Does this PR introduce a precision change?
Yes — XPU precision corrected to align with GPU for previously failing data types.