From ddc8a726ac322d1edf036469cc8acc1262114531 Mon Sep 17 00:00:00 2001 From: jameszhang Date: Fri, 13 Jan 2023 13:58:05 +0800 Subject: [PATCH] fix xpu unittest issue (#49760) * fix xpu unittest issue: zero_dim_tensor * deal with leftout issue introduced by #49470 --- paddle/phi/backends/xpu/xpu2_op_list.cc | 6 ------ .../fluid/tests/unittests/xpu/test_zero_dim_tensor_xpu.py | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/paddle/phi/backends/xpu/xpu2_op_list.cc b/paddle/phi/backends/xpu/xpu2_op_list.cc index 77b113c61b0..a18683f6b52 100644 --- a/paddle/phi/backends/xpu/xpu2_op_list.cc +++ b/paddle/phi/backends/xpu/xpu2_op_list.cc @@ -269,12 +269,6 @@ XPUOpMap& get_kl2_ops() { phi::DataType::INT8, phi::DataType::FLOAT16, phi::DataType::FLOAT32})}, - {"flatten", - XPUKernelSet({phi::DataType::INT64, - phi::DataType::INT32, - phi::DataType::INT8, - phi::DataType::FLOAT16, - phi::DataType::FLOAT32})}, {"flatten_grad", XPUKernelSet({phi::DataType::INT64, phi::DataType::INT32, diff --git a/python/paddle/fluid/tests/unittests/xpu/test_zero_dim_tensor_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_zero_dim_tensor_xpu.py index 64085e2fcdc..97925b72bea 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_zero_dim_tensor_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_zero_dim_tensor_xpu.py @@ -747,6 +747,7 @@ class TestSundryAPI(unittest.TestCase): out1.numpy(), ) + out0.retain_grads() out0.backward() self.assertEqual(out0.grad.shape, [1]) self.assertEqual(logit.grad.shape, [2, 3]) -- GitLab