diff --git a/cmake/external/xpu.cmake b/cmake/external/xpu.cmake index bd86e5ee5b0fabe0ecd5e60fca1858516139e130..5e560a27018b25fe2cea4d2043c2827ed049fed4 100644 --- a/cmake/external/xpu.cmake +++ b/cmake/external/xpu.cmake @@ -10,7 +10,7 @@ set(XPU_RT_LIB_NAME "libxpurt.so") if(NOT DEFINED XPU_BASE_URL) set(XPU_BASE_URL_WITHOUT_DATE "https://baidu-kunlun-product.su.bcebos.com/KL-SDK/klsdk-dev") - set(XPU_BASE_URL "${XPU_BASE_URL_WITHOUT_DATE}/20221104") + set(XPU_BASE_URL "${XPU_BASE_URL_WITHOUT_DATE}/20221110") else() set(XPU_BASE_URL "${XPU_BASE_URL}") endif() @@ -19,7 +19,7 @@ endif() if(NOT DEFINED XPU_XDNN_BASE_URL) set(XPU_XDNN_BASE_URL_WITHOUT_DATE "https://klx-sdk-release-public.su.bcebos.com/xdnn/dev") - set(XPU_XDNN_BASE_URL "${XPU_XDNN_BASE_URL_WITHOUT_DATE}/20221103") + set(XPU_XDNN_BASE_URL "${XPU_XDNN_BASE_URL_WITHOUT_DATE}/20221109") else() set(XPU_XDNN_BASE_URL "${XPU_XDNN_BASE_URL}") endif() diff --git a/paddle/phi/kernels/xpu/conv_transpose_kernel.cc b/paddle/phi/kernels/xpu/conv_transpose_kernel.cc index ca0c0084d3bc774eb969fabb8ad2b11f92a64fdb..888ef7ba33c7085d1b74495268a94abd701b0a24 100644 --- a/paddle/phi/kernels/xpu/conv_transpose_kernel.cc +++ b/paddle/phi/kernels/xpu/conv_transpose_kernel.cc @@ -72,52 +72,30 @@ void Conv2dTransposeKernel(const Context& ctx, const int batch_size = static_cast(x.dims()[0]); const int img_yc = static_cast(x.dims()[1]); - const int img_yh = static_cast(x.dims()[2]); - const int img_yw = static_cast(x.dims()[3]); const int img_xc = static_cast(out->dims()[1]); const int img_xh = static_cast(out->dims()[2]); const int img_xw = static_cast(out->dims()[3]); - { - std::vector ksize_check = vector_extend(ksize, 2); - std::vector stride_check = vector_extend(strides, 2); - std::vector pad_check = vector_extend(paddings_, 4); - std::vector dilation_check = vector_extend(dilations_, 2); - - int xh_check = (img_yh - 1) * stride_check[0] - pad_check[0] - - pad_check[1] + - (dilation_check[0] * (ksize_check[0] - 1) + 1); - int xw_check = (img_yw - 1) * stride_check[1] - pad_check[2] - - pad_check[3] + - (dilation_check[1] * (ksize_check[1] - 1) + 1); - - PADDLE_ENFORCE_EQ( - xh_check == img_xh && xw_check == img_xw, - true, - errors::InvalidArgument( - ("XPU output size check error in conv_transpose op."))); - } - - int r = - xpu::conv2d_transpose(ctx.x_context(), - x.data(), - filter_.data(), - out->data(), - batch_size, - img_yc, - img_yh, - img_yw, - img_xc, - ksize, - strides, - paddings_, - dilations_, - groups, - nullptr, - nullptr, - nullptr, - true); - PADDLE_ENFORCE_XDNN_SUCCESS(r, "conv2d_transpose"); + int r = xpu::conv2d_transpose_v2( + ctx.x_context(), + x.data(), + filter_.data(), + out->data(), + batch_size, + img_yc, + img_xh, + img_xw, + img_xc, + ksize, + strides, + paddings_, + dilations_, + groups, + nullptr, + nullptr, + nullptr, + true); + PADDLE_ENFORCE_XDNN_SUCCESS(r, "conv2d_transpose_v2"); } } // namespace phi diff --git a/paddle/phi/kernels/xpu/deformable_conv_grad_kernel.cc b/paddle/phi/kernels/xpu/deformable_conv_grad_kernel.cc index e354d4ebc49c5d12f536f742cb433a11fb6c4e81..ea2d8b1275b5882cefd08ec203a5aeea4c224ca2 100644 --- a/paddle/phi/kernels/xpu/deformable_conv_grad_kernel.cc +++ b/paddle/phi/kernels/xpu/deformable_conv_grad_kernel.cc @@ -54,21 +54,24 @@ void DeformableConvGradKernel(const Context& dev_ctx, dmask_data = dev_ctx.template Alloc(mask_grad); } - PADDLE_ENFORCE_EQ( - deformable_groups == 1, - true, - errors::InvalidArgument( - ("XPU only support deformable_groups == 1 in deformable_conv op."))); + if (phi::backends::xpu::get_xpu_version(dev_ctx.GetPlace().GetDeviceId()) == + phi::backends::xpu::XPUVersion::XPU1) { + PADDLE_ENFORCE_EQ( + deformable_groups == 1, + true, + errors::InvalidArgument(("XPU1 only support deformable_groups == 1 in " + "deformable_conv_grad op."))); + } PADDLE_ENFORCE_EQ( groups == 1, true, errors::InvalidArgument( - ("XPU only support groups == 1 in deformable_conv op."))); + ("XPU only support groups == 1 in deformable_conv_grad op."))); PADDLE_ENFORCE_EQ(filter.dims()[2] <= 8 && filter.dims()[3] <= 8, true, errors::InvalidArgument( "Filter high and weight should less than 8 on xpu " - "in deformable_conv op.")); + "in deformable_conv_grad op.")); const int batch_size = static_cast(x.dims()[0]); std::vector output_shape_vec(phi::vectorize(out_grad.dims())); diff --git a/paddle/phi/kernels/xpu/deformable_conv_kernel.cc b/paddle/phi/kernels/xpu/deformable_conv_kernel.cc index 064114a7f70442f7532d4837cd830b8f6e6e97a0..895af9486024dab941e5d897cbe0e6ca17766f2e 100644 --- a/paddle/phi/kernels/xpu/deformable_conv_kernel.cc +++ b/paddle/phi/kernels/xpu/deformable_conv_kernel.cc @@ -34,16 +34,19 @@ void DeformableConvKernel(const Context& dev_ctx, DenseTensor* out) { dev_ctx.template Alloc(out); - PADDLE_ENFORCE_EQ( - deformable_groups == 1, - true, - errors::InvalidArgument( - ("XPU only support deformable_groups == 1 in deformable_conv op."))); - PADDLE_ENFORCE_EQ( - groups == 1, - true, - errors::InvalidArgument( - ("XPU only support groups == 1 in deformable_conv op."))); + if (phi::backends::xpu::get_xpu_version(dev_ctx.GetPlace().GetDeviceId()) == + phi::backends::xpu::XPUVersion::XPU1) { + PADDLE_ENFORCE_EQ( + deformable_groups == 1, + true, + errors::InvalidArgument(("XPU1 only support deformable_groups == 1 in " + "deformable_conv op."))); + PADDLE_ENFORCE_EQ( + groups == 1, + true, + errors::InvalidArgument( + ("XPU1 only support groups == 1 in deformable_conv op."))); + } PADDLE_ENFORCE_EQ(filter.dims()[2] <= 8 && filter.dims()[3] <= 8, true, errors::InvalidArgument( diff --git a/python/paddle/fluid/tests/unittests/xpu/test_conv2d_transpose_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_conv2d_transpose_op_xpu.py index 47d13d04b3a1a1a95ca805b8ffe4b5dacaac374c..ed996133930bcbe1f6eb06991f89973a473de1fb 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_conv2d_transpose_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_conv2d_transpose_op_xpu.py @@ -280,6 +280,17 @@ class XPUTestConv2DTransposeOp(XPUOpTestWrapper): f_c = self.input_size[1] self.filter_size = [f_c, 6, 3, 3] + class TestWithEvenUpsample(TestConv2DTransposeOp): + def init_test_case(self): + self.pad = [2, 2] + self.stride = [2, 2] + self.groups = 1 + self.dilations = [1, 1] + self.output_size = [14, 14] + self.input_size = [2, 3, 7, 7] # NCHW + f_c = self.input_size[1] + self.filter_size = [f_c, 6, 5, 5] + support_types = get_xpu_op_support_types('conv2d_transpose') for stype in support_types: