Fix grad_outputs placement in Paddle output grad generation #588
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 意图修复的问题如下:
根因是 PaddleAPITest 在做
paddle.grad(...)时生成的 grad_outputs 没指定 device/place,默认落到 CPU;对 XPU 的slice_grad(complex64)来说,这会触发一条隐式的 CPU→XPU 转换路径,最终把 out_grad 变成了一个只有 meta、没有实际内存的
Tensor(holder_ == null),于是 SliceGradNode 里一旦访问out_grad.data()就报Tensor holds no memory;GPU 上这条隐式拷贝路径是 OK 的所以能过。