Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Zero-Dim] support input 0D for paddle.moveaxis / quantile #49813

Merged
merged 2 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions paddle/phi/kernels/xpu/transpose_grad_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ void TransposeGradKernel(const Context& dev_ctx,
DenseTensor* x_grad) {
using XPUType = typename XPUTypeTrait<T>::Type;
dev_ctx.template Alloc<T>(x_grad);
if (x_grad->numel() == 0) {
return;
}
if (axis.size() == 0) {
phi::Copy<Context>(dev_ctx, out_grad, dev_ctx.GetPlace(), false, x_grad);
return;
}

std::vector<int> reversed_axis(axis);
for (size_t i = 0; i < axis.size(); i++) {
reversed_axis[axis[i]] = i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,6 @@ def test_axis_value_error_2():

self.assertRaises(ValueError, test_axis_value_error_2)

# Test error with no valid axis
def test_axis_value_error_3():
paddle_res = paddle.quantile(self.x, q=0.4, axis=[])

self.assertRaises(ValueError, test_axis_value_error_3)


class TestQuantileRuntime(unittest.TestCase):
"""
Expand Down
Loading