Skip to content

Conversation

@co63oc
Copy link
Contributor

@co63oc co63oc commented Jun 29, 2025

PR Category

Execute Infrastructure

PR Types

Improvements

Description

[0-size Tensor No.160、162、164] Add 0-size Tensor support for conv1d_transpose

paddle.nn.functional.conv1d_transpose
paddle.nn.functional.conv2d_transpose
paddle.nn.functional.conv3d_transpose

修改 infermeta ,如果维度为0,不检查output_size 和 infer_shape 比较
符号推导没有对应代码

kernel 使用到depthwise_conv 和 conv kernel, 修改 depthwise_conv 和 conv kernel
正向测试返回填充时torch为错误,这里按0填充

python engine.py --accuracy=True --api_config='paddle.nn.functional.conv3d(Tensor([2, 1, 1, 1, 1],"float32"
), Tensor([3, 1, 3, 3, 0],"float32"), None, padding=1, stride=1, dilation=1, groups=1, data_format="NCDHW", )'

反向测试filter为填充0

import torch
x=torch.randn([0,1,1])
y=torch.randn([1,1,1])
x.requires_grad=True
y.requires_grad=True
z=torch.nn.functional.conv_transpose1d(x, y, groups=1)
z.sum().backward()
y.grad

tensor([[[0.]]])

PaddleAPITest 测试
GPU测试为torch error
image
image
image

CPU测试为torch error
image

@paddle-bot
Copy link

paddle-bot bot commented Jun 29, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Jun 29, 2025
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (develop@3efb8db). Learn more about missing BASE report.

Additional details and impacted files
@@             Coverage Diff             @@
##             develop    #73698   +/-   ##
===========================================
  Coverage           ?   100.00%           
===========================================
  Files              ?         1           
  Lines              ?         2           
  Branches           ?         0           
===========================================
  Hits               ?         2           
  Misses             ?         0           
  Partials           ?         0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DanielSun11
Copy link
Contributor

关于grad部分的修改存在一些疑问:
前向过程的输出out shape如下所示:
image
也就是可能存在x和filter都不为0 size的情况下output的shape为0?
此时grad 的dout应该也为0-size,这种情况下需不需要full一下dx和dfilter?
上述这个case可能比较难找,请co师傅研判下需不需要应对这种情况。

@co63oc
Copy link
Contributor Author

co63oc commented Jun 30, 2025

关于grad部分的修改存在一些疑问: 前向过程的输出out shape如下所示: image 也就是可能存在x和filter都不为0 size的情况下output的shape为0? 此时grad 的dout应该也为0-size,这种情况下需不需要full一下dx和dfilter? 上述这个case可能比较难找,请co师傅研判下需不需要应对这种情况。

https://github.com/PaddlePaddle/Paddle/blob/1d608281f1187715b80e31e1a3d00d6f09f92c6c/paddle/phi/kernels/impl/conv_transpose_grad_kernel_impl.h#L150C2-L150C3
image
默认是填充0,如果出错应该是有异常,可以按异常再查找问题,因为出现可能性不大,应该暂时可以不用修改

Copy link
Contributor

@DanielSun11 DanielSun11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DanielSun11 DanielSun11 merged commit 31b01e3 into PaddlePaddle:develop Jun 30, 2025
56 checks passed
@co63oc co63oc deleted the f63 branch July 10, 2025 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants